Changeset 897
- Timestamp:
- Sep 21, 2010, 10:58:35 AM (13 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy
r738 r897 258 258 259 259 //import workbook 260 session.importer_importeddata = ImporterService.importdata(session.importer_template_id, session.importer_workbook, 0, 1, session.importer_header)260 session.importer_importeddata = ImporterService.importdata(session.importer_template_id, session.importer_workbook, session.importer_sheetindex, session.importer_datamatrix_start, session.importer_header) 261 261 262 262 if (params.layout=="horizontal") -
trunk/grails-app/domain/dbnp/studycapturing/TemplateEntity.groovy
r881 r897 625 625 value = term 626 626 } 627 // TODO: search ontology for the term online (it may still exist) and insert it into the Term cache 628 // if not found, throw exception 629 else { 630 throw new IllegalArgumentException("Ontology term not recognized (not in the GSCF ontology cache): ${value} when setting field ${fieldName}") 631 } 627 632 } 628 633 } -
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r735 r897 66 66 def datamatrix_celldata = df.formatCellValue(sheet.getRow(datamatrix_start).getCell(columnindex)) 67 67 def datamatrix_cell = sheet.getRow(datamatrix_start).getCell(columnindex) 68 def headercell = sheet.getRow(sheet.getFirstRowNum()).getCell(columnindex) 68 println "frn is "+sheet.getFirstRowNum() 69 def headercell = sheet.getRow(headerrow-1+sheet.getFirstRowNum()).getCell(columnindex) 69 70 def tft = TemplateFieldType.STRING //default templatefield type 70 71 … … 247 248 datamatrix.each { record -> 248 249 record.each { entity -> 249 if(entity.validate()) { 250 switch (entity.getClass()) { 250 switch (entity.getClass()) { 251 251 case Study : print "Persisting Study `" + entity + "`: " 252 persistEntity(entity)253 252 if (persistEntity(entity)) validatedSuccesfully++ 253 break 254 254 case Subject : print "Persisting Subject `" + entity + "`: " 255 persistEntity(entity)256 study.addToSubjects(entity)257 255 study.addToSubjects(entity) 256 if (persistEntity(entity)) validatedSuccesfully++ 257 break 258 258 case Event : print "Persisting Event `" + entity + "`: " 259 persistEntity(entity)260 study.addToEvents(entity)261 259 study.addToEvents(entity) 260 if (persistEntity(entity)) validatedSuccesfully++ 261 break 262 262 case Sample : print "Persisting Sample `" + entity +"`: " 263 persistEntity(entity)264 study.addToSamples(entity)265 263 study.addToSamples(entity) 264 if (persistEntity(entity)) validatedSuccesfully++ 265 break 266 266 case SamplingEvent: print "Persisting SamplingEvent `" + entity + "`: " 267 persistEntity(entity)268 study.addToSamplingEvents(entity)269 267 study.addToSamplingEvents(entity) 268 if (persistEntity(entity)) validatedSuccesfully++ 269 break; 270 270 default : println "Skipping persisting of `" + entity.getclass() +"`" 271 break 272 } // end switch 273 validatedSuccesfully++ 274 } // end if 271 break 272 } // end switch 275 273 } // end record 276 274 } // end datamatrix … … 285 283 * 286 284 */ 287 def persistEntity(entity) { 288 if (!entity.save()) //.merge? 289 entity.errors.allErrors.each { 290 println it 285 boolean persistEntity(entity) { 286 println "persisting ${entity}" 287 // if not validated 288 if (entity.validate()) { 289 if (entity.save()) { //.merge? 290 return true 291 } 292 else { // if save was unsuccesful 293 entity.errors.allErrors.each { 294 println it 295 } 296 return false 297 } 298 } 299 else { // if not validated 300 entity.errors.each { 301 println it 302 } 303 return false 304 } 291 305 } 292 }293 306 294 307 /**
Note: See TracChangeset
for help on using the changeset viewer.