Changeset 173


Ignore:
Timestamp:
Feb 8, 2010, 8:23:33 AM (13 years ago)
Author:
tabma
Message:
  • created taglibrary for importer and first implementation detection of (cell) datatypes
Location:
trunk
Files:
1 added
4 edited

Legend:

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

    r169 r173  
    2626    def ImporterService
    2727
     28    /**
     29     * Default page
     30     **/
    2831    def index = { }
    2932
     
    3134    * This method will move the uploaded file to a temporary path and send the header
    3235    * and the first n rows to the preview
     36    * @param importfile uploaded file to import
    3337    */
    3438    def upload = {
     
    4650
    4751    }
     52
     53    def accept = {
     54       
     55    }
    4856}
  • trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy

    r169 r173  
    1818class ImporterTagLib {
    1919    static namespace = 'importer'
     20    def entities = [[value:0, name:"Study"], [value:1, name:"Subject"], [value:2, name:"Event"],
     21                        [value:3, name:"Protocol"], [value:4, name:"Sample"]]
     22
     23    def celltypes = [[value:0, name:"Numeric"], [value:1, name:"String"], [value:2, name:"Formula"],
     24                         [value:3, name:"Blank"], [value:4, name:"Boolean"], [value:5, name:"Error"]]
    2025
    2126    /**
     
    3237    }
    3338
     39    def createSelect(int selected, String name, ArrayList options) {
     40        def res = "<select style=\"font-size:10px\" name=\"${name}\">"
     41
     42        options.each { e ->
     43            res += "<option value=\"${e.value}\""
     44            res += (e.value == selected) ? " selected" : ""
     45            res += ">${e.name}</option>"
     46        }
     47
     48        res += "</select>"
     49        return res
     50    }
     51
     52    /**
     53     * @param selected selected entity
     54     * @param name name of the HTML select object
     55     **/
     56    def entitySelect = { attrs ->       
     57        def selected = (attrs['selected']==null) ? -1 : attrs['selected']
     58        out << createSelect(selected, attrs['name'], entities)
     59    }
     60
    3461    /**
    3562    * @param selected selected celltype
    3663    * @param name name of the HTML select object
    37     * @param celltypes built-in cell types, based on the cell type
    38     * @see org.apache.poi.ss.usermodel.Cell
     64    * @see org.apache.poi.ss.usermodel.Cell for the possible cell types
    3965    * @return HTML select object
    4066    */
    41     def celltypeselector = { attrs ->
    42         def selected = attrs['selected']
    43         def name = attrs['name']
    44         def celltypes = [[celltype:0, name:"Numeric"], [celltype:1, name:"String"], [celltype:2, name:"Formula"],
    45                          [celltype:3, name:"Blank"], [celltype:4, name:"Boolean"], [celltype:5, name:"Error"]]
    46 
    47         def res = "<select name=\"${name}\">"
    48 
    49         celltypes.each { c ->
    50             res += "<option value=\"${c.celltype}\""
    51             res += (c.celltype == selected) ? " selected" : ""
    52             res += ">${c.name}</option>"
    53         }
    54 
    55         res += "</select>"
    56 
    57         out << res
     67    def celltypeSelect = { attrs ->
     68        def selected = (attrs['selected']==null) ? -1 : attrs['selected']
     69        out << createSelect(selected, attrs['name'], celltypes)
    5870    }
    59 
    6071}
  • trunk/grails-app/views/importer/common/_preview.gsp

    r169 r173  
    1515<g:form name="previewform" action="accept">
    1616    <table>
    17       <tr>
    18         <g:each var="column" in="${header}">       
    19           <td>${column.value}<br />
    20               <importer:celltypeselector selected="${column.celltype}" name="celltype[${column.columnindex}]"/>
    21             </td>
    22         </g:each>
    23       </tr>
     17        <tr>
     18          <td>Columnname:</td>
     19          <g:each var="column" in="${header}">
     20              <td class="header">
     21                  <b>${column.value}</b>
     22              </td>
     23          </g:each>
     24        </tr>
     25
     26        <tr>
     27            <td>Datatype:</td>
     28            <g:each var="column" in="${header}">
     29                <td class="header">
     30                    <importer:celltypeSelect selected="${column.celltype}" name="celltype[${column.columnindex}]"/>
     31                </td>
     32            </g:each>
     33        </tr>
     34       
     35        <tr>
     36            <td>Entity:</td>
     37            <g:each var="column" in="${header}">
     38                <td class="header">
     39                    <importer:entitySelect name="entity[${column.columnindex}]"/>
     40                </td>
     41            </g:each>
     42        </tr>
     43
    2444        <g:each var="row" in="${datamatrix}">
    2545            <tr>
     46                <td>Value</td>
    2647                <g:each var="column" in="${row}">
    27                     <td>
     48                    <td class="datamatrix">
    2849                        <g:if test="${column.toString()==''}">.</g:if>
    2950                        <g:else>${column.toString()}</g:else>
     
    3253            </tr>
    3354        </g:each>
    34       <tr>
    35           <td align="right" colspan="${datamatrix.length}"><input type="submit" value="Accept"></td>
    36       </tr>
     55        <tr>
     56            <td align="right" colspan="${datamatrix.length}"><input type="submit" value="Accept"></td>
     57        </tr>
    3758  </table>
    3859  </g:form>
  • trunk/web-app/css/importer.css

    r169 r173  
     1.header
     2{
     3    border-collapse:collapse;
     4    border-width: 1px;
     5    border-color: red;
     6    background-color: #DDDDDD;
     7}
     8
     9.datamatrix
     10{
     11    background-color: #CCDDCC;
     12}
     13
Note: See TracChangeset for help on using the changeset viewer.