source: trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy @ 173

Last change on this file since 173 was 173, checked in by tabma, 9 years ago
  • created taglibrary for importer and first implementation detection of (cell) datatypes
  • Property svn:keywords set to Date Author Rev
File size: 2.0 KB
Line 
1/**
2 * Importer tag library
3 *
4 * The importer tag library gives support for automating several 'components'
5 *
6 * @package     importer
7 * @author      t.w.abma@umcutrecht.nl
8 * @since       20100202
9 *
10 * Revision information:
11 * $Rev: 173 $
12 * $Author: tabma $
13 * $Date: 2010-02-08 07:23:33 +0000 (ma, 08 feb 2010) $
14 */
15
16package dbnp.importer
17
18class ImporterTagLib {
19    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"]]
25
26    /**
27    * @param header string array containing header
28    * @param datamatrix two dimensional array containing actual data
29    * @return preview of the data with the ability to adjust the datatypes
30    */
31    def preview = { attrs ->
32       
33        def header = attrs['header']
34        def datamatrix = attrs['datamatrix']
35
36        out << render (template:"common/preview", model:[header:header, datamatrix:datamatrix])
37    }
38
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
61    /**
62    * @param selected selected celltype
63    * @param name name of the HTML select object
64    * @see org.apache.poi.ss.usermodel.Cell for the possible cell types
65    * @return HTML select object
66    */
67    def celltypeSelect = { attrs ->
68        def selected = (attrs['selected']==null) ? -1 : attrs['selected']
69        out << createSelect(selected, attrs['name'], celltypes)
70    }
71}
Note: See TracBrowser for help on using the repository browser.