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

Last change on this file since 507 was 507, checked in by roberth, 13 years ago

Implemented file upload template fields

  • Property svn:keywords set to Date Rev Author
File size: 1.2 KB
Line 
1package dbnp.studycapturing
2
3/**
4 * Enum describing the type of a templated field.
5 * Revision information:
6 * $Rev: 507 $
7 * $Author: roberth $
8 * $Date: 2010-06-01 12:45:21 +0000 (di, 01 jun 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        RELTIME('Relative time'), // relative date, e.g. days since start of study
20        FILE('File')
21
22        String name
23
24        TemplateFieldType(String name) {
25                this.name = name
26        }
27
28        static list() {
29                [STRING, TEXT, INTEGER, FLOAT, DOUBLE, STRINGLIST, ONTOLOGYTERM, DATE, RELTIME, FILE]
30        }
31
32        def getDefaultValue() {
33                switch (this) {
34                        case [STRING, TEXT]:
35                                return ""
36                        case INTEGER:
37                                return Integer.MIN_VALUE
38                        case FLOAT:
39                                return Float.NaN
40                        case DOUBLE:
41                                return Double.MIN_VALUE
42                        case STRINGLIST:
43                                return null
44                        case ONTOLOGYTERM:
45                                return null
46                        case DATE:
47                                return null
48                        case RELTIME:
49                                return null
50                        case FILE:
51                                return ""
52                        default:
53                                throw new NoSuchFieldException("Field type ${fieldType} not recognized")
54                }
55        }
56}
Note: See TracBrowser for help on using the repository browser.