Changeset 1202
- Timestamp:
- Nov 25, 2010, 3:51:14 PM (13 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy
r1194 r1202 170 170 table.each { entity -> 171 171 entity.giveFields().each { field -> 172 entity.setFieldValue (field.toString(), params["entity_" + entity. hashCode() + "_" + field.escapedName()])172 entity.setFieldValue (field.toString(), params["entity_" + entity.getIdentifier() + "_" + field.escapedName()]) 173 173 } 174 174 } … … 176 176 177 177 // a new ontology term was added, so stay at the current step otherwise go to the next step 178 if (params.updatefield) render(view:"step3_simple", model:[datamatrix:session.importer_importeddata ])178 if (params.updatefield) render(view:"step3_simple", model:[datamatrix:session.importer_importeddata, failedcells:session.importer_failedcells]) 179 179 else render(view:"step3", model:[datamatrix:session.importer_importeddata]) 180 180 } … … 323 323 session.importer_failedcells = failedcells 324 324 325 if (failedcells.size()!=0) 325 // Are there any failed cells, then show an extra step to correct the cells 326 /*if (failedcells.size()!=0) 326 327 render(view:"step2a_simple", model:[failedcells:session.importer_failedcells]) 327 else { 328 else {*/ 328 329 if (params.layout=="horizontal") 329 render(view:"step3_simple", model:[datamatrix:session.importer_importeddata ])330 render(view:"step3_simple", model:[datamatrix:session.importer_importeddata, failedcells:session.importer_failedcells]) 330 331 else if (params.layout=="vertical") 331 332 render(view:"step3", model:[datamatrix:session.importer_importeddata]) 332 }333 //} 333 334 } 334 335 -
trunk/grails-app/domain/dbnp/importer/ImportCell.groovy
r1121 r1202 20 20 class ImportCell extends Identity { 21 21 MappingColumn mappingcolumn 22 int entityidentifier 22 23 String value 23 24 -
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r1190 r1202 217 217 def sheet = wb.getSheetAt(sheetindex) 218 218 def table = [] 219 def failedcells = [ :] // map [recordhash, importrecord] values219 def failedcells = [] // list of records 220 220 221 221 // walk through all rows and fill the table with records … … 227 227 table.add(record) 228 228 229 // If failed cells have been found, add them to the failed cells map 230 // the record hashcode is later on used to put the failed data back 231 // in the data matrix 232 if (failed.importcells?.size()>0) failedcells.put(record.hashCode(), failed) 229 // If failed cells have been found, add them to the failed cells list 230 if (failed?.importcells?.size()>0) failedcells.add(failed) 233 231 } 234 232 … … 423 421 def tft = TemplateFieldType 424 422 def record = [] // list of entities and the read values 425 def failed = new ImportRecord() // list of failed cells with the value which couldn't be mapped into the entity423 def failed = new ImportRecord() // map with entity identifier and failed mappingcolumn 426 424 427 425 // Initialize all possible entities with the chosen template … … 446 444 } 447 445 448 //println "temateplfedielfdtype=" + mc.templatefieldtype449 // Are we trying to map an ontology term which is empty? Then it is a failed cell450 /*if (value=="") {451 println "empty term"452 def temp = new MappingColumn()453 //temp.properties = mc.properties454 temp.value = "undefined"455 failed.add(temp)456 }*/457 458 459 446 try { 460 447 // which entity does the current cell (field) belong to? … … 481 468 } catch (IllegalArgumentException iae) { 482 469 // store the mapping column and value which failed 470 def identifier 471 472 switch (mc.entity) { 473 case Study: identifier = study.getIdentifier() 474 break 475 case Subject: identifier = subject.getIdentifier() 476 break 477 case SamplingEvent: identifier = samplingEvent.getIdentifier() 478 break 479 case Event: identifier = event.getIdentifier() 480 break 481 case Sample: identifier = sample.getIdentifier() 482 break 483 case Object: // don't import 484 break 485 } 486 483 487 def mcInstance = new MappingColumn() 484 488 mcInstance.properties = mc.properties 485 failed.addToImportcells( 486 new ImportCell(mappingcolumn:mcInstance, 487 value:value) 488 ) 489 failed.addToImportcells(new ImportCell(mappingcolumn:mcInstance, value:value, entityidentifier:identifier)) 489 490 } 490 491 } // end 491 492 } // end for 492 493 // a failed column means that using the entity.setFieldValue() threw an exception 493 return [record, failed] 494 return [record, failed] 494 495 } 495 496 -
trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy
r1143 r1202 60 60 */ 61 61 def missingProperties = { attrs -> 62 def datamatrix = attrs['datamatrix'] 63 out << render (template:"common/missingproperties", model:[datamatrix:datamatrix]) 62 def datamatrix = attrs['datamatrix'] 63 def failedcells = attrs['failedcells'] 64 out << render (template:"common/missingproperties", model:[datamatrix:datamatrix, failedcells:failedcells]) 64 65 } 65 66 -
trunk/grails-app/views/importer/common/_missingproperties.gsp
r1140 r1202 1 <%1 <% 2 2 /** 3 3 * Missing properties template which shows missing properties … … 41 41 updatefield = '<input type = "hidden" name="updatefield" value="true" / >'; 42 42 $('#missingpropertiesform').append(updatefield); 43 44 43 $('#missingpropertiesform').submit(); 45 46 44 } 47 45 }); 48 46 49 47 48 }); 49 </script> 50 51 <script type="text/javascript"> 52 $(document).ready(function() { 53 // mark error fieldssss 54 <g:each in="${failedcells}" var="record"> 55 <g:each in="${record.importcells}" var="cell"> 56 var element = $("select[name=entity_${cell.entityidentifier}_${cell.mappingcolumn.property}]"); 57 58 element.addClass('error') 59 element.append( new Option("Invalid: ${cell.value}","", true, true) ); 60 61 console.log(element.val()) 62 //element. 63 64 //element.hide() 65 //element.attr('disabled', true) 66 67 </g:each> 68 </g:each> 50 69 }); 51 70 </script> … … 69 88 <div class="firstColumn">#</div> 70 89 <div class="firstColumn"></div> 71 <wizard:templateColumns id="${entity.hashCode()}" entity="${entity}" template="${entity.template}" name="entity_${entity. hashCode()}" class="column" subject="${entity.hashCode()}" addDummy="true" />90 <wizard:templateColumns id="${entity.hashCode()}" entity="${entity}" template="${entity.template}" name="entity_${entity.getIdentifier()}" class="column" subject="${entity.hashCode()}" addDummy="true" /> 72 91 </div> 73 92 </g:each> … … 80 99 </g:form> 81 100 </div> 82 -
trunk/grails-app/views/importer/step3_simple.gsp
r1103 r1202 25 25 <h1>Step 3: fill in missing mappings</h1> 26 26 You must map the missing properties 27 <importer:missingProperties datamatrix="${datamatrix}" />27 <importer:missingProperties datamatrix="${datamatrix}" failedcells="${failedcells}"/> 28 28 </body> 29 29 </html>
Note: See TracChangeset
for help on using the changeset viewer.