Last change
on this file since 550 was
550,
checked in by keesvb, 13 years ago
|
added entity property to TemplateField?; added validator to Template to ensure fields are of the correct entity, updated BootStrap? accordingly, updated tests accordingly
|
-
Property svn:keywords set to
Date Rev Author
|
File size:
1.4 KB
|
Line | |
---|
1 | package dbnp.studycapturing |
---|
2 | |
---|
3 | import dbnp.data.Ontology |
---|
4 | |
---|
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: 550 $ |
---|
10 | * $Author: keesvb $ |
---|
11 | * $Date: 2010-06-09 23:33:37 +0000 (wo, 09 jun 2010) $ |
---|
12 | */ |
---|
13 | class TemplateField implements Serializable { |
---|
14 | String name |
---|
15 | TemplateFieldType type |
---|
16 | Class entity |
---|
17 | String unit |
---|
18 | String comment // help string for the user interface |
---|
19 | List listEntries |
---|
20 | boolean required |
---|
21 | boolean preferredIdentifier |
---|
22 | |
---|
23 | static hasMany = [ |
---|
24 | listEntries: TemplateFieldListItem, // to store the entries to choose from when the type is 'item from predefined list' |
---|
25 | ontologies: Ontology // to store the ontologies to choose from when the type is 'ontology term' |
---|
26 | ] |
---|
27 | |
---|
28 | static constraints = { |
---|
29 | // TODO: verify that TemplateField names are unique within templates of each super entity |
---|
30 | name(nullable: false, blank: false) |
---|
31 | type(nullable: false, blank: false) |
---|
32 | entity(nullable: false, blank: false) |
---|
33 | unit(nullable: true, blank: true) |
---|
34 | comment(nullable: true, blank: true) |
---|
35 | required(default: false) |
---|
36 | preferredIdentifier(default: false) |
---|
37 | } |
---|
38 | |
---|
39 | static mapping = { |
---|
40 | // TODO: this doesn't seem to work in Postgres |
---|
41 | comment type: 'text' |
---|
42 | } |
---|
43 | |
---|
44 | String toString() { |
---|
45 | return name |
---|
46 | } |
---|
47 | |
---|
48 | /** |
---|
49 | * return an escaped name which can be used in business logic |
---|
50 | * @return String |
---|
51 | */ |
---|
52 | def String escapedName() { |
---|
53 | return name.toLowerCase().replaceAll("([^a-z0-9])", "_") |
---|
54 | } |
---|
55 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.