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

Last change on this file since 754 was 754, checked in by keesvb, 12 years ago

big refactoring / change of the data model: implemented belongsTo everywhere where it should be, added comments to the domain classes, changed BootStrap? accordingly

  • Property svn:keywords set to Date Rev Author
File size: 1.7 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: 754 $
11 * $Author: keesvb $
12 * $Date: 2010-07-30 13:05:41 +0000 (vr, 30 jul 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
34        /**
35         * return the domain fields for this domain class
36         * @return List
37         */
38        static List<TemplateField> giveDomainFields() { return Subject.domainFields; }
39
40        // We have to specify an ontology list for the species property. However, at compile time, this ontology does of course not exist.
41        // Therefore, the ontology is added at runtime in the bootstrap, possibly downloading the ontology properties if it is not present in the database yet.
42        static List<TemplateField> domainFields = [
43                new TemplateField(
44                        name: 'name',
45                        type: TemplateFieldType.STRING,
46                        preferredIdentifier: true,
47                        comment: 'Use the local subject name or the pre-defined name'),
48                new TemplateField(
49                        name: 'species',
50                        type: TemplateFieldType.ONTOLOGYTERM,
51                        comment: "The species name is based on the NEWT ontology; if a species is missing, please add it to the ontology using 'add more'")
52        ]
53}
Note: See TracBrowser for help on using the repository browser.