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

Last change on this file since 370 was 370, checked in by roberth, 11 years ago

Updated studies list to handle the new data model.
Updated the bootstrap to contain some studies with attached events and persons in order to test the updated studies list
Added fieldExists method to TemplateEntity? to check whether a given field exists or not

  • Property svn:keywords set to Date Author Rev
File size: 2.1 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: 370 $
8 * $Author: roberth $
9 * $Date: 2010-04-22 07:31:50 +0000 (do, 22 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
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         * Return the unique Event templates that are used in this study
64         */
65        def Set<Template> giveEventTemplates() {
66                TemplateEntity.giveTemplates(events);
67        }
68
69        /**
70         * Return the unique SamplingEvent templates that are used in this study
71         */
72        def Set<Template> giveSamplingEventTemplates() {
73                TemplateEntity.giveTemplates(events);
74        }
75       
76        /**
77         * Returns the template of all subjects in the study
78         * Throws an error if there are no or multiple subject templates
79         */
80        // outcommented, we shouldn't make it too easy for ourselves by introducing uncertain assumptions (1 distinct template)
81        //def Template giveSubjectTemplate() {
82        //      TemplateEntity.giveTemplate(subjects);
83        //}
84
85        /**
86         * Returns the unique Sample templates that are used in the study
87         */
88        def Template giveSampleTemplates() {
89                TemplateEntity.giveTemplates(samples);
90        }
91        /**
92         * Returns the template of the study
93         */
94        def Template giveStudyTemplate() {
95                return this.template;
96        }
97}
Note: See TracBrowser for help on using the repository browser.