source: trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy @ 697

Last change on this file since 697 was 697, checked in by keesvb, 12 years ago

added assayModule and assay controllers to be able to create assays

  • Property svn:keywords set to Date Rev Author
File size: 1.5 KB
Line 
1package dbnp.studycapturing
2
3import dbnp.data.Term
4
5/**
6 * The Sample class describes an actual sample which results from a SamplingEvent.
7 */
8class Sample extends TemplateEntity {
9        // uncommented due to searchable issue
10        // @see http://jira.codehaus.org/browse/GRAILSPLUGINS-1577
11        //static searchable = { [only: ['name']] }
12
13        static belongsTo = [ parent : Study]
14
15        Subject parentSubject
16        SamplingEvent parentEvent
17
18        String name             // should be unique with respect to the parent study (which can be inferred)
19        Term material           // material of the sample (should normally be bound to the BRENDA ontology)
20
21        def getExternalSampleId() { name }
22
23        /**
24         * return the domain fields for this domain class
25         * @return List
26         */
27        static List<TemplateField> giveDomainFields() { return Sample.domainFields }
28        static List<TemplateField> domainFields = [
29                new TemplateField(
30                        name: 'name',
31                        type: TemplateFieldType.STRING,
32                        preferredIdentifier: true,
33                        required: true
34                ),
35                new TemplateField(
36                        name: 'material',
37                        type: TemplateFieldType.ONTOLOGYTERM
38                )
39        ]
40
41        static constraints = {
42                parentSubject(nullable:true)
43                material(nullable: true)
44
45                // Checks if the externalSampleId (currently defined as name) is really unique within each parent study of this sample.
46                // This feature is tested by integration test SampleTests.testSampleUniqueNameConstraint
47                name(unique:['parent'])
48        }
49
50        static getSamplesFor( event ) {
51                return  Sample.findAll( 'from Sample s where s.parentEvent =:event', [event:event] )
52        }
53
54        def String toString() {
55                return name
56        }
57}
Note: See TracBrowser for help on using the repository browser.