- Timestamp:
- May 4, 2010, 5:03:21 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/TemplateEntity.groovy
r390 r392 14 14 abstract class TemplateEntity implements Serializable { 15 15 Template template 16 static List systemFields17 16 Map templateStringFields = [:] 18 17 Map templateTextFields = [:] … … 253 252 254 253 /** 255 * Find a template field by its name and return its value for this entity256 * @param fieldName The name of the template field254 * Find a domain or template field by its name and return its value for this entity 255 * @param fieldName The name of the domain or template field 257 256 * @return the value of the field (class depends on the field type) 258 257 * @throws NoSuchFieldException If the field is not found or the field type is not supported 259 258 */ 260 259 def getFieldValue(String fieldName) { 261 TemplateFieldType fieldType = template.getFieldType(fieldName) 262 if (!fieldType) throw new NoSuchFieldException("Field name ${fieldName} not recognized") 263 getStore(fieldType)[fieldName] 260 if (this.properties.containsKey(fieldName)) { 261 return this[fieldName] 262 } 263 else { 264 TemplateFieldType fieldType = template.getFieldType(fieldName) 265 if (!fieldType) throw new NoSuchFieldException("Field name ${fieldName} not recognized") 266 return getStore(fieldType)[fieldName] 267 } 264 268 } 265 269 … … 375 379 376 380 /** 381 * Return all fields defined in the underlying template and the built-in 382 * domain fields of this entity 383 */ 384 def List<TemplateField> giveFields() { 385 return this.giveDomainFields() + this.giveTemplateFields(); 386 } 387 388 /** 377 389 * Return all templated fields defined in the underlying template of this entity 378 390 */ 379 def List<TemplateField> give Fields() {391 def List<TemplateField> giveTemplateFields() { 380 392 return this.template.fields; 381 393 } 382 394 383 def List<TemplateField> giveSystemFields() {384 return systemFields;385 }386 387 388 395 /** 389 396 * Return all relevant 'built-in' domain fields of the super class 390 * @return key-value pairs describing the built-in fields, with the names as keys and type (as TemplateFieldType) as values 397 * @return List with DomainTemplateFields 398 * @see TemplateField 391 399 */ 392 abstract Map giveDomainFields() 400 abstract List<TemplateField> giveDomainFields() 401 393 402 /*def giveDomainFields() { 394 403 def fieldSet = [:];
Note: See TracChangeset
for help on using the changeset viewer.