Changeset 735


Ignore:
Timestamp:
Jul 27, 2010, 4:26:35 PM (13 years ago)
Author:
tabma
Message:
  • improved partial missing code documentation
Location:
trunk/grails-app
Files:
2 edited

Legend:

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

    r732 r735  
    7979        def entityClass = Class.forName(entity, true, this.getClass().getClassLoader())
    8080
     81        // Initialize some session variables
    8182        session.importer_workbook = wb
    8283        session.importer_study = Study.get(params.study.id.toInteger())
     
    8687        session.importer_headerrow = params.headerrow.toInteger()
    8788
     89        // Get the header from the Excel file using the arguments given in the first step of the wizard
    8890        session.importer_header = ImporterService.getHeader(wb,
    8991                                                            session.importer_sheetindex,
     
    9294                                                            entityClass)
    9395       
    94         session.importer_header.each {     
     96        // Initialize 'selected entities', used to show entities above the columns
     97        session.importer_header.each {
    9598            selectedentities.add([name:params.entity, columnindex:it.key.toInteger()])
    9699        }
     
    125128
    126129    /**
     130     * Method to save the missing properties
    127131     * @param entity entity class we are using (dbnp.studycapturing.Subject etc.)
    128132     */
    129133
    130134    def saveMissingProperties = {
    131        
     135
    132136        session.importer_importeddata.each { table ->
    133137            table.each { entity ->
     
    185189            }
    186190           
     191            // Set the templatefield type for this column
    187192            session.importer_header[columnindex.toInteger()].templatefieldtype = tft
    188193        }
    189194
     195        // Detect the entity type
    190196        params.entity.index.each { columnindex, entityname ->
    191197            Class clazz = null
     
    206212            }
    207213
     214            // Store properties for this column
    208215            session.importer_header[columnindex.toInteger()].identifier = (columnindex.toInteger() == identifiercolumnindex) ? true : false
    209216            session.importer_header[columnindex.toInteger()].index = columnindex.toInteger()
     
    259266    }
    260267
     268    /**
     269     * Method which saves the data matrix to the database
     270     */
    261271    def savePostview = {
    262272        def validatedSuccesfully = ImporterService.saveDatamatrix(session.importer_study, session.importer_importeddata)
  • trunk/grails-app/services/dbnp/importer/ImporterService.groovy

    r732 r735  
    225225        def table = []
    226226       
    227         // walk through all rows       
     227        // walk through all rows and fill the table with records
    228228        (rowindex..sheet.getLastRowNum()).each { i ->
    229229            table.add(createRecord(template_id, sheet.getRow(i), mcmap))
    230230        }
    231 
    232         /*table.each {
    233             it.each { entity ->
    234                 entity.giveFields().each { field ->
    235                     print field.name + ":" + entity.getFieldValue(field.name) + "/"
    236                 }
    237                 println
    238             }
    239         }*/
    240 
    241231        return table   
    242232    }
     
    254244        study.refresh()
    255245       
     246        // go through the data matrix, read every record and validate the entity and try to persist it
    256247        datamatrix.each { record ->
    257248            record.each { entity ->
     
    312303                def template = Template.get(template_id)
    313304                def record = []
    314         def samplingevent = new SamplingEvent(template:template)
    315 
     305
     306                // Initialize all possible entities with the chosen template
    316307                def study = new Study(template: template)
    317308                def subject = new Subject(template: template)
     
    320311                def sample = new Sample(template: template)
    321312
     313                // Go through the Excel row cell by cell
    322314                for (HSSFCell cell: excelrow) {
     315                        // get the MappingColumn information of the current cell
    323316                        def mc = mcmap[cell.getColumnIndex()]
    324317                        def value
     
    332325                                }
    333326
     327                                // which entity does the current cell (field) belong to?
    334328                                switch (mc.entity) {
    335329                                        case Study: (record.any {it.getClass() == mc.entity}) ? 0 : record.add(study)
Note: See TracChangeset for help on using the changeset viewer.