Changeset 1202


Ignore:
Timestamp:
Nov 25, 2010, 3:51:14 PM (13 years ago)
Author:
t.w.abma@…
Message:
  • removed extra step and implemented a failed cells check in step 3 (missing mappings) which shows the failed ontologies in the table editor (might have to tune appearance)
Location:
trunk/grails-app
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy

    r1194 r1202  
    170170            table.each { entity ->
    171171                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()])
    173173                }               
    174174            }
     
    176176
    177177        // 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])
    179179            else render(view:"step3", model:[datamatrix:session.importer_importeddata])
    180180    }
     
    323323        session.importer_failedcells = failedcells
    324324
    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)
    326327            render(view:"step2a_simple", model:[failedcells:session.importer_failedcells])
    327         else {
     328        else {*/
    328329            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])
    330331            else if (params.layout=="vertical")
    331332                render(view:"step3", model:[datamatrix:session.importer_importeddata])
    332         }
     333        //}
    333334    }
    334335
  • trunk/grails-app/domain/dbnp/importer/ImportCell.groovy

    r1121 r1202  
    2020class ImportCell extends Identity {
    2121    MappingColumn mappingcolumn
     22    int entityidentifier
    2223    String value
    2324
  • trunk/grails-app/services/dbnp/importer/ImporterService.groovy

    r1190 r1202  
    217217        def sheet = wb.getSheetAt(sheetindex)
    218218        def table = []
    219         def failedcells = [:] // map [recordhash, importrecord] values
     219        def failedcells = [] // list of records
    220220       
    221221        // walk through all rows and fill the table with records
     
    227227            table.add(record)
    228228
    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)
    233231        }
    234232
     
    423421                def tft = TemplateFieldType
    424422                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 entity
     423                def failed = new ImportRecord() // map with entity identifier and failed mappingcolumn
    426424
    427425                // Initialize all possible entities with the chosen template
     
    446444                                }
    447445
    448                                 //println "temateplfedielfdtype=" + mc.templatefieldtype
    449                                 // Are we trying to map an ontology term which is empty? Then it is a failed cell
    450                                 /*if (value=="") {
    451                                     println "empty term"
    452                                     def temp = new MappingColumn()
    453                                     //temp.properties = mc.properties
    454                                     temp.value = "undefined"
    455                                     failed.add(temp)
    456                                 }*/                               
    457                              
    458 
    459446                                try {
    460447                                // which entity does the current cell (field) belong to?
     
    481468                                } catch (IllegalArgumentException iae) {
    482469                                    // 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                                   
    483487                                    def mcInstance = new MappingColumn()
    484488                                    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))
    489490                                }
    490491                        } // end
    491492                } // end for
    492493        // a failed column means that using the entity.setFieldValue() threw an exception       
    493         return [record, failed]       
     494        return [record, failed]
    494495    }
    495496
  • trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy

    r1143 r1202  
    6060     */
    6161    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])
    6465    }
    6566
  • trunk/grails-app/views/importer/common/_missingproperties.gsp

    r1140 r1202  
    1 <%
     1  <%
    22        /**
    33         * Missing properties template which shows missing properties
     
    4141             updatefield = '<input type = "hidden" name="updatefield" value="true" / >';
    4242             $('#missingpropertiesform').append(updatefield);
    43 
    4443             $('#missingpropertiesform').submit();
    45 
    4644        }
    4745    });
    4846
    4947
     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>
    5069  });
    5170</script>
     
    6988                        <div class="firstColumn">#</div>
    7089                        <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" />
    7291                    </div>
    7392                </g:each>
     
    8099</g:form>   
    81100</div>
    82 
  • trunk/grails-app/views/importer/step3_simple.gsp

    r1103 r1202  
    2525    <h1>Step 3: fill in missing mappings</h1>
    2626    You must map the missing properties
    27     <importer:missingProperties datamatrix="${datamatrix}"/>
     27    <importer:missingProperties datamatrix="${datamatrix}" failedcells="${failedcells}"/>
    2828  </body>
    2929</html>
Note: See TracChangeset for help on using the changeset viewer.