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

Last change on this file since 389 was 389, checked in by duh, 9 years ago
  • reverted changes of revisions 386, 387 and 388 as they completely broke the repository (you need to get cake now! ;)
  • committed development version of modified study capture wizard (works until events)
  • Property svn:keywords set to Date Author Rev
File size: 2.2 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: 389 $
8 * $Author: duh $
9 * $Date: 2010-04-28 14:28:39 +0000 (wo, 28 apr 2010) $
10 */
11class Study extends TemplateEntity implements Serializable {
12        static searchable = true
13        nimble.User owner
14        String title
15        Date dateCreated
16        Date lastUpdated
17        Date startDate
18
19        // TODO: The following 4 fields should be moved into templates
20        //String code
21        //String researchQuestion
22        //String description
23        //String ecCode
24
25        Map giveDomainFields() {
26                return ['title':TemplateFieldType.STRING,'startDate':TemplateFieldType.DATE]
27        }
28
29        static hasMany = [
30                editors: nimble.User,
31                readers: nimble.User,
32                subjects: Subject,
33                events: Event,
34                samplingEvents: SamplingEvent,
35                eventGroups: EventGroup,
36                samples: Sample,
37                assays: Assay,
38                persons: StudyPerson,
39                publications: Publication
40        ]
41
42        static constraints = {
43                owner(nullable: true, blank: true)
44                title(nullable: false, blank: false)
45                template(nullable: false, blank: false)
46        }
47
48        static mapping = {
49                researchQuestion type: 'text'
50                description type: 'text'
51                autoTimestamp true
52        }
53
54        def String toString() {
55                return title;
56        }
57
58        /**
59         * Return the unique Subject templates that are used in this study
60         */
61        def Set<Template> giveSubjectTemplates() {
62                TemplateEntity.giveTemplates(subjects);
63        }
64
65        /**
66         * Return the unique Event templates that are used in this study
67         */
68        def Set<Template> giveEventTemplates() {
69                TemplateEntity.giveTemplates(events);
70        }
71
72        /**
73         * Return the unique SamplingEvent templates that are used in this study
74         */
75        def Set<Template> giveSamplingEventTemplates() {
76                TemplateEntity.giveTemplates(events);
77        }
78       
79        /**
80         * Returns the template of all subjects in the study
81         * Throws an error if there are no or multiple subject templates
82         */
83        // outcommented, we shouldn't make it too easy for ourselves by introducing uncertain assumptions (1 distinct template)
84        //def Template giveSubjectTemplate() {
85        //      TemplateEntity.giveTemplate(subjects);
86        //}
87
88        /**
89         * Returns the unique Sample templates that are used in the study
90         */
91        def Template giveSampleTemplates() {
92                TemplateEntity.giveTemplates(samples);
93        }
94        /**
95         * Returns the template of the study
96         */
97        def Template giveStudyTemplate() {
98                return this.template;
99        }
100}
Note: See TracBrowser for help on using the repository browser.