Ignore:
Timestamp:
Nov 25, 2010, 3:51:14 PM (12 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)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.