Changeset 689 for trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy
- Timestamp:
- Jul 21, 2010, 4:52:12 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy
r667 r689 2 2 3 3 import dbnp.data.Term 4 import dbnp.data.Ontology5 4 6 5 /** … … 44 43 material(nullable: true) 45 44 46 // TODO: Write a validation method that checks if the externalSampleId (currently defined as name) 47 // is really unique within each parent study of this sample. 48 // Maybe this could also be a constraint, but we might run into trouble creating new Sample objects in e.g. the create wizard. 49 // To be checked. 45 // Checks if the externalSampleId (currently defined as name) is really unique within each parent study of this sample. 50 46 // This feature is tested by integration test SampleTests.testSampleUniqueNameConstraint 51 52 /*name(validator: { fields, obj, errors -> 53 def error = false 54 55 if (fields) { 56 // Search through all study 57 if (obj.parent.samples.findAll({ it.name == fields}).size() != 1) { 58 errors.rejectValue( 59 'name', 60 'sample.name.NotUnique', 61 ['name',fields] as Object[], 62 'The sample name is not unique within the study' 63 ) 64 } 65 } 66 else { 67 // If no value for name is specified, the sample should not validate 68 error = true 69 } 70 71 return (!error) 72 })*/ 47 name(unique:['parent']) 73 48 } 74 75 /*static def getParentStudies() {76 Study.findAll {77 it.samples.findAll {78 it.name == this.name79 }80 }81 }*/82 49 83 50 static getSamplesFor( event ) {
Note: See TracChangeset
for help on using the changeset viewer.