Last change
on this file since 654 was
654,
checked in by keesvb, 13 years ago
|
updated sample and study tests, added belongsTo to Sample (which gives it its parent), tried to write the unique name constraint of Sample and wrote a test for it
|
-
Property svn:keywords set to
Date Rev Author
|
File size:
832 bytes
|
Line | |
---|
1 | package dbnp.studycapturing |
---|
2 | |
---|
3 | /** |
---|
4 | * The SamplingEvent class describes a sampling event, an event that also results in one or more samples. |
---|
5 | * |
---|
6 | * NOTE: according to documentation, super classes and subclasses share the same table. |
---|
7 | * thus, we could merge the sampling with the Event super class and include a boolean |
---|
8 | * However, using a separate class makes it more clear in the code that Event and SamplingEvent are treated differently |
---|
9 | */ |
---|
10 | |
---|
11 | class SamplingEvent extends Event { |
---|
12 | |
---|
13 | static constraints = { |
---|
14 | } |
---|
15 | |
---|
16 | /** |
---|
17 | * Get all samples that have this sampling event as a parent |
---|
18 | */ |
---|
19 | def getSamples() { |
---|
20 | |
---|
21 | def samples = Sample.findAll("from Sample as s where s.parentEvent.id = ${this.id}") |
---|
22 | samples.collect { it.class == SamplingEvent.class } |
---|
23 | samples.collect { it != null } |
---|
24 | return samples == null ? [] : samples |
---|
25 | } |
---|
26 | |
---|
27 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.