Ignore:
Timestamp:
Feb 10, 2011, 4:30:16 PM (10 years ago)
Author:
t.w.abma@…
Message:
  • removed popup solution for properties and changed it into simple "save" method to step 2 of importer wizard
File:
1 edited

Legend:

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

    r1511 r1514  
    152152                        }
    153153            on("refresh") {
    154                 if (params.savepropertymapping) println "saved properties"
     154                // a name was given to the current property mapping, try to store it
     155                if (params.mappingname) {
     156                    flash['mappingname'] = params.mappingname
     157                    propertiesSaveImportMappingPage(flow, flash, params)
     158                }
    155159                flow.importer_fuzzymatching="true"
    156160                                success()
     
    365369        return false
    366370        }
     371
     372    /**
     373     * Save the properties as an import mapping.
     374     *
     375     * @param Map LocalAttributeMap (the flow scope)
     376         * @param Map GrailsParameterMap (the flow parameters = form data)
     377         * @returns boolean true if correctly validated, otherwise false
     378         */
     379    boolean propertiesSaveImportMappingPage(flow, flash, params) {
     380        flash.wizardErrors = [:]
     381
     382                // Find actual Template object from the chosen template name
     383                def template = Template.get(flow.importer_template_id)
     384        //def im = new ImportMapping(name:params.mappingname).save()
     385
     386                params.columnproperty.index.each { columnindex, property ->
     387                        // Create an actual class instance of the selected entity with the selected template
     388                        // This should be inside the closure because in some cases in the advanced importer, the fields can have different target entities
     389                        def entityClass = Class.forName(flow.importer_header[columnindex.toInteger()].entity.getName(), true, this.getClass().getClassLoader())
     390                        def entityObj = entityClass.newInstance(template: template)
     391            def dontimport = (property == "dontimport") ? true : false
     392
     393            def mc = new MappingColumn (property:property, templatefieldtype:entityObj.giveFieldType(property), dontimport: dontimport )
     394
     395                        // Store the selected property for this column into the column map for the ImporterService
     396                        /*flow.importer_header[columnindex.toInteger()].property = property
     397
     398                        // Look up the template field type of the target TemplateField and store it also in the map
     399                        flow.importer_header[columnindex.toInteger()].templatefieldtype = entityObj.giveFieldType(property)
     400
     401                        // Is a "Don't import" property assigned to the column?
     402                        flow.importer_header[columnindex.toInteger()].dontimport = (property == "dontimport") ? true : false
     403
     404                        //if it's an identifier set the mapping column true or false
     405                        entityObj.giveFields().each {
     406                                (it.preferredIdentifier && (it.name == property)) ? flow.importer_header[columnindex.toInteger()].identifier = true : false
     407                        }*/
     408                }
     409    }
    367410
    368411        /**
Note: See TracChangeset for help on using the changeset viewer.