Changeset 2200 for trunk/grails-app/domain/dbnp/studycapturing/Assay.groovy
- Timestamp:
- Mar 30, 2012, 5:17:57 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/Assay.groovy
r1873 r2200 1 1 package dbnp.studycapturing 2 2 3 import org.dbnp.gdt.* 3 4 … … 8 9 */ 9 10 class Assay extends TemplateEntity { 10 11 11 // The name of the assay, which should indicate the measurements represented in this assay to the user. 12 String name 12 13 13 14 14 // The dbNP module in which the assay omics data can be found. */ 15 AssayModule module 15 16 16 17 18 17 /** 18 * UUID of this assay 19 */ 19 20 String assayUUID 20 21 21 /** 22 * return the domain fields for this domain class 23 * @return List 24 */ 25 static List<TemplateField> giveDomainFields() { return Assay.domainFields } 26 static List<TemplateField> domainFields = [ 27 new TemplateField( 28 name: 'name', 29 type: TemplateFieldType.STRING, 30 preferredIdentifier: true, 31 comment: 'The name you give here is used to discern this assay within the study (e.g. \'liver transcriptomics\', \'blood lipidomics\')', 32 required: true 33 ), 34 new TemplateField( 35 name: 'module', 36 type: TemplateFieldType.MODULE, 37 comment: 'Select the dbNP module where the actual assay measurement data is stored', 38 required: true 39 ) 40 ] 22 /** 23 * return the domain fields for this domain class 24 * @return List 25 */ 26 static List<TemplateField> giveDomainFields() { return Assay.domainFields } 41 27 42 // An Assay always belongs to one study. 43 static belongsTo = [parent: Study] 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 ] 44 43 45 // An Assay can have many samples on which it is performed, but all samples should be within the 'parent' Study.46 static hasMany = [samples: Sample]44 // An Assay always belongs to one study. 45 static belongsTo = [parent: Study] 47 46 48 static constraints = { 49 assayUUID(nullable:true, unique: true) 50 } 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] 49 50 static constraints = { 51 assayUUID(nullable: true, unique: true) 52 } 51 53 52 54 static mapping = { … … 54 56 55 57 // Workaround for bug http://jira.codehaus.org/browse/GRAILS-6754 56 58 templateTextFields type: 'text' 57 59 } 58 60 59 60 61 61 def String toString() { 62 return name; 63 } 62 64 63 65 def getToken() { 64 66 return giveUUID() 65 67 } 66 67 /**68 * Basic equals method to check whether objects are equals, by comparing the ids69 * @param o Object to compare with70 * @return True iff the id of the given Study is equal to the id of this Study71 */72 public boolean equals( Object o ) {73 if( o == null )74 return false;75 68 76 if( !( o instanceof Assay ) ) 77 return false 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; 78 77 79 Assay s = (Assay) o; 78 if (!(o instanceof Assay)) 79 return false 80 80 81 return this.id == s.id 82 } 83 84 /** 85 * Returns the UUID of this sample and generates one if needed 86 */ 87 public String giveUUID() { 88 if( !this.assayUUID ) { 89 this.assayUUID = UUID.randomUUID().toString(); 90 if( !this.save(flush:true) ) { 91 log.error "Couldn't save assay UUID: " + this.getErrors(); 92 } 93 } 94 95 return this.assayUUID; 96 } 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 } 97 99 }
Note: See TracChangeset
for help on using the changeset viewer.