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

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