root/trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy @ 408

Revision 408, 1.0 KB (checked in by keesvb, 4 years ago)

reverted changes which removed domain fields from the domain classes, we are now back again at more or less the situation of #394, added preferredIdentifier property to TemplateField? to facilitate simple import

  • Property svn:keywords set to Date Author Rev
Line 
1package dbnp.studycapturing
2
3import dbnp.data.Term
4import dbnp.data.Ontology
5
6/**
7 * The Sample class describes an actual sample which results from a SamplingEvent.
8 */
9class Sample extends TemplateEntity {
10        static searchable = true
11        Subject parentSubject
12        SamplingEvent parentEvent
13
14        String name     // should be unique with respect to the parent study (which can be inferred)
15        Term material   // a member that describes the quantity of the sample? --> should be in the templates
16
17        /**
18         * return the domain fields for this domain class
19         * @return List
20         */
21        List<TemplateField> giveDomainFields() {
22                [
23                        new TemplateField(
24                                name: 'name',
25                                type: TemplateFieldType.STRING,
26                                preferredIdentifier: true),
27                        new TemplateField(
28                                name: 'material',
29                                type: TemplateFieldType.ONTOLOGYTERM,
30                                ontologies: [Ontology.findByNcboId(1005)])
31                ]
32        }
33
34        static constraints = {
35                parentSubject(nullable:true)
36        }
37
38        static getSamplesFor( event ) {
39            return  Sample.findAll( 'from Sample s where s.parentEvent =:event', [event:event] )
40        }
41
42}
Note: See TracBrowser for help on using the browser.