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

Last change on this file since 296 was 296, checked in by duh, 10 years ago
  • refactored template field handeling in the wizard
  • added escapedName() method to TemplateField? which returns the field name in lowercase format, and all non-alphanumeric characters escaped to underscores (hence: jeroen_s_very_cool_field)
  • (re)moved some template 'note' boxes
  • Property svn:keywords set to Author Rev Date
File size: 1.0 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: 296 $
8 * $Author: duh $
9 * $Date: 2010-03-22 12:44:00 +0000 (ma, 22 mrt 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    static hasMany = [listEntries : TemplateFieldListItem] // to store the entries to choose from when the type is 'item from predefined list'
18
19        static constraints = {
20                name(unique: true)
21                unit(nullable: true, blank: true)
22                comment(nullable:true, blank: true)
23        }
24
25        static mapping = {
26                comment type: 'text'
27        }
28
29        String toString() {
30                return name
31        }
32
33
34        /**
35         * return an escaped name which can be used in business logic
36         * @return String
37         */
38        def String escapedName() {
39                return name.toLowerCase().replaceAll("([^a-zA-Z0-9])","_")
40        }
41
42        //TODO: make a convenience setter for a string array
43        /*def setListEntries(ArrayList entries) {
44                list=[]
45                entries.each {
46                        list.add(new TemplateFieldListItem(name: it))
47                }
48                this
49        }*/
50
51}
Note: See TracBrowser for help on using the repository browser.