root/trunk/grails-app/domain/dbnp/studycapturing/Subject.groovy @ 1198

Revision 1198, 2.0 KB (checked in by t.e.roos@…, 3 years ago)

Added workarounds for known template text fields bug

  • Property svn:keywords set to Author Date Rev
Line 
1package dbnp.studycapturing
2
3import dbnp.data.Term
4import dbnp.data.Ontology
5
6/**
7 * This domain class describes the subjects in a study.
8 *
9 * Revision information:
10 * $Rev$
11 * $Author$
12 * $Date$
13 */
14class Subject extends TemplateEntity {
15        // uncommented due to searchable issue
16        // @see http://jira.codehaus.org/browse/GRAILSPLUGINS-1577
17        //static searchable = { [only: ['name']] }
18
19        // A Subject always belongs to one Study
20        static belongsTo = [parent: Study]
21
22        /** The name of the subject, which should be unique within the study  */
23        String name
24
25        /** The species of the subject. In the domainFields property, the ontologies from which this term may come are specified.  */
26        Term species
27
28        static constraints = {
29                // Ensure that the subject name is unique within the study
30                name(unique: ['parent'])
31        }
32
33        static mapping = {
34                name column: "subjectname"
35
36                // Workaround for bug http://jira.codehaus.org/browse/GRAILS-6754
37                templateTextFields type: 'text'
38        }
39
40        /**
41         * return the domain fields for this domain class
42         * @return List
43         */
44        static List<TemplateField> giveDomainFields() { return Subject.domainFields; }
45
46        // We have to specify an ontology list for the species property. However, at compile time, this ontology does of course not exist.
47        // Therefore, the ontology is added at runtime in the bootstrap, possibly downloading the ontology properties if it is not present in the database yet.
48        static List<TemplateField> domainFields = [
49                new TemplateField(
50                        name: 'name',
51                        type: TemplateFieldType.STRING,
52                        preferredIdentifier: true,
53                        comment: 'Use the local subject name or the pre-defined name',
54                        required: true),
55                new TemplateField(
56                        name: 'species',
57                        type: TemplateFieldType.ONTOLOGYTERM,
58                        comment: "The species name is based on the NEWT ontology; if a species is missing, please add it to the ontology using 'add more'",
59                        required: true)
60        ]
61
62        /**
63         * Return by default the name of the subject.
64         *
65         * @return name field
66         */
67        String toString() {
68                return name
69        }
70}
Note: See TracBrowser for help on using the browser.