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

Last change on this file since 300 was 300, checked in by duh, 12 years ago
  • it makes no sense using a regular expression mathing for a-zA-Z0-9 on a lowercase string; removed A-Z
  • moved minumum string length configuration before ontology autocomplete fires to the class variables
  • Property svn:keywords set to Date Rev Author
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: 300 $
8 * $Author: duh $
9 * $Date: 2010-03-22 15:04:29 +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-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.