- Timestamp:
- Nov 1, 2010, 9:42:38 PM (12 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy
r989 r1044 229 229 render(view:"step2", model:[entities:selectedentities, header:session.importer_header, templates:templates]) 230 230 } 231 232 /** 233 * @param columnproperty array of columns containing index and property (represented as a String) 231 232 /** 233 * Method which stores the properties set per column and then imports the data. 234 * 235 * @param columnproperty array of columns containing index and property (represented as a String) 234 236 * 235 237 */ 236 def saveProperties = { 238 def saveProperties = { 237 239 238 240 // Find actual Template object from the chosen template name … … 261 263 } 262 264 263 //import workbook 264 session.importer_importeddata = ImporterService.importdata(session.importer_template_id, session.importer_workbook, session.importer_sheetindex, session.importer_datamatrix_start, session.importer_header) 265 //import workbook and store it in a session 266 session.importer_importeddata = ImporterService.importData(session.importer_template_id, session.importer_workbook, session.importer_sheetindex, session.importer_datamatrix_start, session.importer_header) 267 268 // 269 //render(view:"step2a_simple", model:[datamatrix:session.importer_importeddata]) 265 270 266 271 if (params.layout=="horizontal") -
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r1028 r1044 222 222 * @see dbnp.importer.MappingColumn 223 223 */ 224 def import data(template_id, HSSFWorkbook wb, int sheetindex, int rowindex, mcmap) {224 def importData(template_id, HSSFWorkbook wb, int sheetindex, int rowindex, mcmap) { 225 225 def sheet = wb.getSheetAt(sheetindex) 226 226 def table = [] … … 376 376 def template = Template.get(template_id) 377 377 def record = [] 378 def failed = [:] 378 379 379 380 // Initialize all possible entities with the chosen template … … 388 389 // get the MappingColumn information of the current cell 389 390 def mc = mcmap[cell.getColumnIndex()] 390 def value 391 def value 391 392 392 393 // Check if column must be imported … … 402 403 // which entity does the current cell (field) belong to? 403 404 switch (mc.entity) { 404 case Study: (record.any {it.getClass() == mc.entity}) ? 0 : record.add(study) 405 case Study: // does the entity already exist in the record? If not make it so. 406 (record.any {it.getClass() == mc.entity}) ? 0 : record.add(study) 405 407 study.setFieldValue(mc.property, value) 406 408 break … … 422 424 } catch (IllegalArgumentException iae) { 423 425 // leave the field empty and let the user choose the ontology manually in a later step 424 426 failed.put(mc, value) 425 427 } 426 428 } // end 427 429 } // end for 428 430 429 return record 431 // add the failed columns to the record (might also be just an empty map if nothing failed) 432 // a failed column means that using the entity.setFieldValue() threw an exception 433 record.add(failed) 434 435 return record 430 436 } 431 437
Note: See TracChangeset
for help on using the changeset viewer.