Changeset 545 for trunk


Ignore:
Timestamp:
Jun 9, 2010, 12:54:12 PM (13 years ago)
Author:
tabma
Message:
  • fixed Advanced Import Wizard (preferredIdentifier issues)
Location:
trunk/grails-app
Files:
4 edited

Legend:

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

    r534 r545  
    5858        def wb = handleUpload('importfile')
    5959
    60        
    6160        session.importer_header = ImporterService.getHeader(wb, 0)
    6261        session.importer_study = Study.get(params.study.id.toInteger())
    6362        session.importer_template_id = params.template_id
    6463        session.importer_workbook = wb
     64
     65       
    6566
    6667        render (view:"step1_advanced", model:[header:session.importer_header, datamatrix:ImporterService.getDatamatrix(wb, 0, 5)])
     
    163164
    164165        params.entity.index.each { columnindex, entityname ->
    165             Class clazz
     166            Class clazz = null
    166167
    167168            switch (entityname) {
    168                 case "Study"    : clazz = Study
    169                         break
    170                 case "Subject"  : clazz = Subject
    171                         break
    172                 case "Event"    : clazz = Event
    173                         break
    174                 case "Protocol" : clazz = Protocol
    175                         break
    176                 case "Sample"   : clazz = Sample
     169                case "Study"    : clazz = dbnp.studycapturing.Study
     170                        break
     171                case "Subject"  : clazz = dbnp.studycapturing.Subject
     172                        break
     173                case "Event"    : clazz = dbnp.studycapturing.Event
     174                        break
     175                case "Protocol" : clazz = dbnp.studycapturing.Protocol
     176                        break
     177                case "Sample"   : clazz = dbnp.studycapturing.Sample
    177178                        break
    178179                default: clazz = Object
  • trunk/grails-app/domain/dbnp/importer/MappingColumn.groovy

    r534 r545  
    2626
    2727    String toString() {
    28         return "Name:" + name + "/TemplateFieldType:" + templatefieldtype + "/Entity:" + entity + "/Property:" + property + "/Index:" + index + "/Value:" + value + "/Identifier:" + identifier
     28        return "Name:" + name + "/TemplateFieldType:" + fieldtype + "/Entity:" + entity + "/Property:" + property + "/Index:" + index + "/Value:" + value + "/Identifier:" + identifier
    2929    }
    3030}
  • trunk/grails-app/services/dbnp/importer/ImporterService.groovy

    r534 r545  
    4949     * @return header representation as a MappingColumn hashmap
    5050     */
    51     def getHeader(HSSFWorkbook wb, int sheetindex, theEntity=0){
     51    def getHeader(HSSFWorkbook wb, int sheetindex, theEntity=null){
    5252
    5353        def sheet = wb.getSheetAt(sheetindex)
     
    6262            def datamatrix_celltype = sheet.getRow(datamatrix_start).getCell(index).getCellType()
    6363            def headercell = sheet.getRow(sheet.getFirstRowNum()).getCell(index)
    64 
     64            def tft = TemplateFieldType.STRING //default templatefield type
     65
     66           
    6567            // Check for every celltype, currently redundant code, but possibly this will be
    6668            // a piece of custom code for every cell type like specific formatting
     
    7072                            //parse cell value as double
    7173                            def parsable = true
    72                             def templatefieldtype = TemplateFieldType.STRING
     74                            def fieldtype = TemplateFieldType.STRING
    7375
    7476                            // is this string perhaps a double?
     
    7779                            } catch (NumberFormatException nfe) { parsable = false }
    7880                            finally {
    79                                 if (parsable) templatefieldtype = TemplateFieldType.DOUBLE
     81                                if (parsable) fieldtype = TemplateFieldType.DOUBLE
    8082                            }
    8183
    8284                            header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell),
    83                                                                             templatefieldtype:templatefieldtype,
     85                                                                            templatefieldtype:fieldtype,
    8486                                                                            index:index,
    8587                                                                            entity:theEntity,
    8688                                                                            property:property);
     89
    8790                            break
    8891                    case HSSFCell.CELL_TYPE_NUMERIC:                   
     
    115118                                                                            property:property);
    116119                            break
    117             }
    118         }
     120            } // end of switch
     121        } // end of cell loop
    119122        return header
    120123    }
     
    305308                                    study.setFieldValue(mc.property, value)
    306309                                    break
    307                 case Subject    :   (record.any {it.getClass()==mc.entity}) ? 0 : record.add(subject)                               
     310                case Subject    :   (record.any {it.getClass()==mc.entity}) ? 0 : record.add(subject)
     311                                    println "TOT HIER" + mc.property + "/ " + value
    308312                                    subject.setFieldValue(mc.property, value)                               
    309313                                    break
  • trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy

    r534 r545  
    8383        def mc = attrs['mappingcolumn']
    8484        def allfieldtypes = attrs['allfieldtypes']
     85        def domainfields = mc.entity.giveDomainFields().findAll { it.type == mc.templatefieldtype }
     86            domainfields = domainfields.findAll { it.preferredIdentifier != mc.identifier}
    8587
    8688        //def templatefields = (allfieldtypes=="true") ? t.fields : t.fields.findAll { it.type == mc.templatefieldtype }
    8789        def templatefields = (allfieldtypes=="true") ?
    8890            t.fields + mc.entity.giveDomainFields() :
    89             t.fields.findAll { it.type == mc.templatefieldtype } + mc.entity.giveDomainFields()
     91            t.fields.findAll { it.type == mc.templatefieldtype } + domainfields
    9092
    91         (mc.identifier) ? out << "<select style=\"font-size:10px\" name=\"\" disabled><option>Identifier</option></select>":
     93        // map identifier to preferred column
     94        def prefcolumn = mc.entity.giveDomainFields().findAll { it.preferredIdentifier == true }
     95
     96        (mc.identifier) ? out << createPropertySelect(attrs['name'], prefcolumn, mc.index) :
    9297            out << createPropertySelect(attrs['name'], templatefields, mc.index)
    9398    }
Note: See TracChangeset for help on using the changeset viewer.