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

Last change on this file since 2200 was 2200, checked in by work@…, 9 years ago
  • implemented getAssayData api call
  • Property svn:keywords set to Rev Author Date
File size: 2.9 KB
RevLine 
[81]1package dbnp.studycapturing
[2200]2
[1457]3import org.dbnp.gdt.*
[81]4
[84]5/**
6 * This class describes an Assay, which describes the application of a certain (omics) measurement to multiple samples.
7 * The actual data of these measurements are described in submodules of dbNP. The type property describes in which module
8 * this data can be found.
9 */
[1452]10class Assay extends TemplateEntity {
[2200]11    // The name of the assay, which should indicate the measurements represented in this assay to the user.
12    String name
[754]13
[2200]14    // The dbNP module in which the assay omics data can be found. */
15    AssayModule module
[81]16
[2200]17    /**
18     * UUID of this assay
19     */
[1440]20    String assayUUID
21
[2200]22    /**
23     * return the domain fields for this domain class
24     * @return List
25     */
26    static List<TemplateField> giveDomainFields() { return Assay.domainFields }
[825]27
[2200]28    static List<TemplateField> domainFields = [
29            new TemplateField(
30                    name: 'name',
31                    type: TemplateFieldType.STRING,
32                    preferredIdentifier: true,
33                    comment: 'The name you give here is used to discern this assay within the study (e.g. \'liver transcriptomics\', \'blood lipidomics\')',
34                    required: true
35            ),
36            new TemplateField(
37                    name: 'module',
38                    type: TemplateFieldType.MODULE,
39                    comment: 'Select the dbNP module where the actual assay measurement data is stored',
40                    required: true
41            )
42    ]
[690]43
[2200]44    // An Assay always belongs to one study.
45    static belongsTo = [parent: Study]
[690]46
[2200]47    // An Assay can have many samples on which it is performed, but all samples should be within the 'parent' Study.
48    static hasMany = [samples: Sample]
[690]49
[2200]50    static constraints = {
51        assayUUID(nullable: true, unique: true)
52    }
53
[1036]54    static mapping = {
55        sort "name"
[1198]56
57        // Workaround for bug http://jira.codehaus.org/browse/GRAILS-6754
[2200]58        templateTextFields type: 'text'
[1036]59    }
60
[2200]61    def String toString() {
62        return name;
63    }
[934]64
65    def getToken() {
[2200]66        return giveUUID()
[934]67    }
[1526]68
[2200]69    /**
70     * Basic equals method to check whether objects are equals, by comparing the ids
71     * @param o Object to compare with
72     * @return True iff the id of the given Study is equal to the id of this Study
73     */
74    public boolean equals(Object o) {
75        if (o == null)
76            return false;
[1526]77
[2200]78        if (!(o instanceof Assay))
79            return false
[1526]80
[2200]81        Assay s = (Assay) o;
82
83        return this.id == s.id
84    }
85
86    /**
87     * Returns the UUID of this sample and generates one if needed
88     */
89    public String giveUUID() {
90        if (!this.assayUUID) {
91            this.assayUUID = UUID.randomUUID().toString();
92            if (!this.save(flush: true)) {
93                log.error "Couldn't save assay UUID: " + this.getErrors();
94            }
95        }
96
97        return this.assayUUID;
98    }
[81]99}
Note: See TracBrowser for help on using the repository browser.