Changeset 1121
- Timestamp:
- Nov 11, 2010, 2:29:16 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy
r1103 r1121 170 170 171 171 // Loop through the form with cell fields and values 172 params.cell.index.each { mappingcolumnhash, value ->173 correctedcells.put( mappingcolumnhash, value)172 params.cell.index.each { cellhash, value -> 173 correctedcells.put(cellhash, value) 174 174 } 175 175 -
trunk/grails-app/domain/dbnp/importer/MappingColumn.groovy
r1103 r1121 1 1 package dbnp.importer 2 2 import dbnp.studycapturing.TemplateField 3 import dbnp.studycapturing.Identity 3 4 4 5 /** -
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r1103 r1121 219 219 def sheet = wb.getSheetAt(sheetindex) 220 220 def table = [] 221 def failedcells = [:] // map [recordhash, [mappingcolumnlist]] values221 def failedcells = [:] // map [recordhash, importrecord] values 222 222 223 223 // walk through all rows and fill the table with records 224 (rowindex..sheet.getLastRowNum()).each { i -> 225 //table.add(createRecord(template_id, sheet.getRow(i), mcmap)) 224 (rowindex..sheet.getLastRowNum()).each { i -> 226 225 // Create an entity record based on a row read from Excel and store the cells which failed to be mapped 227 226 def (record, failed) = createRecord(template_id, sheet.getRow(i), mcmap) … … 232 231 // If failed cells have been found, add them to the failed cells map 233 232 // the record hashcode is later on used to put the failed data back 234 // in the data matrix 235 if (failed. size()!=0) failedcells.put(record.hashCode(), failed)233 // in the data matrix 234 if (failed.importcells.size()>0) failedcells.put(record.hashCode(), failed) 236 235 } 237 238 failedcells.each { record ->239 record.each { cell ->240 cell.each {241 println it.value.dump()242 }243 }244 }245 246 236 247 237 return [table,failedcells] … … 257 247 **/ 258 248 def saveCorrectedCells(datamatrix, failedcells, correctedcells) { 259 // Loop through all failed cells 260 261 failedcells.each { mcrecord -> 262 mcrecord.each { mappingcolumn -> 249 250 // Loop through all failed cells (stored as 251 failedcells.each { record -> 252 record.value.importcells.each { cell -> 253 263 254 // Get the corrected value 264 def correctedvalue = correctedcells.find { it.key.toInteger() == mappingcolumn.hashCode()}.value255 def correctedvalue = correctedcells.find { it.key.toInteger() == cell.getIdentifier()}.value 265 256 266 257 // Find the record in the table which the mappingcolumn belongs to 267 def tablerecord = datamatrix.find { it.hashCode() == mcrecord.key }268 269 // Loop through all entities in the record 258 def tablerecord = datamatrix.find { it.hashCode() == record.key } 259 260 // Loop through all entities in the record and correct them if necessary 270 261 tablerecord.each { rec -> 271 262 rec.each { entity -> 272 263 try { 273 264 // Update the entity field 274 entity.setFieldValue( mappingcolumn.value.property[0], correctedvalue)275 println "Adjusted " + mappingcolumn.value.property[0]+ " to " + correctedvalue265 entity.setFieldValue(cell.mappingcolumn.property, correctedvalue) 266 //println "Adjusted " + cell.mappingcolumn.property + " to " + correctedvalue 276 267 } 277 268 catch (Exception e) { 278 println "Could not map corrected ontology"269 //println "Could not map corrected ontology: " + cell.mappingcolumn.property + " to " + correctedvalue 279 270 } 280 271 } 281 272 } // end of table record 282 } // end of mappingrecord283 } // end of failed cells loop273 } // end of cell record 274 } // end of failedlist 284 275 } 285 276 … … 428 419 def tft = TemplateFieldType 429 420 def record = [] // list of entities and the read values 430 def failed = [] // list of failed columns [mappingcolumn]with the value which couldn't be mapped into the entity421 def failed = new ImportRecord() // list of failed cells with the value which couldn't be mapped into the entity 431 422 432 423 // Initialize all possible entities with the chosen template … … 460 451 temp.value = "undefined" 461 452 failed.add(temp) 462 }*/ 453 }*/ 463 454 464 455 465 456 try { 466 /*if ((mc.templatefieldtype == TemplateFieldType.ONTOLOGYTERM) && (value == ""))467 {468 def temp = new MappingColumn()469 temp.properties = mc.properties470 temp.value="unknown"471 failed.add(temp)472 }*/473 474 457 // which entity does the current cell (field) belong to? 475 458 switch (mc.entity) { … … 495 478 } catch (IllegalArgumentException iae) { 496 479 // store the mapping column and value which failed 497 def temp = new MappingColumn() 498 temp.properties = mc.properties 499 temp.value = value 500 failed.add(temp) 480 def mcInstance = new MappingColumn() 481 mcInstance.properties = mc.properties 482 failed.addToImportcells( 483 new ImportCell(mappingcolumn:mcInstance, 484 value:value) 485 ) 501 486 } 502 487 } // end 503 488 } // end for 504 505 489 // a failed column means that using the entity.setFieldValue() threw an exception 506 490 return [record, failed] -
trunk/grails-app/views/importer/common/_failedcells.gsp
r1103 r1121 31 31 </tr> 32 32 <g:form name="failedcellsform" action="saveCorrectedCells"> 33 <g:each var="record" in="${failedcells}"> 34 <g:each var="list" in="${record}"> 35 <g:each var="cell" in="${list}"> 33 <g:each var="item" in="${failedcells}"> <!-- [recordhash, importrecord] --> 34 <g:each var="cell" in="${item.value.importcells}"> 36 35 <tr> 37 <td>${cell. value.name}</td>36 <td>${cell.mappingcolumn.name}</td> 38 37 <td>-</td> 39 <td>${cell .value.value}</td>38 <td>${cell}</td> 40 39 <td> 41 <input type="text" name="cell.index.${cell. hashCode()}" rel="ontology-all-name"/>42 <!-- <input type="hidden" name="cell.index.${cell .value}-concept_id"/>43 <input type="hidden" name="cell.index.${cell .value}-ontology_id"/>44 <input type="hidden" name="cell.index.${cell .value}-full_id"/> -->40 <input type="text" name="cell.index.${cell.getIdentifier()}" rel="ontology-all-name"/> 41 <!-- <input type="hidden" name="cell.index.${cell}-concept_id"/> 42 <input type="hidden" name="cell.index.${cell}-ontology_id"/> 43 <input type="hidden" name="cell.index.${cell}-full_id"/> --> 45 44 </td> 46 </tr> 47 </g:each> 45 </tr> 48 46 </g:each> 49 47 </g:each> -
trunk/grails-app/views/importer/common/_missingproperties.gsp
r1103 r1121 25 25 <g:set var="showHeader" value="${true}"/> 26 26 <g:each status="index" var="table" in="${datamatrix}"> 27 <g:each status="i" var="entity" in="${table}"> 27 <g:each status="i" var="entity" in="${table}"> 28 28 <g:if test="${showHeader}"> 29 29 <g:set var="showHeader" value="${false}"/>
Note: See TracChangeset
for help on using the changeset viewer.