Ignore:
Timestamp:
Jul 1, 2010, 12:31:49 PM (6 years ago)
Author:
tabma
Message:
  • extra step for Simple Import Wizard implemented for easy adding and editing of cells (which were not imported yet)
File:
1 edited

Legend:

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

    r545 r632  
    4141    }
    4242
    43     def simplewizard = {
     43    def simpleWizard = {
    4444        render(view:"index_simple", model:[studies:Study.list(), entities: grailsApplication.config.gscf.domain.importableEntities])
    4545    }
    4646
    47     def advancedwizard = {
     47    def advancedWizard = {
    4848        render(view:"index_advanced", model:[templates:Template.list()])
    4949    }
     
    6262        session.importer_template_id = params.template_id
    6363        session.importer_workbook = wb
    64 
    65        
    6664
    6765        render (view:"step1_advanced", model:[header:session.importer_header, datamatrix:ImporterService.getDatamatrix(wb, 0, 5)])
     
    9088        }
    9189
    92         //import workbook
    93         //session.importer_importeddata = ImporterService.importdata(session.importer_template_id, session.importer_workbook, 0, 1, session.importer_header)
    94 
    95         //println "DAS" + session.importer_header
    96 
    97         //render(view:"step2_simple", model:[datamatrix:session.importer_importeddata])
    9890        def templates = Template.get(session.importer_template_id)
    9991       
    100         render(view:"step2_simple", model:[entities: selectedentities, header:session.importer_header, templates:templates])
     92        render(view:"step2_simple", model:[entities: selectedentities, header:session.importer_header, datamatrix:ImporterService.getDatamatrix(wb, 0, 5), templates:templates])
    10193    }
    10294
     
    118110
    119111    /**
     112     * @param entity entity class we are using (dbnp.studycapturing.Subject etc.)
     113     */
     114
     115    def saveMissingProperties = {
     116        println params.entity
     117       
     118        session.importer_importeddata.each { table ->
     119            table.each { entity ->
     120                entity.giveFields().each { field ->
     121                    print ":" + params["entity_" + entity.hashCode() + "_" + field.escapedName()]
     122                    entity.setFieldValue (field.toString(), params["entity_" + entity.hashCode() + "_" + field.escapedName()])
     123                }               
     124            }
     125        }
     126
     127        render(view:"step3", model:[datamatrix:session.importer_importeddata])
     128        //render("Succesful")
     129    }
     130
     131    /**
    120132    * User has assigned all entities and templatefieldtypes to the columns and continues to the next step (assigning properties to columns)
    121133    * All information of the columns is stored in a session as MappingColumn object
     
    127139    * @see celltype: http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Cell.html
    128140    */
    129     def savepreview = {
     141    def savePreview = {
    130142        def tft = null 
    131143        def identifiercolumnindex = (params.identifier!=null) ? params.identifier.toInteger() : -1
     
    198210    *
    199211    */
    200     def saveproperties = {     
     212    def saveProperties = {
    201213
    202214        params.columnproperty.index.each { columnindex, property ->
     
    204216
    205217                def entityClass = Class.forName(session.importer_header[columnindex.toInteger()].entity.getName(), true, this.getClass().getClassLoader())
    206                 def entityObj = entityClass.newInstance(template:template)             
    207 
     218                def entityObj = entityClass.newInstance(template:template)
    208219               
    209220                session.importer_header[columnindex.toInteger()].property = property
     
    218229        session.importer_importeddata = ImporterService.importdata(session.importer_template_id, session.importer_workbook, 0, 1, session.importer_header)
    219230
    220         render(view:"step3", model:[datamatrix:session.importer_importeddata])
    221     }
    222 
    223     def savepostview = {
     231        if (params.layout=="horizontal")
     232            render(view:"step3_simple", model:[datamatrix:session.importer_importeddata])
     233        else if (params.layout=="vertical")
     234            render(view:"step3", model:[datamatrix:session.importer_importeddata])
     235    }
     236
     237    def savePostview = {
    224238        ImporterService.saveDatamatrix(session.importer_study, session.importer_importeddata)
    225239        render(view:"step4")
     
    234248    def ajaxGetTemplatesByEntity = {
    235249        def entityClass = grailsApplication.config.gscf.domain.importableEntities.get(params.entity).entity
     250       
    236251
    237252        // fetch all templates for a specific entity
    238         def templates = Template.findAllByEntity(Class.forName(entityClass, true, this.getClass().getClassLoader()))
     253        //def templates = Template.findAllByEntity(Class.forName(entityClass, true, this.getClass().getClassLoader()))
     254        def templates = Template.list()
     255
     256        println templates.dump()
    239257
    240258        // render as JSON
Note: See TracChangeset for help on using the changeset viewer.