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

Last change on this file since 375 was 375, checked in by keesvb, 10 years ago

added giveDomainFields to TemplateEntity? entities, fixed some problems in BootStrap?

  • Property svn:keywords set to Date Author Rev
File size: 1.3 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: 375 $
10 * $Author: keesvb $
11 * $Date: 2010-04-23 09:26:57 +0000 (vr, 23 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
20    static hasMany = [listEntries :
21                TemplateFieldListItem, // to store the entries to choose from when the type is 'item from predefined list'
22                ontologies : Ontology // to store the ontologies to choose from when the type is 'ontology term'
23        ]
24       
25        static constraints = {
26                // TODO: verify that TemplateField names are unique within templates of each super entity
27                unit(nullable: true, blank: true)
28                comment(nullable:true, blank: true)
29        }
30
31        static mapping = {
32                comment type: 'text'
33        }
34
35        String toString() {
36                return name
37        }
38
39
40        /**
41         * return an escaped name which can be used in business logic
42         * @return String
43         */
44        def String escapedName() {
45                return name.toLowerCase().replaceAll("([^a-z0-9])","_")
46        }
47
48        //TODO: make a convenience setter for a string array
49        /*def setListEntries(ArrayList entries) {
50                list=[]
51                entries.each {
52                        list.add(new TemplateFieldListItem(name: it))
53                }
54                this
55        }*/
56
57}
Note: See TracBrowser for help on using the repository browser.