Changeset 1202 for trunk/grails-app/services
- Timestamp:
- Nov 25, 2010, 3:51:14 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r1190 r1202 217 217 def sheet = wb.getSheetAt(sheetindex) 218 218 def table = [] 219 def failedcells = [ :] // map [recordhash, importrecord] values219 def failedcells = [] // list of records 220 220 221 221 // walk through all rows and fill the table with records … … 227 227 table.add(record) 228 228 229 // If failed cells have been found, add them to the failed cells map 230 // the record hashcode is later on used to put the failed data back 231 // in the data matrix 232 if (failed.importcells?.size()>0) failedcells.put(record.hashCode(), failed) 229 // If failed cells have been found, add them to the failed cells list 230 if (failed?.importcells?.size()>0) failedcells.add(failed) 233 231 } 234 232 … … 423 421 def tft = TemplateFieldType 424 422 def record = [] // list of entities and the read values 425 def failed = new ImportRecord() // list of failed cells with the value which couldn't be mapped into the entity423 def failed = new ImportRecord() // map with entity identifier and failed mappingcolumn 426 424 427 425 // Initialize all possible entities with the chosen template … … 446 444 } 447 445 448 //println "temateplfedielfdtype=" + mc.templatefieldtype449 // Are we trying to map an ontology term which is empty? Then it is a failed cell450 /*if (value=="") {451 println "empty term"452 def temp = new MappingColumn()453 //temp.properties = mc.properties454 temp.value = "undefined"455 failed.add(temp)456 }*/457 458 459 446 try { 460 447 // which entity does the current cell (field) belong to? … … 481 468 } catch (IllegalArgumentException iae) { 482 469 // store the mapping column and value which failed 470 def identifier 471 472 switch (mc.entity) { 473 case Study: identifier = study.getIdentifier() 474 break 475 case Subject: identifier = subject.getIdentifier() 476 break 477 case SamplingEvent: identifier = samplingEvent.getIdentifier() 478 break 479 case Event: identifier = event.getIdentifier() 480 break 481 case Sample: identifier = sample.getIdentifier() 482 break 483 case Object: // don't import 484 break 485 } 486 483 487 def mcInstance = new MappingColumn() 484 488 mcInstance.properties = mc.properties 485 failed.addToImportcells( 486 new ImportCell(mappingcolumn:mcInstance, 487 value:value) 488 ) 489 failed.addToImportcells(new ImportCell(mappingcolumn:mcInstance, value:value, entityidentifier:identifier)) 489 490 } 490 491 } // end 491 492 } // end for 492 493 // a failed column means that using the entity.setFieldValue() threw an exception 493 return [record, failed] 494 return [record, failed] 494 495 } 495 496
Note: See TracChangeset
for help on using the changeset viewer.