Changeset 654 for trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy
- Timestamp:
- Jul 15, 2010, 2:26:48 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy
r652 r654 8 8 */ 9 9 class Sample extends TemplateEntity { 10 static searchable = { [only: ['name']] } 11 10 static searchable = { [only: ['name']] } 11 12 static belongsTo = [ parent : Study] 13 12 14 Subject parentSubject 13 15 SamplingEvent parentEvent … … 17 19 18 20 def getExternalSampleId() { name } 19 20 // TODO: Write a validation method that checks if the externalSampleId (currently defined as name)21 // is really unique within each parent study of this sample.22 // Maybe this could also be a constraint, but we might run into trouble creating new Sample objects in e.g. the create wizard.23 // To be checked.24 21 25 22 /** … … 32 29 name: 'name', 33 30 type: TemplateFieldType.STRING, 34 preferredIdentifier: true 31 preferredIdentifier: true, 32 required: true 35 33 ), 36 34 new TemplateField( … … 42 40 static constraints = { 43 41 parentSubject(nullable:true) 42 material(nullable: true) 43 44 // TODO: Write a validation method that checks if the externalSampleId (currently defined as name) 45 // is really unique within each parent study of this sample. 46 // Maybe this could also be a constraint, but we might run into trouble creating new Sample objects in e.g. the create wizard. 47 // To be checked. 48 // This feature is tested by integration test SampleTests.testSampleUniqueNameConstraint 49 50 /*name(validator: { fields, obj, errors -> 51 def error = false 52 53 if (fields) { 54 // Search through all study 55 if (obj.parent.samples.findAll({ it.name == fields}).size() != 1) { 56 errors.rejectValue( 57 'name', 58 'sample.name.NotUnique', 59 ['name',fields] as Object[], 60 'The sample name is not unique within the study' 61 ) 62 } 63 } 64 else { 65 // If no value for name is specified, the sample should not validate 66 error = true 67 } 68 69 return (!error) 70 })*/ 44 71 } 72 73 /*static def getParentStudies() { 74 Study.findAll { 75 it.samples.findAll { 76 it.name == this.name 77 } 78 } 79 }*/ 45 80 46 81 static getSamplesFor( event ) {
Note: See TracChangeset
for help on using the changeset viewer.