Changeset 256


Ignore:
Timestamp:
Mar 11, 2010, 11:48:16 AM (7 years ago)
Author:
tabma
Message:
  • Template enums now used instead of POI Celltypes
Location:
trunk/grails-app
Files:
4 edited

Legend:

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

    r255 r256  
    6262
    6363    /**
    64     * User has assigned all entities and celltypes to the columns and continues to the next step (assigning properties to columns)
     64    * User has assigned all entities and templatefieldtypes to the columns and continues to the next step (assigning properties to columns)
    6565    * All information of the columns is stored in a session as MappingColumn object
    6666    *
    6767    * @param entity list of entities and columns it has been assigned to (columnindex:entitytype format)
    68     * @param celltype list of celltypes and columns it has been assigned to (columnindex:celltype format)
     68    * @param templatefieldtype list of celltypes and columns it has been assigned to (columnindex:templatefieldtype format)
    6969    * @return properties page
    7070    *
    7171    * @see celltype: http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Cell.html
    7272    */
    73     def savepreview = {
     73    def savepreview = {
     74        def tft = null
    7475        def entities  = request.getParameterValues("entity")
    75         def celltypes = request.getParameterValues("celltype")
     76        def templatefieldtypes = request.getParameterValues("templatefieldtype")
    7677
    77         celltypes.each { c ->
    78             def temp = c.split(":")
    79             def celltype = temp[1].toInteger()
    80             def templatefieldtype = TemplateFieldType.STRING
     78        templatefieldtypes.each { t ->
     79            def temp = t.split(":")
     80            def templatefieldtype = temp[1]         
    8181           
    82             session.header[temp[0].toInteger()].celltype = celltype
    83 
    84             switch (celltype) {
    85                 case 0 : templatefieldtype = TemplateFieldType.INTEGER
    86                          break
    87                 case 1 : templatefieldtype = TemplateFieldType.STRING
    88                          break
    89                 case 2 :  // formula cell type, cannot handle this
    90                          break
    91                 case 3 : templatefieldtype = TemplateFieldType.STRING
    92                          break
    93                 case 4 : templatefieldtype = TemplateFieldType.STRING
    94                          break
     82            switch (templatefieldtype) {
     83                case "STRING"       : tft = TemplateFieldType.STRING
     84                                      break
     85                case "TEXT"         : tft = TemplateFieldType.TEXT
     86                                      break
     87                case "INTEGER"      : tft = TemplateFieldType.INTEGER
     88                                      break
     89                case "FLOAT"        : tft = TemplateFieldType.FLOAT
     90                                      break
     91                case "DOUBLE"       : tft = TemplateFieldType.DOUBLE
     92                                      break
     93                case "STRINGLIST"   : tft = TemplateFieldType.STRINGLIST
     94                                      break
     95                case "ONTOLOGYTERM" : tft = TemplateFieldType.ONTOLOGYTERM
     96                                      break
     97                case "DATE"         : tft = TemplateFieldType.DATE
     98                                      break
    9599                default: break
    96100            }
     101            session.header[temp[0].toInteger()].templatefieldtype = tft
    97102        }
    98103
    99104        entities.each { e ->
    100105            def temp = e.split(":")
    101             Class clazz
     106            Class clazz     
    102107
    103108            switch (temp[1].toInteger()) {
     
    113118                        break
    114119                default: clazz = Object
     120                        break
    115121            }
    116122
     
    132138    */
    133139    def saveproperties = {
     140        def columnproperties  = request.getParameterValues("columnproperty")
    134141
    135         def columnproperties  = request.getParameterValues("columnproperty")
    136142        columnproperties.each { cp ->
    137143                def temp = cp.split(":")
  • trunk/grails-app/domain/dbnp/importer/MappingColumn.groovy

    r255 r256  
    1515        dbnp.studycapturing.TemplateFieldType templatefieldtype
    1616        Class entity
    17         String property
    18         Integer celltype
     17        String property
    1918        Integer index
    2019        String value
     
    2524
    2625    String toString() {
    27         return "Name:" + name + "/TemplateFieldType:" + templatefieldtype + "/Entity:" + entity + "/Property:" + property + "/Celltype:" + celltype + "/Index:" + index + "/Value:" + value
     26        return "Name:" + name + "/TemplateFieldType:" + templatefieldtype + "/Entity:" + entity + "/Property:" + property + "/Index:" + index + "/Value:" + value
    2827    }
    2928}
  • trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy

    r255 r256  
    2222    def standardentities = [[type:-1, name:"Don't import"], [type:0, name:"Study"], [type:1, name:"Subject"], [type:2, name:"Event"],
    2323                        [type:3, name:"Protocol"], [type:4, name:"Sample"]]
    24 
    25     /*def standardcelltypes = [
    26                          [type:0, name:"Numeric"], [type:1, name:"String"], [type:2, name:"Formula"],
    27                          [type:3, name:"Blank"], [type:4, name:"Boolean"], [type:5, name:"Error"], [type:6, name:"Date"],
    28                          [type:7, name:"Float"], [type:8, name:"Double"], [type:9, name:"List of items"], [type:10, name:"Ontologyterm"]
    29                      ]*/
    3024
    3125    /**
     
    6256    }
    6357
    64     def createSelect(int selected, String name, options, String customvalue) {
     58    def createSelect(selected, String name, options, String customvalue) {
    6559        def res = "<select style=\"font-size:10px\" name=\"${name}\">"
    6660
    6761        options.each { e ->
    68             res += "<option value=\"${customvalue}:${e.type}\""
    69             res += (e.type.toInteger() == selected) ? " selected" : ""
    70             res += ">${e.name}</option>"
     62            res += "<option value=\"${customvalue}:${e}\""
     63            res += (e == selected) ? " selected" : ""
     64            res += ">${e}</option>"
    7165        }
    7266
     
    118112    }   
    119113
    120     /**
    121      * @param selected selected entity
    122      * @param name name of the HTML select object
    123      **/
    124     def entitySelect = { attrs ->       
    125         def selected = (attrs['selected']==null) ? -1 : attrs['selected']
    126         def customvalue = (attrs['customvalue']==null) ? "" : attrs['customvalue']
    127         out << createSelect(selected, attrs['name'], standardentities, customvalue)
     114     def entitySelect = { attrs ->
     115        def sel = (attrs['selected']==null) ? -1 : attrs['selected']
     116        def custval = (attrs['customvalue']==null) ? "" : attrs['customvalue']
     117        def name = (attrs['name']==null) ? -1 : attrs['name']
     118
     119        def res = "<select style=\"font-size:10px\" name=\"${name}\">"
     120
     121        standardentities.each { e ->
     122            res += "<option value=\"${custval}:${e.type}\""
     123            res += (e.type == sel) ? " selected" : ""
     124            res += ">${e.name}</option>"
     125        }
     126
     127        res += "</select>"
     128        out << res
    128129    }
    129130
     
    134135    * @return HTML select object
    135136    */
    136     def celltypeSelect = { attrs ->
     137    def templatefieldtypeSelect = { attrs ->
    137138        def selected = (attrs['selected']==null) ? -1 : attrs['selected']
    138139        def customvalue = (attrs['customvalue']==null) ? "" : attrs['customvalue']
     140        def name = (attrs['name']==null) ? "" : attrs['name']
    139141        //out << createSelect(selected, attrs['name'], standardcelltypes, customvalue)
    140         out << createSelect(selected, attrs['name'], TemplateFieldType.list(), customvalue)
     142
     143        def res = "<select style=\"font-size:10px\" name=\"${name}\">"
     144
     145        TemplateFieldType.list().each { e ->
     146            res += "<option value=\"${customvalue}:${e}\""
     147            res += (e == selected) ? " selected" : ""
     148            res += ">${e}</option>"
     149        }
     150
     151        res += "</select>"
     152
     153        out << res
    141154    }
    142155}
  • trunk/grails-app/views/importer/common/_preview.gsp

    r255 r256  
    2828            <g:each var="column" in="${header}">
    2929                <td class="header">
    30                     <importer:celltypeSelect selected="${column.value.templatefieldtype}" name="celltype" customvalue="${column.key.toString()}"/>
     30                    <importer:templatefieldtypeSelect selected="${column.value.templatefieldtype}" name="templatefieldtype" customvalue="${column.key.toString()}"/>
    3131                </td>
    3232            </g:each>
Note: See TracChangeset for help on using the changeset viewer.