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

Last change on this file since 1118 was 1118, checked in by work@…, 10 years ago
  • cleaned up the Bootstrap
  • 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: 1118 $
11 * $Author: work@osx.eu $
12 * $Date: 2010-11-11 11:18:20 +0000 (do, 11 nov 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         * return the domain fields for this domain class
39         * @return List
40         */
41        static List<TemplateField> giveDomainFields() { return Subject.domainFields; }
42
43        // We have to specify an ontology list for the species property. However, at compile time, this ontology does of course not exist.
44        // Therefore, the ontology is added at runtime in the bootstrap, possibly downloading the ontology properties if it is not present in the database yet.
45        static List<TemplateField> domainFields = [
46                new TemplateField(
47                        name: 'name',
48                        type: TemplateFieldType.STRING,
49                        preferredIdentifier: true,
50                        comment: 'Use the local subject name or the pre-defined name',
51                        required: true),
52                new TemplateField(
53                        name: 'species',
54                        type: TemplateFieldType.ONTOLOGYTERM,
55                        comment: "The species name is based on the NEWT ontology; if a species is missing, please add it to the ontology using 'add more'",
56                        required: true)
57        ]
58
59        /**
60         * Return by default the name of the subject.
61         *
62         * @return name field
63         */
64        String toString() {
65                return name
66        }
67}
Note: See TracBrowser for help on using the repository browser.