source: trunk/grails-app/domain/dbnp/studycapturing/Assay.groovy @ 1456

Last change on this file since 1456 was 1456, checked in by business@…, 8 years ago

moved gdt package to org.dbnp, moved tests for RelTime?, TemplateEntity?, Template etc. to gdt plugin

  • Property svn:keywords set to Rev Author Date
File size: 2.2 KB
Line 
1package dbnp.studycapturing
2
3/**
4 * This class describes an Assay, which describes the application of a certain (omics) measurement to multiple samples.
5 * The actual data of these measurements are described in submodules of dbNP. The type property describes in which module
6 * this data can be found.
7 */
8class Assay extends TemplateEntity {
9        // The name of the assay, which should indicate the measurements represented in this assay to the user.
10        String name
11
12        // The dbNP module in which the assay omics data can be found. */
13        AssayModule module
14
15        // The assay ID which is used in the dbNP submodule which contains the actual omics data of this assay.
16        // This ID is generated in GSCF, but is used in the submodules to refer to this particular Assay.
17        String externalAssayID
18
19        /**
20        * UUID of this assay
21        */
22    String assayUUID
23
24        /**
25         * return the domain fields for this domain class
26         * @return List
27         */
28        static List<TemplateField> giveDomainFields() { return Assay.domainFields }
29        static List<TemplateField> domainFields = [
30                new TemplateField(
31                        name: 'name',
32                        type: TemplateFieldType.STRING,
33                        preferredIdentifier: true,
34                        required: true
35                ),
36                new TemplateField(
37                        name: 'module',
38                        type: TemplateFieldType.MODULE,
39                        required: true
40                ),
41                new TemplateField(
42                        name: 'externalAssayID',
43                        type: TemplateFieldType.STRING,
44                        required: true
45                )
46        ]
47
48        // An Assay always belongs to one study.
49        static belongsTo = [parent: Study]
50
51        // An Assay can have many samples on which it is performed, but all samples should be within the 'parent' Study.
52        static hasMany = [samples: Sample]
53
54        static constraints = {
55                externalAssayID(nullable:false, blank:false, unique: true)
56                assayUUID(nullable:true, unique: true)
57        }
58
59    static mapping = {
60        sort "name"
61
62        // Workaround for bug http://jira.codehaus.org/browse/GRAILS-6754
63        templateTextFields type: 'text'
64    }
65
66        def String toString() {
67                return name;
68        }
69
70    def getToken() {
71                return giveUUID()
72    }
73       
74        /**
75         * Returns the UUID of this sample and generates one if needed
76         */
77        public String giveUUID() {
78                if( !this.assayUUID ) {
79                        this.assayUUID = UUID.randomUUID().toString();
80                        if( !this.save(flush:true) ) {
81                                log.error "Couldn't save assay UUID: " + this.getErrors();
82                        }
83                }
84               
85                return this.assayUUID;
86        }
87}
Note: See TracBrowser for help on using the repository browser.