Ignore:
Timestamp:
Nov 1, 2010, 9:42:38 PM (12 years ago)
Author:
t.w.abma@…
Message:
  • added record which contains failed columns, should be passed to an overview in step 2a
File:
1 edited

Legend:

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

    r1028 r1044  
    222222    * @see dbnp.importer.MappingColumn
    223223    */
    224     def importdata(template_id, HSSFWorkbook wb, int sheetindex, int rowindex, mcmap) {
     224    def importData(template_id, HSSFWorkbook wb, int sheetindex, int rowindex, mcmap) {
    225225        def sheet = wb.getSheetAt(sheetindex)
    226226        def table = []
     
    376376                def template = Template.get(template_id)
    377377                def record = []
     378                def failed = [:]
    378379
    379380                // Initialize all possible entities with the chosen template
     
    388389                        // get the MappingColumn information of the current cell
    389390                        def mc = mcmap[cell.getColumnIndex()]
    390                         def value
     391                        def value                       
    391392
    392393                        // Check if column must be imported
     
    402403                                // which entity does the current cell (field) belong to?
    403404                                    switch (mc.entity) {
    404                                         case Study: (record.any {it.getClass() == mc.entity}) ? 0 : record.add(study)
     405                                        case Study: // does the entity already exist in the record? If not make it so.
     406                                                (record.any {it.getClass() == mc.entity}) ? 0 : record.add(study)
    405407                                                study.setFieldValue(mc.property, value)
    406408                                                break
     
    422424                                } catch (IllegalArgumentException iae) {
    423425                                    // leave the field empty and let the user choose the ontology manually in a later step
    424                                    
     426                                    failed.put(mc, value)
    425427                                }
    426428                        } // end
    427429                } // end for
    428430
    429         return record
     431        // add the failed columns to the record (might also be just an empty map if nothing failed)
     432        // a failed column means that using the entity.setFieldValue() threw an exception
     433        record.add(failed)
     434       
     435        return record
    430436    }
    431437
Note: See TracChangeset for help on using the changeset viewer.