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

Revision 454, 1.0 KB (checked in by roberth, 4 years ago)

Improved study list to be able to handle one or more studies. Also improved performance issues with Subject and Sample classes. I have set the domainFields property to a static property, filled it in the class description and attached an ontology to it in the bootstrap (because it can't be done in the class description). It might not be the prettiest solution, it does improve the performance of the study detail page and study comparison with 90%.

  • 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() { return Sample.domainFields }
22        static List<TemplateField> domainFields =
23                [
24                        new TemplateField(
25                                name: 'name',
26                                type: TemplateFieldType.STRING,
27                                preferredIdentifier: true),
28                        new TemplateField(
29                                name: 'material',
30                                type: TemplateFieldType.ONTOLOGYTERM )
31                ]
32
33        static constraints = {
34                parentSubject(nullable:true)
35        }
36
37        static getSamplesFor( event ) {
38            return  Sample.findAll( 'from Sample s where s.parentEvent =:event', [event:event] )
39        }
40
41}
Note: See TracBrowser for help on using the browser.