[81] | 1 | package dbnp.studycapturing |
---|
[1426] | 2 | import nl.grails.plugins.gdt.* |
---|
[1440] | 3 | import java.util.UUID; |
---|
[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 | */ |
---|
[1426] | 10 | class Assay extends nl.grails.plugins.gdt.TemplateEntity { |
---|
[825] | 11 | // The name of the assay, which should indicate the measurements represented in this assay to the user. |
---|
[690] | 12 | String name |
---|
[754] | 13 | |
---|
[825] | 14 | // The dbNP module in which the assay omics data can be found. */ |
---|
[690] | 15 | AssayModule module |
---|
[81] | 16 | |
---|
[825] | 17 | // The assay ID which is used in the dbNP submodule which contains the actual omics data of this assay. |
---|
| 18 | // This ID is generated in GSCF, but is used in the submodules to refer to this particular Assay. |
---|
[834] | 19 | String externalAssayID |
---|
[825] | 20 | |
---|
[754] | 21 | /** |
---|
[1440] | 22 | * UUID of this assay |
---|
| 23 | */ |
---|
| 24 | String assayUUID |
---|
| 25 | |
---|
| 26 | /** |
---|
[825] | 27 | * return the domain fields for this domain class |
---|
| 28 | * @return List |
---|
[754] | 29 | */ |
---|
[825] | 30 | static List<TemplateField> giveDomainFields() { return Assay.domainFields } |
---|
| 31 | static List<TemplateField> domainFields = [ |
---|
| 32 | new TemplateField( |
---|
| 33 | name: 'name', |
---|
| 34 | type: TemplateFieldType.STRING, |
---|
| 35 | preferredIdentifier: true, |
---|
| 36 | required: true |
---|
| 37 | ), |
---|
| 38 | new TemplateField( |
---|
| 39 | name: 'module', |
---|
[962] | 40 | type: TemplateFieldType.MODULE, |
---|
| 41 | required: true |
---|
[825] | 42 | ), |
---|
| 43 | new TemplateField( |
---|
| 44 | name: 'externalAssayID', |
---|
[962] | 45 | type: TemplateFieldType.STRING, |
---|
| 46 | required: true |
---|
[825] | 47 | ) |
---|
| 48 | ] |
---|
| 49 | |
---|
[754] | 50 | // An Assay always belongs to one study. |
---|
[690] | 51 | static belongsTo = [parent: Study] |
---|
| 52 | |
---|
[754] | 53 | // An Assay can have many samples on which it is performed, but all samples should be within the 'parent' Study. |
---|
[690] | 54 | static hasMany = [samples: Sample] |
---|
| 55 | |
---|
| 56 | static constraints = { |
---|
[962] | 57 | externalAssayID(nullable:false, blank:false, unique: true) |
---|
[1440] | 58 | assayUUID(nullable:true, unique: true) |
---|
[690] | 59 | } |
---|
| 60 | |
---|
[1036] | 61 | static mapping = { |
---|
| 62 | sort "name" |
---|
[1198] | 63 | |
---|
| 64 | // Workaround for bug http://jira.codehaus.org/browse/GRAILS-6754 |
---|
| 65 | templateTextFields type: 'text' |
---|
[1036] | 66 | } |
---|
| 67 | |
---|
[690] | 68 | def String toString() { |
---|
| 69 | return name; |
---|
| 70 | } |
---|
[934] | 71 | |
---|
| 72 | def getToken() { |
---|
[1440] | 73 | return giveUUID() |
---|
[934] | 74 | } |
---|
[1440] | 75 | |
---|
| 76 | /** |
---|
| 77 | * Returns the UUID of this sample and generates one if needed |
---|
| 78 | */ |
---|
| 79 | public String giveUUID() { |
---|
| 80 | if( !this.assayUUID ) { |
---|
| 81 | this.assayUUID = UUID.randomUUID().toString(); |
---|
| 82 | this.save(); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | return this.assayUUID; |
---|
| 86 | } |
---|
[81] | 87 | } |
---|