Changeset 485 for trunk/grails-app/services
- Timestamp:
- May 27, 2010, 1:13:50 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r415 r485 46 46 /** 47 47 * @param wb high level representation of the workbook 48 * @param sheetindex sheet to use within the workbook 48 49 * @return header representation as a MappingColumn hashmap 49 50 */ 50 def getHeader(HSSFWorkbook wb, int sheetindex ){51 def getHeader(HSSFWorkbook wb, int sheetindex, theEntity=0){ 51 52 52 53 def sheet = wb.getSheetAt(sheetindex) … … 55 56 def header = [:] 56 57 def df = new DataFormatter() 57 58 def property = new dbnp.studycapturing.TemplateField() 58 59 59 60 for (HSSFCell c: sheet.getRow(datamatrix_start)) { … … 67 68 switch (datamatrix_celltype) { 68 69 case HSSFCell.CELL_TYPE_STRING: 69 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), templatefieldtype:TemplateFieldType.STRING, index:index );70 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), templatefieldtype:TemplateFieldType.STRING, index:index, entity:theEntity, property:property); 70 71 break 71 72 case HSSFCell.CELL_TYPE_NUMERIC: 72 73 if (HSSFDateUtil.isCellDateFormatted(c)) { 73 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), templatefieldtype:TemplateFieldType.DATE, index:index )74 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), templatefieldtype:TemplateFieldType.DATE, index:index, entity:theEntity, property:property) 74 75 } 75 76 else 76 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), templatefieldtype:TemplateFieldType.INTEGER,index:index );77 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), templatefieldtype:TemplateFieldType.INTEGER,index:index, entity:theEntity, property:property); 77 78 break 78 79 case HSSFCell.CELL_TYPE_BLANK: 79 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), templatefieldtype:TemplateFieldType.STRING, index:index );80 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), templatefieldtype:TemplateFieldType.STRING, index:index, entity:theEntity, property:property); 80 81 break 81 82 default: 82 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), templatefieldtype:TemplateFieldType.STRING,index:index );83 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), templatefieldtype:TemplateFieldType.STRING,index:index, entity:theEntity, property:property); 83 84 break 84 85 } … … 160 161 def sheet = wb.getSheetAt(sheetindex) 161 162 def table = [] 163 162 164 163 165 // walk through all rows 164 166 (rowindex..sheet.getLastRowNum()).each { i -> 165 table.add(createRecord(template_id, sheet.getRow(i), mcmap)) 167 table.add(createRecord(template_id, sheet.getRow(i), mcmap)) 166 168 } 167 169 … … 263 265 def sample = new Sample(name:"New sample", template:template) 264 266 265 for (HSSFCell cell: excelrow) { 267 for (HSSFCell cell: excelrow) { 266 268 def mc = mcmap[cell.getColumnIndex()] 267 def value = formatValue(df.formatCellValue(cell), mc.templatefieldtype) 269 def value = formatValue(df.formatCellValue(cell), mc.templatefieldtype) 268 270 269 271 switch(mc.entity) {
Note: See TracChangeset
for help on using the changeset viewer.