source: trunk/grails-app/domain/dbnp/studycapturing/TemplateField.groovy @ 389

Last change on this file since 389 was 384, checked in by keesvb, 9 years ago

FINALLY found a possible way to integrate the domain fields as TemplateFields?, see Event. Also added required attribute for template fields.

  • Property svn:keywords set to Date Author Rev
File size: 1.4 KB
Line 
1package dbnp.studycapturing
2
3import dbnp.data.Ontology
4
5/**
6 * This is the class for template fields. These should be part of one or more templates via Template.fields
7 *
8 * Revision information:
9 * $Rev: 384 $
10 * $Author: duh $
11 * $Date: 2010-04-27 07:13:47 +0000 (di, 27 apr 2010) $
12 */
13class TemplateField implements Serializable {
14        String name
15        TemplateFieldType type
16        String unit
17        String comment // help string for the user interface
18        List listEntries
19        boolean required
20
21    static hasMany = [listEntries :
22                TemplateFieldListItem, // to store the entries to choose from when the type is 'item from predefined list'
23                ontologies : Ontology // to store the ontologies to choose from when the type is 'ontology term'
24        ]
25       
26        static constraints = {
27                // TODO: verify that TemplateField names are unique within templates of each super entity
28                unit(nullable: true, blank: true)
29                comment(nullable:true, blank: true)
30                required(default: false)
31        }
32
33        static mapping = {
34                comment type: 'text'
35        }
36
37        String toString() {
38                return name
39        }
40
41
42        /**
43         * return an escaped name which can be used in business logic
44         * @return String
45         */
46        def String escapedName() {
47                return name.toLowerCase().replaceAll("([^a-z0-9])","_")
48        }
49
50        //TODO: make a convenience setter for a string array
51        /*def setListEntries(ArrayList entries) {
52                list=[]
53                entries.each {
54                        list.add(new TemplateFieldListItem(name: it))
55                }
56                this
57        }*/
58
59}
Note: See TracBrowser for help on using the repository browser.