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