Changeset 669
- Timestamp:
- Jul 20, 2010, 4:21:50 PM (12 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy
r661 r669 119 119 table.each { entity -> 120 120 entity.giveFields().each { field -> 121 print ":" + params["entity_" + entity.hashCode() + "_" + field.escapedName()]121 //print ":" + params["entity_" + entity.hashCode() + "_" + field.escapedName()] 122 122 entity.setFieldValue (field.toString(), params["entity_" + entity.hashCode() + "_" + field.escapedName()]) 123 123 } … … 223 223 // Store the selected property for this column into the column map for the ImporterService 224 224 session.importer_header[columnindex.toInteger()].property = property 225 225 226 // Look up the template field type of the target TemplateField and store it also in the map 226 session.importer_header[columnindex.toInteger()].templatefieldtype = entityObj.getFieldType(property) 227 session.importer_header[columnindex.toInteger()].templatefieldtype = entityObj.giveFieldType(property) 228 229 // Is a "Don't import" property assigned to the column? 230 session.importer_header[columnindex.toInteger()].dontimport = (property=="dontimport") ? true : false 227 231 228 232 //if it's an identifier set the mapping column true or false -
trunk/grails-app/domain/dbnp/importer/MappingColumn.groovy
r545 r669 20 20 String value 21 21 Boolean identifier 22 Boolean dontimport 22 23 23 24 static constraints = { 24 25 name(unique: true) 26 dontimport(default:false) 25 27 } 26 28 -
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r666 r669 171 171 172 172 (0..header.size()-1).each { columnindex -> 173 def c = sheet.getRow(rowindex).getCell(columnindex, org.apache.poi.ss.usermodel.Row.CREATE_NULL_AS_BLANK) 174 println "DAS " + columnindex + ":" + c 173 def c = sheet.getRow(rowindex).getCell(columnindex, org.apache.poi.ss.usermodel.Row.CREATE_NULL_AS_BLANK) 175 174 row.add(c) 175 //if (c.getCellType() == c.CELL_TYPE_STRING) println "STR"+c.getStringCellValue() 176 //if (c.getCellType() == c.CELL_TYPE_NUMERIC) println "INT" +c.getNumericCellValue() 176 177 } 177 178 //row.add(df.formatCellValue(c)) … … 224 225 def sheet = wb.getSheetAt(sheetindex) 225 226 def table = [] 226 227 227 228 228 // walk through all rows … … 242 242 return table 243 243 } 244 245 /** 246 // start transaction 247 def transaction = sessionFactory.getCurrentSession().beginTransaction() 248 // persist data to the database 249 try { 250 // commit transaction 251 println "commit" 252 transaction.commit() 253 success() 254 } catch (Exception e) { 255 // rollback 256 // stacktrace in flash scope 257 flash.debug = e.getStackTrace() 258 259 println "rollback" 260 transaction.rollback() 261 error() 262 } 263 */ 264 244 265 245 /** 266 246 * Method to store a matrix containing the entities in a record like structure. Every row in the table … … 332 312 def value 333 313 334 try { 335 value = formatValue(df.formatCellValue(cell), mc.templatefieldtype) 336 } catch (NumberFormatException nfe) { 337 value = "" 338 } 314 if (!mc.dontimport) { 315 /*try { 316 value = formatValue(df.formatCellValue(cell), mc.templatefieldtype) 317 } catch (NumberFormatException nfe) { 318 value = "" 319 }*/ 320 value = df.formatCellValue(cell) 339 321 340 322 switch(mc.entity) { … … 354 336 break 355 337 } // end switch 356 } // end for 338 } // end 339 } // end for 357 340 358 341 return record -
trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy
r632 r669 16 16 package dbnp.importer 17 17 import dbnp.studycapturing.Template 18 import dbnp.studycapturing.TemplateField 18 19 import dbnp.studycapturing.TemplateFieldType 19 20 import org.apache.poi.hssf.usermodel.HSSFCell … … 130 131 def res = "<select style=\"font-size:10px\" name=\"${name}.index.${columnIndex}\">" 131 132 133 res += "<option value=\"dontimport\" selected>Don't import</option>" 134 132 135 options.each { f -> 133 136 res+= "<option value=\"${f.name}\">"
Note: See TracChangeset
for help on using the changeset viewer.