Changeset 228 for trunk/grails-app/domain
- Timestamp:
- Mar 3, 2010, 12:17:06 PM (13 years ago)
- Location:
- trunk/grails-app/domain/dbnp/studycapturing
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r224 r228 50 50 } 51 51 52 /** 53 * Returns the template of all subjects in the study 54 * Throws an error if there are no or multiple subject templates 55 */ 56 def Template giveSubjectTemplate() { 57 TemplateEntity.giveTemplate(subjects); 58 } 59 60 /** 61 * Returns the template of all samples in the study 62 * Throws an error if there are no or multiple sample templates 63 */ 64 def Template giveSampleTemplate() { 65 TemplateEntity.giveTemplate(samples); 66 } 67 /** 68 * Returns the template of the study 69 */ 70 def Template giveStudyTemplate() { 71 return this.template; 72 } 52 73 } -
trunk/grails-app/domain/dbnp/studycapturing/TemplateEntity.groovy
r224 r228 27 27 28 28 static constraints = { 29 template(nullable: true) 29 30 } 30 31 … … 71 72 } 72 73 if (templateStringListFields.containsKey(fieldName) && value.class == TemplateFieldListItem) { 74 // TODO: check if item really belongs to the list under fieldName 73 75 this.templateStringFields[fieldName] = value 74 76 } … … 119 121 } 120 122 123 /** 124 * Convenience method. Returns all unique templates within a collection of TemplateEntities. 125 */ 126 static List<Template> giveTemplates(Set<TemplateEntity> entityCollection) { 127 return entityCollection*.template.unique(); 128 } 129 130 static Template giveTemplate(Set<TemplateEntity> entityCollection) { 131 def templates = giveTemplates(entityCollection); 132 if (templates.size() == 0) { 133 throw new NoSuchFieldException("No templates found in collection!") 134 } 135 else if (templates.size() == 1) { 136 return templates[0]; 137 } 138 else { 139 throw new NoSuchFieldException("Multiple templates found in collection!") 140 } 141 } 142 121 143 } -
trunk/grails-app/domain/dbnp/studycapturing/TemplateFieldListItem.groovy
r225 r228 7 7 static constraints = { 8 8 } 9 10 String toString() { 11 return name; 12 } 9 13 }
Note: See TracChangeset
for help on using the changeset viewer.