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

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

added plant template to BootStrap?

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