Changeset 1044 for trunk/grails-app/services
- Timestamp:
- Nov 1, 2010, 9:42:38 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.