source: trunk/grails-app/domain/dbnp/studycapturing/TemplateFieldType.groovy @ 238

Last change on this file since 238 was 238, checked in by duh, 13 years ago

Refectored version of the wizard

  • initial template page has been removed, now is a generic 'start' page where one (in the future) may create a new study, or load and modify an already stored study
  • study page incorporates study template select element, but does not yet incorporate the study template fields
  • subjects page now allows creation of subjects based on a template. This change also implied the study page altogether had to change into a seperate table entity. Now the the page lists as many tables as unique templates have been selected. These tables contain all subjects that were added using that particular template. NOTE: data is not stored yet, due to the fact that templateEntity does not work properly yey (key/value pairs need to be set correctly when calling the setTemplate method)
  • the JavaScript? now handles multiple tables in a page as well, and automatically initializes any underlying slider div if that is required
  • Property svn:keywords set to Rev Date Author
File size: 1.3 KB
Line 
1package dbnp.studycapturing
2
3/**
4 * Enum describing the type of a templated field.
5 * Revision information:
6 * $Rev: 238 $
7 * $Author: duh $
8 * $Date: 2010-03-05 14:21:52 +0000 (vr, 05 mrt 2010) $
9 */
10public enum TemplateFieldType implements Serializable  {
11        STRING('String'),
12        TEXT('Long string'),
13        INTEGER('Integer number'),
14        FLOAT('Floating-point number'),
15        DOUBLE('Double precision floating-point number'),
16        STRINGLIST('List of items'),
17        ONTOLOGYTERM('Ontology Reference'),
18        DATE('Date')
19
20        String name
21
22        TemplateFieldType(String name) {
23                this.name = name
24        }
25
26        static list() {
27                [STRING, TEXT, INTEGER, FLOAT, DOUBLE, STRINGLIST, ONTOLOGYTERM, DATE]
28        }
29
30        def getDefaultValue() {
31                switch(this) {
32                        case [STRING, TEXT]:
33                                return ""
34                        case INTEGER:
35                                return Integer.MIN_VALUE
36                        case FLOAT:
37                                return Float.NaN
38                        case DOUBLE:
39                                return Double.MIN_VALUE
40                        case STRINGLIST:
41                                return null
42                        case ONTOLOGYTERM:
43                                return null
44                        case DATE:
45                                return null
46                        default:
47                                throw new NoSuchFieldException("Field type ${fieldType} not recognized")
48                }
49        }
50
51        // It would be nice to see the description string in the scaffolding,
52        // and the following works, but then the item cannot be saved properly.
53        // TODO: find a way to display the enum description but save the enum value in the scaffolding
54        /*
55        def String toString() {
56                  return this.name
57        }
58        */
59}
Note: See TracBrowser for help on using the repository browser.