source: trunk/grails-app/domain/dbnp/studycapturing/Study.groovy @ 345

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

long-awaited code-breaking commit: cleanup of domain classes

  • Property svn:keywords set to Date Rev Author
File size: 1.8 KB
Line 
1package dbnp.studycapturing
2
3/**
4 * Domain class describing the basic entity in the study capture part: the Study class.
5 *
6 * Revision information:
7 * $Rev: 345 $
8 * $Author: keesvb $
9 * $Date: 2010-04-19 07:35:27 +0000 (ma, 19 apr 2010) $
10 */
11class Study extends TemplateEntity implements Serializable {
12        static searchable = true
13        nimble.User owner
14        String title
15
16        // TODO: The following 4 fields should be moved into templates
17        String code
18        String researchQuestion
19        String description
20        String ecCode
21
22        Date dateCreated
23        Date lastUpdated
24        Date startDate
25
26        static hasMany = [
27                editors: nimble.User,
28                readers: nimble.User,
29                subjects: Subject,
30                events: Event,
31                samplingEvents: SamplingEvent,
32                eventGroups: EventGroup,
33                samples: Sample,
34                assays: Assay,
35                persons: StudyPerson,
36                publications: Publication
37        ]
38
39        static constraints = {
40                owner(nullable: true, blank: true)
41                title(nullable: false, blank: false)
42                template(nullable: false, blank: false)
43        }
44
45        static mapping = {
46                researchQuestion type: 'text'
47                description type: 'text'
48                autoTimestamp true
49        }
50
51        def String toString() {
52                return title;
53        }
54
55        /**
56         * Return the unique Subject templates that are used in this study
57         */
58        def Set<Template> giveSubjectTemplates() {
59                TemplateEntity.giveTemplates(subjects);
60        }
61
62
63        /**
64         * Returns the template of all subjects in the study
65         * Throws an error if there are no or multiple subject templates
66         */
67        // outcommented, we shouldn't make it too easy for ourselves by introducing uncertain assumptions (1 distinct template)
68        //def Template giveSubjectTemplate() {
69        //      TemplateEntity.giveTemplate(subjects);
70        //}
71
72        /**
73         * Returns the unique Sample templates that are used in the study
74         */
75        def Template giveSampleTemplates() {
76                TemplateEntity.giveTemplates(samples);
77        }
78        /**
79         * Returns the template of the study
80         */
81        def Template giveStudyTemplate() {
82                return this.template;
83        }
84}
Note: See TracBrowser for help on using the repository browser.