Changeset 861
- Timestamp:
- Aug 30, 2010, 3:45:44 PM (11 years ago)
- Location:
- trunk/grails-app/domain/dbnp/studycapturing
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy
r822 r861 62 62 // This feature is tested by integration test SampleTests.testSampleUniqueNameConstraint 63 63 name(unique:['parent']) 64 65 // Same, but also when the other sample is not even in the database 66 // This feature is tested by integration test SampleTests.testSampleUniqueNameConstraintAtValidate 67 name(validator: { field, obj, errors -> 68 // 'obj' refers to the actual Sample object 69 70 // define a boolean 71 def error = false 72 73 if (obj.parent) { 74 75 // check if there is exactly one sample with this name in the study (this one) 76 if (obj.parent.samples.findAll{ it.name == obj.name}.size() > 1) { 77 error = true 78 errors.rejectValue( 79 'name', 80 'sample.UniqueNameViolation', 81 [obj.name, obj.parent] as Object[], 82 'Sample name {0} appears multiple times in study {1}' 83 ) 84 } 85 } 86 else { 87 // if there is no parent study defined, fail immediately 88 error = true 89 } 90 91 // got an error, or not? 92 return (!error) 93 }) 64 94 } 65 95 -
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r857 r861 82 82 */ 83 83 def String toString() { 84 return title84 return code + " - " + title 85 85 } 86 86
Note: See TracChangeset
for help on using the changeset viewer.