source: trunk/grails-app/domain/dbnp/studycapturing/Subject.groovy @ 999

Last change on this file since 999 was 999, checked in by t.w.abma@…, 13 years ago
  • fixed constraint violation error by adding parent to the entities
  • Property svn:keywords set to Author Date Rev
File size: 1.9 KB
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: 999 $
11 * $Author: t.w.abma@umcutrecht.nl $
12 * $Date: 2010-10-27 10:21:30 +0000 (wo, 27 okt 2010) $
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
37
38        /**
39         * return the domain fields for this domain class
40         * @return List
41         */
42        static List<TemplateField> giveDomainFields() { return Subject.domainFields; }
43
44        // We have to specify an ontology list for the species property. However, at compile time, this ontology does of course not exist.
45        // Therefore, the ontology is added at runtime in the bootstrap, possibly downloading the ontology properties if it is not present in the database yet.
46        static List<TemplateField> domainFields = [
47                new TemplateField(
48                        name: 'name',
49                        type: TemplateFieldType.STRING,
50                        preferredIdentifier: true,
51                        comment: 'Use the local subject name or the pre-defined name',
52                        required: true),
53                new TemplateField(
54                        name: 'species',
55                        type: TemplateFieldType.ONTOLOGYTERM,
56                        comment: "The species name is based on the NEWT ontology; if a species is missing, please add it to the ontology using 'add more'",
57                        required: true)
58        ]
59
60        /**
61        * Return by default the name of the subject.
62        *
63        * @return name field
64        */
65        String toString() {
66            return name
67        }
68}
Note: See TracBrowser for help on using the repository browser.