- Timestamp:
- Jun 9, 2010, 12:54:12 PM (13 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy
r534 r545 58 58 def wb = handleUpload('importfile') 59 59 60 61 60 session.importer_header = ImporterService.getHeader(wb, 0) 62 61 session.importer_study = Study.get(params.study.id.toInteger()) 63 62 session.importer_template_id = params.template_id 64 63 session.importer_workbook = wb 64 65 65 66 66 67 render (view:"step1_advanced", model:[header:session.importer_header, datamatrix:ImporterService.getDatamatrix(wb, 0, 5)]) … … 163 164 164 165 params.entity.index.each { columnindex, entityname -> 165 Class clazz 166 Class clazz = null 166 167 167 168 switch (entityname) { 168 case "Study" : clazz = Study169 break 170 case "Subject" : clazz = Subject171 break 172 case "Event" : clazz = Event173 break 174 case "Protocol" : clazz = Protocol175 break 176 case "Sample" : clazz = Sample169 case "Study" : clazz = dbnp.studycapturing.Study 170 break 171 case "Subject" : clazz = dbnp.studycapturing.Subject 172 break 173 case "Event" : clazz = dbnp.studycapturing.Event 174 break 175 case "Protocol" : clazz = dbnp.studycapturing.Protocol 176 break 177 case "Sample" : clazz = dbnp.studycapturing.Sample 177 178 break 178 179 default: clazz = Object -
trunk/grails-app/domain/dbnp/importer/MappingColumn.groovy
r534 r545 26 26 27 27 String toString() { 28 return "Name:" + name + "/TemplateFieldType:" + templatefieldtype + "/Entity:" + entity + "/Property:" + property + "/Index:" + index + "/Value:" + value + "/Identifier:" + identifier28 return "Name:" + name + "/TemplateFieldType:" + fieldtype + "/Entity:" + entity + "/Property:" + property + "/Index:" + index + "/Value:" + value + "/Identifier:" + identifier 29 29 } 30 30 } -
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r534 r545 49 49 * @return header representation as a MappingColumn hashmap 50 50 */ 51 def getHeader(HSSFWorkbook wb, int sheetindex, theEntity= 0){51 def getHeader(HSSFWorkbook wb, int sheetindex, theEntity=null){ 52 52 53 53 def sheet = wb.getSheetAt(sheetindex) … … 62 62 def datamatrix_celltype = sheet.getRow(datamatrix_start).getCell(index).getCellType() 63 63 def headercell = sheet.getRow(sheet.getFirstRowNum()).getCell(index) 64 64 def tft = TemplateFieldType.STRING //default templatefield type 65 66 65 67 // Check for every celltype, currently redundant code, but possibly this will be 66 68 // a piece of custom code for every cell type like specific formatting … … 70 72 //parse cell value as double 71 73 def parsable = true 72 def templatefieldtype = TemplateFieldType.STRING74 def fieldtype = TemplateFieldType.STRING 73 75 74 76 // is this string perhaps a double? … … 77 79 } catch (NumberFormatException nfe) { parsable = false } 78 80 finally { 79 if (parsable) templatefieldtype = TemplateFieldType.DOUBLE81 if (parsable) fieldtype = TemplateFieldType.DOUBLE 80 82 } 81 83 82 84 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), 83 templatefieldtype: templatefieldtype,85 templatefieldtype:fieldtype, 84 86 index:index, 85 87 entity:theEntity, 86 88 property:property); 89 87 90 break 88 91 case HSSFCell.CELL_TYPE_NUMERIC: … … 115 118 property:property); 116 119 break 117 } 118 } 120 } // end of switch 121 } // end of cell loop 119 122 return header 120 123 } … … 305 308 study.setFieldValue(mc.property, value) 306 309 break 307 case Subject : (record.any {it.getClass()==mc.entity}) ? 0 : record.add(subject) 310 case Subject : (record.any {it.getClass()==mc.entity}) ? 0 : record.add(subject) 311 println "TOT HIER" + mc.property + "/ " + value 308 312 subject.setFieldValue(mc.property, value) 309 313 break -
trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy
r534 r545 83 83 def mc = attrs['mappingcolumn'] 84 84 def allfieldtypes = attrs['allfieldtypes'] 85 def domainfields = mc.entity.giveDomainFields().findAll { it.type == mc.templatefieldtype } 86 domainfields = domainfields.findAll { it.preferredIdentifier != mc.identifier} 85 87 86 88 //def templatefields = (allfieldtypes=="true") ? t.fields : t.fields.findAll { it.type == mc.templatefieldtype } 87 89 def templatefields = (allfieldtypes=="true") ? 88 90 t.fields + mc.entity.giveDomainFields() : 89 t.fields.findAll { it.type == mc.templatefieldtype } + mc.entity.giveDomainFields()91 t.fields.findAll { it.type == mc.templatefieldtype } + domainfields 90 92 91 (mc.identifier) ? out << "<select style=\"font-size:10px\" name=\"\" disabled><option>Identifier</option></select>": 93 // map identifier to preferred column 94 def prefcolumn = mc.entity.giveDomainFields().findAll { it.preferredIdentifier == true } 95 96 (mc.identifier) ? out << createPropertySelect(attrs['name'], prefcolumn, mc.index) : 92 97 out << createPropertySelect(attrs['name'], templatefields, mc.index) 93 98 }
Note: See TracChangeset
for help on using the changeset viewer.