Ignore:
Timestamp:
Nov 4, 2010, 4:49:53 PM (10 years ago)
Author:
t.w.abma@…
Message:
  • added logic for cleaning up 'failed cells' in the imported datamatrix
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/services/dbnp/importer/ImporterService.groovy

    r1058 r1083  
    237237     *
    238238     * @param datamatrix two dimensional array containing entities and possibly also failed cells
    239      * @return array of failed cells in [rownum:n, value:xxx] format
     239     * @return array of failed cells in [mappingcolumn, hssfcell] format
    240240     * */
    241241    def getFailedCells(datamatrix) {
     
    244244       datamatrix.each { record ->
    245245            record.each { column ->
    246                 column.each {
     246                column.each {                   
    247247                    if (it.getClass().getName().equals('java.util.LinkedHashMap$Entry')) {                       
    248248                        failedcells.add(it)
     
    253253
    254254        return failedcells
     255    }
     256
     257    /** Method to put failed cells back into the datamatrix. Failed cells are cell values
     258     * which could not be stored in an entity (e.g. Humu Supiuns in an ontology field).
     259     *
     260     * @param datamatrix two dimensional array containing entities and possibly also failed cells
     261     * @param failedcells map of failed cells in [mappingcolumn, hssfcell] format
     262     * @param correctedcells map of corrected cells
     263     **/
     264    def saveCorrectedCells(datamatrix, failedcells, correctedcells) {
     265        /*failedcells.each {
     266            println it
     267        }*/
     268        def newdatamatrix = []
     269
     270        // Remove failed cells 'entity' / clean up datamatrix
     271        datamatrix.each { record ->
     272            def newrecord = []
     273
     274            record.each { entity ->
     275              // LinkedHashMap means a "mappingcolumn:hssfcell" object is inside the record (= failed to map to entity)
     276              if (!entity.getClass().getName().equals('java.util.LinkedHashMap'))
     277              newrecord.add(entity)
     278            }
     279
     280            newdatamatrix.add(newrecord)
     281        }
     282
     283        newdatamatrix.each { record ->
     284            record.each { entity ->
     285                entity.giveFields().each { field ->
     286                    println "das"+ field
     287                }
     288            }
     289        }
     290
     291        println "-----"
     292        correctedcells.each {
     293            println it.dump()
     294        }
    255295    }
    256296   
     
    446486                                    } // end switch
    447487                                } catch (IllegalArgumentException iae) {
    448                                     // leave the field empty and let the user choose the ontology manually in a later step
    449                                     failed.put(mc, [rownum:excelrow.getRowNum(), value:value])
     488                                    // store the mapping column and the cell in an array
     489                                    failed.put(mc, cell)
    450490                                    //println "failed ("+mc.templatefieldtype+"`" + value + "`"
    451491                                }
Note: See TracChangeset for help on using the changeset viewer.