Changeset 1207 for trunk/grails-app/services/dbnp
- Timestamp:
- Nov 26, 2010, 1:02:51 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r1202 r1207 281 281 def saveDatamatrix(Study study, datamatrix) { 282 282 def validatedSuccesfully = 0 283 def entitystored = null 284 study.refresh() 285 283 def entitystored = null 284 def failedtopersist = [] 285 def updatedentities = [] 286 study.refresh() 287 286 288 // go through the data matrix, read every record and validate the entity and try to persist it 287 289 datamatrix.each { record -> … … 290 292 case Study : print "Persisting Study `" + entity + "`: " 291 293 entity.owner = AuthenticationService.getLoggedInUser() 292 if (persistEntity(entity)) validatedSuccesfully++ 294 if (persistEntity(entity)) validatedSuccesfully++; 295 else failedtopersist.add(entity) 293 296 break 294 297 case Subject : print "Persisting Subject `" + entity + "`: " … … 300 303 // this entity is new, so add it to the study 301 304 if (entitystored==null) study.addToSubjects(entity) 302 else // existing entity, so update it305 else { // existing entity, so update it 303 306 updateEntity(entitystored, entity) 304 305 if (persistEntity(study)) validatedSuccesfully++ 307 updatedentities.add(entity) 308 } 309 310 if (persistEntity(study)) validatedSuccesfully++; 311 else failedtopersist.add(entity) 306 312 break 307 313 case Event : print "Persisting Event `" + entity + "`: " 308 314 entity.parent = study 309 315 study.addToEvents(entity) 310 if (persistEntity(entity)) validatedSuccesfully++ 316 if (persistEntity(entity)) validatedSuccesfully++; 317 else failedtopersist.add(entity) 311 318 break 312 319 case Sample : print "Persisting Sample `" + entity +"`: " … … 316 323 if (entity.validate()) { 317 324 study.addToSamples(entity) 318 if (persistEntity(study)) validatedSuccesfully++ 319 } 325 if (persistEntity(study)) validatedSuccesfully++; 326 } else failedtopersist.add(entity) 320 327 321 328 break … … 323 330 entity.parent = study 324 331 study.addToSamplingEvents(entity) 325 if (persistEntity(entity)) validatedSuccesfully++ 332 if (persistEntity(entity)) validatedSuccesfully++; 333 else failedtopersist.add(entity) 326 334 break 327 335 default : println "Skipping persisting of `" + entity.getclass() +"`" 336 failedtopersist.add(entity) 328 337 break 329 338 } // end switch 330 339 } // end record 331 340 } // end datamatrix 332 return validatedSuccesfully341 return [validatedSuccesfully, updatedentities, failedtopersist] 333 342 } 334 343
Note: See TracChangeset
for help on using the changeset viewer.