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

Last change on this file since 465 was 465, checked in by keesvb, 11 years ago

typing error

  • 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: 465 $
10 * $Author: keesvb $
11 * $Date: 2010-05-25 14:55:45 +0000 (di, 25 mei 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        boolean preferredIdentifier
21
22    static hasMany = [
23                listEntries     : TemplateFieldListItem,        // to store the entries to choose from when the type is 'item from predefined list'
24                ontologies      : Ontology                                      // to store the ontologies to choose from when the type is 'ontology term'
25        ]
26       
27        static constraints = {
28                // TODO: verify that TemplateField names are unique within templates of each super entity
29                unit(nullable: true, blank: true)
30                comment(nullable:true, blank: true)
31                required(default: false)
32                preferredIdentifier(default: false)
33        }
34
35        static mapping = {
36        // TODO: this doesn't seem to work in Postgres
37                comment type: 'text'
38        }
39
40        String toString() {
41                return name
42        }
43
44        /**
45         * return an escaped name which can be used in business logic
46         * @return String
47         */
48        def String escapedName() {
49                return name.toLowerCase().replaceAll("([^a-z0-9])","_")
50        }
51}
Note: See TracBrowser for help on using the repository browser.