Changeset 883
- Timestamp:
- Sep 9, 2010, 4:57:23 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/Template.groovy
r796 r883 72 72 // TODO: this probably has to change in the case of private templates of different users, 73 73 // which can co-exist with the same name. See also TemplateField 74 // name(unique:['entity']) 74 // name(unique:['entity']) 75 // workaround: 76 name(validator: { value, obj, errors -> 77 // 'obj' refers to the actual Template object 78 79 // define a boolean 80 boolean error = false 81 82 if (value && obj.entity) { 83 84 // gather all Cars with this particular model 85 def entityTemplates = Template.findAllByEntity(obj.entity) 86 87 // check if there is already a Template object with this name in that collection 88 if (entityTemplates.findAll{it.name.equals(value)}.size() > 0) { 89 errors.rejectValue( 90 'name', 91 'template.UniqueNameViolation', 92 [value, obj.entity] as Object[], 93 'There already exists a template named {0} for entity {1}' 94 ) 95 error = true 96 } 97 } 98 else { 99 // if there is no name or model defined, fail immediately 100 error = true 101 } 102 // got an error, or not? 103 if (error) return false 104 }) 105 75 106 } 76 107
Note: See TracChangeset
for help on using the changeset viewer.