Changeset 660

Show
Ignore:
Timestamp:
19-07-10 12:37:23 (4 years ago)
Author:
keesvb
Message:

updated importer logic to fetch template field type from importer mapping instead of excel type guessing

Files:
1 modified

Legend:

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

    r655 r660  
    211211    def saveProperties = { 
    212212 
     213        // Find actual Template object from the chosen template name 
     214        def template = Template.get(session.imported_template_id) 
     215 
    213216        params.columnproperty.index.each { columnindex, property -> 
    214                 def template = Template.get(session.imported_template_id) 
    215  
     217 
     218                // Create an actual class instance of the selected entity with the selected template 
     219                // This should be inside the closure because in some cases in the advanced importer, the fields can have different target entities 
    216220                def entityClass = Class.forName(session.importer_header[columnindex.toInteger()].entity.getName(), true, this.getClass().getClassLoader()) 
    217221                def entityObj = entityClass.newInstance(template:template) 
    218                  
     222 
     223                // Store the selected property for this column into the column map for the ImporterService 
    219224                session.importer_header[columnindex.toInteger()].property = property 
    220                  
    221                 //if it's an identifier set the mapping column true or false             
     225                // Look up the template field type of the target TemplateField and store it also in the map 
     226                session.importer_header[columnindex.toInteger()].templatefieldtype = entityObj.giveFields()[property].type 
     227 
     228                //if it's an identifier set the mapping column true or false 
    222229                entityObj.giveFields().each { 
    223230                    (it.preferredIdentifier && (it.name==property)) ? session.importer_header[columnindex.toInteger()].identifier = true : false