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

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

changed TemplateEntity?.giveFields to reflect ordering as well, also applied ordering to TemplateFieldListItems?, updated Sandbox to display mouse template fields

  • Property svn:keywords set to Date Rev Author
File size: 1.1 KB
Line 
1package dbnp.studycapturing
2
3/**
4 * This is the superclass for template fields. Normally, this class will not be instantiated.
5 *
6 * Revision information:
7 * $Rev: 338 $
8 * $Author: keesvb $
9 * $Date: 2010-04-12 13:11:34 +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.