Changeset 632

Show
Ignore:
Timestamp:
01-07-10 12:31:49 (4 years ago)
Author:
tabma
Message:

- extra step for Simple Import Wizard implemented for easy adding and editing of cells (which were not imported yet)

Location:
trunk
Files:
5 added
9 modified
1 moved

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 
  • trunk/grails-app/services/dbnp/importer/ImporterService.groovy

    r589 r632  
    6363            def headercell = sheet.getRow(sheet.getFirstRowNum()).getCell(index) 
    6464            def tft = TemplateFieldType.STRING //default templatefield type 
    65  
    6665             
    6766            // Check for every celltype, currently redundant code, but possibly this will be  
     
    295294        def record = []  
    296295         
    297         def study = new Study(title:"New study", template:template) 
    298         def subject = new Subject(name:"New subject", species:Term.findByName("Homo sapiens"), template:template) 
    299         def event = new Event(eventdescription:"New event", template:template) 
    300         def sample = new Sample(name:"New sample", template:template) 
     296        def study = new Study(template:template) 
     297        def subject = new Subject(template:template) 
     298        def event = new Event(template:template) 
     299        def sample = new Sample(template:template) 
    301300 
    302301        for (HSSFCell cell: excelrow) {      
  • trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy

    r545 r632  
    5050    } 
    5151 
     52    def datapreview = { attrs -> 
     53        def datamatrix = attrs['datamatrix'] 
     54        out << render (template:"common/datapreview", model:[datamatrix:datamatrix]) 
     55    } 
     56 
     57    /** 
     58     * Show missing properties 
     59     */ 
     60    def missingProperties = { attrs -> 
     61        def datamatrix = attrs['datamatrix']     
     62        out << render (template:"common/missingproperties", model:[datamatrix:datamatrix]) 
     63    } 
     64 
    5265    /** 
    5366     * @param entities array containing selected entities 
     67     * @param header array containing mappingcolumn objects 
     68     * @param allfieldtypes if set, show all fields 
     69     * @param layout constant value: "horizontal" or "vertical" 
    5470     */ 
    5571    def properties = { attrs -> 
     
    5773        def entities = attrs['entities'] 
    5874        def allfieldtypes = (attrs['allfieldtypes']==null) ? "false" : "true" 
     75        def layout = (attrs['layout']==null) ? "vertical" : attrs['layout'] 
     76 
     77        //choose template for vertical layout (default) or horizontal layout 
     78        def template = (layout == "vertical") ? "common/properties_vertical" : "common/properties_horizontal" 
    5979         
    60  
    61         out << render ( template:"common/properties", 
     80        out << render ( template:template, 
    6281                        model:[selectedentities:entities, 
    6382                        standardentities:grailsApplication.config.gscf.domain.importableEntities, 
    6483                        header:header, 
    65                         allfieldtypes:allfieldtypes] 
     84                        allfieldtypes:allfieldtypes, 
     85                        layout:layout] 
    6686                        ) 
    6787    } 
  • trunk/grails-app/views/importer/common/_preview.gsp

    r359 r632  
    6262            </tr> 
    6363        </g:each> 
     64         
    6465        <tr> 
    6566            <td align="right" colspan="${datamatrix.length}"><input type="submit" value="Next"></td> 
  • trunk/grails-app/views/importer/common/_properties_vertical.gsp

    r492 r632  
    1313         */ 
    1414%> 
    15 <g:form name="propertiesform" action="saveproperties"> 
     15<g:form name="propertiesform" action="saveProperties"> 
    1616    <table> 
    1717          <g:each var="stdentity" in ="${standardentities}">           
     
    4545        <tr> 
    4646            <td> 
     47                <input type="hidden" name="layout" value="${params.layout}"> 
    4748                <input type="submit" name="savebutton" value="Next"/> 
    4849            </td> 
  • trunk/grails-app/views/importer/index.gsp

    r417 r632  
    1717    <ol> 
    1818        <li> 
    19             <g:link controller="importer" action="simplewizard">Simple wizard</g:link> 
     19            <g:link controller="importer" action="simpleWizard">Simple wizard</g:link> 
    2020        </li> 
    2121        <li> 
    22             <g:link controller="importer" action="advancedwizard">Advanced wizard</g:link> 
     22            <g:link controller="importer" action="advancedWizard">Advanced wizard</g:link> 
    2323        </li> 
    2424    </ol> 
  • trunk/grails-app/views/importer/index_simple.gsp

    r534 r632  
    55 
    66<%@ page contentType="text/html;charset=UTF-8" %> 
    7 <g:setProvider library="jquery"/> 
    87 
    98<html> 
     
    1110    <meta name="layout" content="main"/> 
    1211    <title>Importer wizard (simple)</title> 
     12 
     13<g:javascript library="jquery"/> 
    1314 
    1415<g:javascript> 
  • trunk/grails-app/views/importer/step2.gsp

    r496 r632  
    2828    selections.</p> 
    2929     
    30   <importer:properties entities="${entities}" header="${header}" templates="${templates}"/> 
     30  <importer:properties entities="${entities}" header="${header}" templates="${templates}" layout="vertical"/> 
    3131  </body> 
    3232</html> 
  • trunk/grails-app/views/importer/step2_simple.gsp

    r489 r632  
    2727    <p>The next step is to assign properties to the columns. Below you see the columns, please assign every column to 
    2828    a property.</p> 
    29   <importer:properties entities="${entities}" header="${header}" templates="${templates}" allfieldtypes="true"/> 
     29  <importer:properties entities="${entities}" header="${header}" datamatrix="${datamatrix}" templates="${templates}" allfieldtypes="true" layout="horizontal"/> 
    3030  </body> 
    3131</html> 
  • trunk/web-app/css/importer.css

    r328 r632  
    2525} 
    2626 
     27.importer .table { 
     28    color:green; 
     29} 
     30 
     31.importer .tr { 
     32    color:red; 
     33} 
     34 
     35.importer .td { 
     36    color:blue; 
     37}