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

Last change on this file since 540 was 540, checked in by duh, 11 years ago
  • fixed indentation shite!!!
  • samples dev commit
  • Property svn:keywords set to Date Rev Author
File size: 1.3 KB
RevLine 
[348]1package dbnp.studycapturing
2
[349]3import dbnp.data.Ontology
4
[348]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: 540 $
10 * $Author: duh $
11 * $Date: 2010-06-08 11:04:08 +0000 (di, 08 jun 2010) $
12 */
13class TemplateField implements Serializable {
14        String name
15        TemplateFieldType type
16        String unit
17        String comment // help string for the user interface
[349]18        List listEntries
[384]19        boolean required
[408]20        boolean preferredIdentifier
[348]21
[540]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'
[349]25        ]
[540]26
[348]27        static constraints = {
[375]28                // TODO: verify that TemplateField names are unique within templates of each super entity
[348]29                unit(nullable: true, blank: true)
[540]30                comment(nullable: true, blank: true)
[384]31                required(default: false)
[408]32                preferredIdentifier(default: false)
[348]33        }
34
35        static mapping = {
[540]36                // TODO: this doesn't seem to work in Postgres
[348]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() {
[540]49                return name.toLowerCase().replaceAll("([^a-z0-9])", "_")
[348]50        }
[465]51}
Note: See TracBrowser for help on using the repository browser.