1 | package 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: 496 $ |
---|
8 | * $Author: duh $ |
---|
9 | * $Date: 2010-05-28 12:25:13 +0000 (vr, 28 mei 2010) $ |
---|
10 | */ |
---|
11 | class 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 | 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 | /** |
---|
85 | * Return the unique Event templates that are used in this study |
---|
86 | */ |
---|
87 | Set<Template> giveEventTemplates() { |
---|
88 | TemplateEntity.giveTemplates(events); |
---|
89 | } |
---|
90 | |
---|
91 | /** |
---|
92 | * Return the unique SamplingEvent templates that are used in this study |
---|
93 | */ |
---|
94 | Set<Template> giveSamplingEventTemplates() { |
---|
95 | TemplateEntity.giveTemplates(samplingEvents); |
---|
96 | } |
---|
97 | |
---|
98 | /** |
---|
99 | * Returns the unique Sample templates that are used in the study |
---|
100 | */ |
---|
101 | Set<Template> giveSampleTemplates() { |
---|
102 | TemplateEntity.giveTemplates(samples); |
---|
103 | } |
---|
104 | /** |
---|
105 | * Returns the template of the study |
---|
106 | */ |
---|
107 | Template giveStudyTemplate() { |
---|
108 | return this.template; |
---|
109 | } |
---|
110 | } |
---|