Changeset 1050


Ignore:
Timestamp:
Nov 2, 2010, 4:48:11 PM (13 years ago)
Author:
t.w.abma@…
Message:
  • initial "failed cells" logic figured out, now extracts cells from the datamatrix which were not able to be stored in an entity
Location:
trunk/grails-app
Files:
2 edited

Legend:

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

    r1047 r1050  
    4444        //session.import_referer = request.forwardURI
    4545        // should do a check what is in the url, strip it?
    46         session.import_referer = params.redirectTo
     46        session.import_referer = params.redirectTo       
    4747    }
    4848
     
    269269
    270270        // First handle the "failed cells"
    271         //ImporterService.getFailedCells(session.importer_importeddata)
    272        
    273         //render(view:"step2a_simple", model:[datamatrix:session.importer_importeddata])
     271        //render(view:"step2a_simple", model:[datamatrix:ImporterService.getFailedCells(session.importer_importeddata)])
    274272
    275273        if (params.layout=="horizontal")
  • trunk/grails-app/services/dbnp/importer/ImporterService.groovy

    r1045 r1050  
    230230        }
    231231        return table   
     232    }
     233
     234    /** Method to extract failed cells from the datamatrix. Failed cells are cell values
     235     * which could not be stored in an entity (e.g. Humu Supiuns in an ontology field).
     236     *
     237     * @param datamatrix two dimensional array containing entities and possibly also failed cells
     238     * @return array of failed cells
     239     * */
     240    def getFailedCells(datamatrix) {
     241       def failedcells = []
     242       
     243       datamatrix.each { record ->
     244            record.each { column ->
     245                column.each {
     246                    if (it.getClass().getName().equals('java.util.LinkedHashMap$Entry')) {
     247                        println it.key
     248                        println it.value
     249                        failedcells.add(it)
     250                    }
     251                }
     252            }
     253        }
     254
     255        return failedcells
    232256    }
    233257   
     
    424448                                    // leave the field empty and let the user choose the ontology manually in a later step
    425449                                    failed.put(mc, value)
     450                                    println "failed ("+mc.templatefieldtype+"`" + value + "`"
    426451                                }
    427452                        } // end
     
    431456        // a failed column means that using the entity.setFieldValue() threw an exception
    432457        //record.add(failed)
    433        
    434458        return record
    435459    }
Note: See TracChangeset for help on using the changeset viewer.