Ignore:
Timestamp:
Jan 28, 2010, 6:42:30 PM (9 years ago)
Author:
keesvb
Message:

added helper functions to Subject and Template classes to easily get the template fields, and added a demonstration of use in the sandbox

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/domain/dbnp/studycapturing/Template.groovy

    r140 r146  
    1212 */
    1313class Template implements Serializable {
    14     String name
    15     //nimble.User owner
     14        String name
     15        //nimble.User owner
    1616
    17     static hasMany = [subjectFields : TemplateSubjectField]
    18  
    19     static constraints = {
    20         name(unique:true)
    21     }
     17        static hasMany = [subjectFields: TemplateSubjectField]
    2218
    23     def String toString() {
    24         return this.name;
    25     }
     19        static constraints = {
     20                name(unique: true)
     21        }
     22
     23        def String toString() {
     24                return this.name;
     25        }
     26
     27        /**
     28         * Look up the type of a certain template subject field
     29         * @param fieldName The name of the template field
     30         * @return The type (static member of TemplateFieldType) of the field, or null of the field does not exist
     31         */
     32        def TemplateFieldType getSubjectFieldType(String fieldName) {
     33                def field = subjectFields.find {
     34                        it.name == fieldName   
     35                }
     36                field?.type
     37        }
    2638}
Note: See TracChangeset for help on using the changeset viewer.