Ignore:
Timestamp:
May 12, 2010, 1:23:35 PM (12 years ago)
Author:
tabma
Message:
  • refactored code and templates of the Importer Wizard, now makes use of indexed formparameters
File:
1 edited

Legend:

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

    r359 r415  
    7373    */
    7474    def savepreview = {
    75         def tft = null
    76         def entities  = request.getParameterValues("entity")
    77         def templatefieldtypes = request.getParameterValues("templatefieldtype")
     75        def tft = null 
    7876        def identifiercolumnindex = (params.identifier!=null) ? params.identifier.toInteger() : -1
    7977
    80         templatefieldtypes.each { t ->     
    81             def columnindex = t.split(":")[0].toInteger()
    82             def templatefieldtype = t.split(":")[1]
    83            
    84             switch (templatefieldtype) {
     78        params.templatefieldtype.index.each { columnindex, _templatefieldtype ->
     79            switch (_templatefieldtype) {
    8580                case "STRING"       : tft = TemplateFieldType.STRING
    8681                                      break
     
    10196                default: break
    10297            }
    103             session.importer_header[columnindex].templatefieldtype = tft
     98           
     99            session.importer_header[columnindex.toInteger()].templatefieldtype = tft
    104100        }
    105101
    106         entities.each { e ->               
    107             def columnindex = e.split(":")[0].toInteger()
    108             def entitytype = e.split(":")[1].toInteger()
    109             Class clazz     
     102        params.entity.index.each { columnindex, entitytype ->
     103            Class clazz
    110104
    111             switch (entitytype) {
     105            switch (entitytype.toInteger()) {
    112106                case 0: clazz = Study
    113107                        break
     
    124118            }
    125119
    126             session.importer_header[columnindex].identifier = (columnindex == identifiercolumnindex) ? true : false
    127             session.importer_header[columnindex].index = columnindex
    128             session.importer_header[columnindex].entity = clazz
     120            session.importer_header[columnindex.toInteger()].identifier = (columnindex.toInteger() == identifiercolumnindex) ? true : false
     121            session.importer_header[columnindex.toInteger()].index = columnindex.toInteger()
     122            session.importer_header[columnindex.toInteger()].entity = clazz
    129123        }
    130124
     
    134128        def templates = Template.get(session.importer_template_id)
    135129
    136         render(view:"step2", model:[entities:entities, header:session.importer_header, templates:templates])
     130        render(view:"step2", model:[entities:params.entity, header:session.importer_header, templates:templates])
    137131    }
    138132
    139133    /**
    140     * @param columnproperty array of columns and the assigned property in `column:property_id` format
     134    * @param columnproperty array of columns containing index and property_id
    141135    *
    142136    */
    143     def saveproperties = {
    144         def columnproperties  = request.getParameterValues("columnproperty")   
     137    def saveproperties = {     
    145138        session.importer_study = Study.get(params.study.id.toInteger())
    146139
    147         columnproperties.each { cp ->           
    148                 def columnindex = cp.split(":")[0].toInteger()
    149                 def property_id = cp.split(":")[1].toInteger()
    150                 session.importer_header[columnindex].property = TemplateField.get(property_id)
     140        params.columnproperty.index.each { columnindex, property_id ->
     141                session.importer_header[columnindex.toInteger()].property = TemplateField.get(property_id.toInteger())
    151142        }
    152143
     
    158149
    159150    def savepostview = {
    160         ImporterService.savedata(session.importer_study, session.importer_importeddata)
     151        ImporterService.saveDatamatrix(session.importer_study, session.importer_importeddata)
    161152        render(view:"step4")
    162153    }
Note: See TracChangeset for help on using the changeset viewer.