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

Last change on this file since 453 was 453, checked in by roberth, 13 years ago

Improved study list, study detail view and study comparison. Also improved performance issues

  • Property svn:keywords set to Date Author Rev
File size: 2.3 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: 453 $
8 * $Author: roberth $
9 * $Date: 2010-05-20 15:02:22 +0000 (do, 20 mei 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        /**
20         * return the domain fields for this domain class
21         * @return List
22         */
23        List<TemplateField> giveDomainFields() { return Study.domainFields }
24
25        static final List<TemplateField> domainFields =
26                [
27                        new TemplateField(
28                                name: 'title',
29                                type: TemplateFieldType.STRING),
30                        new TemplateField(
31                                name: 'startDate',
32                                type: TemplateFieldType.DATE)
33                ]
34
35        static hasMany = [
36                editors: nimble.User,
37                readers: nimble.User,
38                subjects: Subject,
39                events: Event,
40                samplingEvents: SamplingEvent,
41                eventGroups: EventGroup,
42                samples: Sample,
43                assays: Assay,
44                persons: StudyPerson,
45                publications: Publication
46        ]
47
48        static constraints = {
49                owner(nullable: true, blank: true)
50        }
51
52        static mapping = {
53                researchQuestion type: 'text'
54                description type: 'text'
55                autoTimestamp true
56        }
57
58        /**
59         * return the title of this study
60         */
61        def String toString() {
62                return title;
63        }
64
65        /**
66         * Return the unique Subject templates that are used in this study
67         */
68        def Set<Template> giveSubjectTemplates() {
69                TemplateEntity.giveTemplates(subjects);
70        }
71
72        /**
73         * Return the unique Event and SamplingEvent templates that are used in this study
74         */
75        Set<Template> giveAllEventTemplates() {
76                // For some reason, giveAllEventTemplates() + giveAllSamplingEventTemplates()
77                // gives trouble when asking .size() to the result
78                // So we also use giveTemplates here
79                TemplateEntity.giveTemplates(events + samplingEvents);
80        }
81
82
83        /**
84         * Return the unique Event templates that are used in this study
85         */
86        Set<Template> giveEventTemplates() {
87                TemplateEntity.giveTemplates(events);
88        }
89
90        /**
91         * Return the unique SamplingEvent templates that are used in this study
92         */
93        Set<Template> giveSamplingEventTemplates() {
94                TemplateEntity.giveTemplates(samplingEvents);
95        }
96
97        /**
98         * Returns the unique Sample templates that are used in the study
99         */
100        Set<Template> giveSampleTemplates() {
101                TemplateEntity.giveTemplates(samples);
102        }
103        /**
104         * Returns the template of the study
105         */
106        Template giveStudyTemplate() {
107                return this.template;
108        }
109}
Note: See TracBrowser for help on using the repository browser.