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

Last change on this file since 386 was 386, checked in by roberth, 9 years ago

Updated the template entities to be able to return domain fields, template fields and both.
Rolled back the change of Kees in the Event object, so the startTime and endTime fields returned.
Also updated the studies list with a new layout.

  • Property svn:keywords set to Date Author Rev
File size: 2.5 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: 386 $
8 * $Author: roberth $
9 * $Date: 2010-04-27 13:53:06 +0000 (di, 27 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        List<DomainTemplateField> giveDomainFields() {
26                [ new TemplateField( 
27                            name: 'title - niet opslaan!',
28                            type: TemplateFieldType.STRING),
29                        new TemplateField( 
30                            name: 'startDate', 
31                            type: TemplateFieldType.DATE) ];
32        }
33
34        static hasMany = [
35                editors: nimble.User,
36                readers: nimble.User,
37                subjects: Subject,
38                events: Event,
39                samplingEvents: SamplingEvent,
40                eventGroups: EventGroup,
41                samples: Sample,
42                assays: Assay,
43                persons: StudyPerson,
44                publications: Publication
45        ]
46
47        static constraints = {
48                owner(nullable: true, blank: true)
49                title(nullable: false, blank: false)
50                template(nullable: false, blank: false)
51        }
52
53        static mapping = {
54                researchQuestion type: 'text'
55                description type: 'text'
56                autoTimestamp true
57        }
58
59        def String toString() {
60                return title;
61        }
62
63        /**
64         * Return the unique Subject templates that are used in this study
65         */
66        def Set<Template> giveSubjectTemplates() {
67                TemplateEntity.giveTemplates(subjects);
68        }
69
70        /**
71         * Return the unique Event templates that are used in this study
72         */
73        def Set<Template> giveEventTemplates() {
74                TemplateEntity.giveTemplates(events);
75        }
76
77        /**
78         * Return the unique SamplingEvent templates that are used in this study
79         */
80        def Set<Template> giveSamplingEventTemplates() {
81                TemplateEntity.giveTemplates(events);
82        }
83       
84        /**
85         * Returns the template of all subjects in the study
86         * Throws an error if there are no or multiple subject templates
87         */
88        // outcommented, we shouldn't make it too easy for ourselves by introducing uncertain assumptions (1 distinct template)
89        //def Template giveSubjectTemplate() {
90        //      TemplateEntity.giveTemplate(subjects);
91        //}
92
93        /**
94         * Returns the unique Sample templates that are used in the study
95         */
96        def Template giveSampleTemplates() {
97                TemplateEntity.giveTemplates(samples);
98        }
99        /**
100         * Returns the template of the study
101         */
102        def Template giveStudyTemplate() {
103                return this.template;
104        }
105}
Note: See TracBrowser for help on using the repository browser.