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

Last change on this file since 510 was 510, checked in by duh, 13 years ago
  • wizard saving second version
  • Property svn:keywords set to Date Rev Author
File size: 2.4 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: 510 $
8 * $Author: duh $
9 * $Date: 2010-06-02 14:38:09 +0000 (wo, 02 jun 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        static 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                        comment: 'Fill out the official start date or date of first action')
34        ]
35
36        static hasMany = [
37                editors: nimble.User,
38                readers: nimble.User,
39                subjects: Subject,
40                events: Event,
41                samplingEvents: SamplingEvent,
42                eventGroups: EventGroup,
43                samples: Sample,
44                assays: Assay,
45                persons: StudyPerson,
46                publications: Publication
47        ]
48
49        static constraints = {
50                owner(nullable: true, blank: true)
51        }
52
53        static mapping = {
54                researchQuestion type: 'text'
55                description type: 'text'
56                autoTimestamp true
57        }
58
59        /**
60         * return the title of this study
61         */
62        def String toString() {
63                return title;
64        }
65
66        /**
67         * Return the unique Subject templates that are used in this study
68         */
69        def Set<Template> giveSubjectTemplates() {
70                TemplateEntity.giveTemplates(subjects);
71        }
72
73        /**
74         * Return the unique Event and SamplingEvent templates that are used in this study
75         */
76        Set<Template> giveAllEventTemplates() {
77                // For some reason, giveAllEventTemplates() + giveAllSamplingEventTemplates()
78                // gives trouble when asking .size() to the result
79                // So we also use giveTemplates here
80                TemplateEntity.giveTemplates(events + samplingEvents);
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.