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: 352 $ |
---|
8 | * $Author: duh $ |
---|
9 | * $Date: 2010-04-20 07:29:08 +0000 (di, 20 apr 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 | // TODO: The following 4 fields should be moved into templates |
---|
20 | //String code |
---|
21 | //String researchQuestion |
---|
22 | //String description |
---|
23 | //String ecCode |
---|
24 | |
---|
25 | |
---|
26 | static hasMany = [ |
---|
27 | editors: nimble.User, |
---|
28 | readers: nimble.User, |
---|
29 | subjects: Subject, |
---|
30 | events: Event, |
---|
31 | samplingEvents: SamplingEvent, |
---|
32 | eventGroups: EventGroup, |
---|
33 | samples: Sample, |
---|
34 | assays: Assay, |
---|
35 | persons: StudyPerson, |
---|
36 | publications: Publication |
---|
37 | ] |
---|
38 | |
---|
39 | static constraints = { |
---|
40 | owner(nullable: true, blank: true) |
---|
41 | title(nullable: false, blank: false) |
---|
42 | template(nullable: false, blank: false) |
---|
43 | } |
---|
44 | |
---|
45 | static mapping = { |
---|
46 | researchQuestion type: 'text' |
---|
47 | description type: 'text' |
---|
48 | autoTimestamp true |
---|
49 | } |
---|
50 | |
---|
51 | def String toString() { |
---|
52 | return title; |
---|
53 | } |
---|
54 | |
---|
55 | /** |
---|
56 | * Return the unique Subject templates that are used in this study |
---|
57 | */ |
---|
58 | def Set<Template> giveSubjectTemplates() { |
---|
59 | TemplateEntity.giveTemplates(subjects); |
---|
60 | } |
---|
61 | |
---|
62 | |
---|
63 | /** |
---|
64 | * Returns the template of all subjects in the study |
---|
65 | * Throws an error if there are no or multiple subject templates |
---|
66 | */ |
---|
67 | // outcommented, we shouldn't make it too easy for ourselves by introducing uncertain assumptions (1 distinct template) |
---|
68 | //def Template giveSubjectTemplate() { |
---|
69 | // TemplateEntity.giveTemplate(subjects); |
---|
70 | //} |
---|
71 | |
---|
72 | /** |
---|
73 | * Returns the unique Sample templates that are used in the study |
---|
74 | */ |
---|
75 | def Template giveSampleTemplates() { |
---|
76 | TemplateEntity.giveTemplates(samples); |
---|
77 | } |
---|
78 | /** |
---|
79 | * Returns the template of the study |
---|
80 | */ |
---|
81 | def Template giveStudyTemplate() { |
---|
82 | return this.template; |
---|
83 | } |
---|
84 | } |
---|