Changeset 1527
- Timestamp:
- Feb 16, 2011, 2:22:09 PM (12 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy
r1525 r1527 351 351 flow.importer_datamatrix_start = params.datamatrix_start.toInteger() - 1 // 0 == first row 352 352 flow.importer_headerrow = params.headerrow.toInteger() 353 flow.importer_entityclass = entityClass .getClass()353 flow.importer_entityclass = entityClass 354 354 355 355 // Get the header from the Excel file using the arguments given in the first step of the wizard … … 372 372 } 373 373 374 374 375 log.error ".importer wizard not all fields are filled in" 375 376 this.appendErrorMap(['error': "Not all fields are filled in, please fill in or select all fields"], flash.wizardErrors) … … 386 387 boolean propertiesLoadImportMappingPage(flow, flash, params) { 387 388 def im = ImportMapping.get(params.importmapping_id.toInteger()) 388 389 flow.importer_header.each { 390 println "original=" + it.dump() 391 } 389 im.refresh() 392 390 393 391 im.mappingcolumns.each { mappingcolumn -> 394 flow.importer_header[mappingcolumn.index.toInteger()] = mappingcolumn 395 println "adjusted=" + mappingcolumn.dump() 392 def mc = new MappingColumn() 393 mc.properties = mappingcolumn.properties 394 395 flow.importer_header[mappingcolumn.index.toInteger()] = mc 396 396 } 397 397 } … … 418 418 // Create an actual class instance of the selected entity with the selected template 419 419 // This should be inside the closure because in some cases in the advanced importer, the fields can have different target entities 420 def entityClass = GdtService.getInstanceByEntityName(flow.importer_header[columnindex.toInteger()].entity.getName())421 def entityObj = entityClass.newInstance(template:template)420 //def entityClass = GdtService.getInstanceByEntityName(flow.importer_header[columnindex.toInteger()].entity.getName()) 421 def entityObj = flow.importer_entityclass.newInstance(template:template) 422 422 423 423 def dontimport = (property == "dontimport") ? true : false … … 432 432 property:property, 433 433 index:columnindex, 434 entity :flow.importer_header[columnindex.toInteger()].entity,434 entityclass:flow.importer_entityclass, 435 435 templatefieldtype:entityObj.giveFieldType(property), 436 436 dontimport: dontimport, … … 439 439 // Save mappingcolumn 440 440 if (mc.validate()) { 441 im.addToMappingcolumns(mc) 441 im.addToMappingcolumns(mc) 442 442 } 443 443 else { … … 449 449 // Save importmapping 450 450 if (im.validate()) { 451 im.save(flush:true) 451 im.save(flush:true) 452 452 } 453 453 else { … … 488 488 // Create an actual class instance of the selected entity with the selected template 489 489 // This should be inside the closure because in some cases in the advanced importer, the fields can have different target entities 490 def entityClass = Class.forName(flow.importer_header[columnindex.toInteger()].entity .getName(), true, this.getClass().getClassLoader())490 def entityClass = Class.forName(flow.importer_header[columnindex.toInteger()].entityclass.getName(), true, this.getClass().getClassLoader()) 491 491 def entityObj = entityClass.newInstance(template: template) 492 492 … … 707 707 return errors 708 708 } 709 709 710 } -
trunk/grails-app/domain/dbnp/importer/MappingColumn.groovy
r1525 r1527 16 16 String name 17 17 TemplateFieldType templatefieldtype 18 Class entity 18 Class entityclass 19 19 String property 20 20 Integer index … … 36 36 37 37 String toString() { 38 return "Name:" + name + "/TemplateFieldType:" + templatefieldtype + "/Entity:" + entity + "/Property:" + property + "/Index:" + index + "/Value:" + value + "/Identifier:" + identifier38 return "Name:" + name + "/TemplateFieldType:" + templatefieldtype + "/Entity:" + entityclass + "/Property:" + property + "/Index:" + index + "/Value:" + value + "/Identifier:" + identifier 39 39 } 40 40 } -
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r1515 r1527 76 76 templatefieldtype: fieldtype, 77 77 index: columnindex, 78 entity : theEntity,78 entityclass: theEntity, 79 79 property: property); 80 80 … … 107 107 templatefieldtype: fieldtype, 108 108 index: columnindex, 109 entity : theEntity,109 entityclass: theEntity, 110 110 property: property); 111 111 break … … 114 114 templatefieldtype: TemplateFieldType.STRING, 115 115 index: columnindex, 116 entity : theEntity,116 entityclass: theEntity, 117 117 property: property); 118 118 break … … 121 121 templatefieldtype: TemplateFieldType.STRING, 122 122 index: columnindex, 123 entity : theEntity,123 entityclass: theEntity, 124 124 property: property); 125 125 break … … 442 442 443 443 try { 444 println "importdata="+mc.entityclass 444 445 // which entity does the current cell (field) belong to? 445 switch (mc.entity ) {446 switch (mc.entityclass) { 446 447 case Study: // does the entity already exist in the record? If not make it so. 447 (record.any {it.getClass() == mc.entity }) ? 0 : record.add(study)448 (record.any {it.getClass() == mc.entityclass}) ? 0 : record.add(study) 448 449 study.setFieldValue(mc.property, value) 449 450 break 450 case Subject: (record.any {it.getClass() == mc.entity }) ? 0 : record.add(subject)451 case Subject: (record.any {it.getClass() == mc.entityclass}) ? 0 : record.add(subject) 451 452 subject.setFieldValue(mc.property, value) 452 453 break 453 case SamplingEvent: (record.any {it.getClass() == mc.entity }) ? 0 : record.add(samplingEvent)454 case SamplingEvent: (record.any {it.getClass() == mc.entityclass}) ? 0 : record.add(samplingEvent) 454 455 samplingEvent.setFieldValue(mc.property, value) 455 456 break 456 case Event: (record.any {it.getClass() == mc.entity }) ? 0 : record.add(event)457 case Event: (record.any {it.getClass() == mc.entityclass}) ? 0 : record.add(event) 457 458 event.setFieldValue(mc.property, value) 458 459 break 459 case Sample: (record.any {it.getClass() == mc.entity }) ? 0 : record.add(sample)460 case Sample: (record.any {it.getClass() == mc.entityclass}) ? 0 : record.add(sample) 460 461 sample.setFieldValue(mc.property, value) 461 462 break … … 468 469 def identifier 469 470 470 switch (mc.entity ) {471 switch (mc.entityclass) { 471 472 case Study: identifier = "entity_" + study.getIdentifier() + "_" + mc.property 472 473 break -
trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy
r1515 r1527 111 111 def selected = (attrs['selected']) ? attrs['selected'] : "" 112 112 113 def domainfields = mc.entity .giveDomainFields().findAll { it.type == mc.templatefieldtype }113 def domainfields = mc.entityclass.giveDomainFields().findAll { it.type == mc.templatefieldtype } 114 114 domainfields = domainfields.findAll { it.preferredIdentifier != mc.identifier} 115 115 … … 118 118 t.fields + mc.entity.giveDomainFields() : 119 119 t.fields.findAll { it.type == mc.templatefieldtype } + domainfields*/ 120 def templatefields = t.fields + mc.entity .giveDomainFields()120 def templatefields = t.fields + mc.entityclass.giveDomainFields() 121 121 122 122 // map identifier to preferred column 123 def prefcolumn = mc.entity .giveDomainFields().findAll { it.preferredIdentifier == true }123 def prefcolumn = mc.entityclass.giveDomainFields().findAll { it.preferredIdentifier == true } 124 124 125 125 /*(mc.identifier) ? out << createPropertySelect(attrs['name'], prefcolumn, matchvalue, mc.index) :
Note: See TracChangeset
for help on using the changeset viewer.