Changeset 176


Ignore:
Timestamp:
Feb 8, 2010, 12:42:46 PM (9 years ago)
Author:
keesvb
Message:

added first version of importer data model, added helper methods to domain class for getting all entity fields, added study template fields

Location:
trunk/grails-app
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/SandboxController.groovy

    r162 r176  
    1111                def f = st.template.subjectFields
    1212
     13                //println st.giveAllFields()
     14
    1315                // This is a way to iterate over the fields in your controller
    1416                // And print them to the console
     
    2224                def subject = Subject.findByName('A1')
    2325                println st.template.getSubjectFieldType('Age')
    24                 println subject.getFieldValue('Age')
    25 
    26 
     26                println subject.getFieldValue('Genotype')
     27                subject.setFieldValue('Genotype','wildtype')
     28                println subject.getFieldValue('Genotype')
     29                subject.setFieldValue('name','hallo')
     30                println subject.name
     31               
    2732                // Specify which variables we want to be available in the controller (implicit return statement)
    2833                [fields: f, subjects: st.subjects]
  • trunk/grails-app/domain/dbnp/studycapturing/Study.groovy

    r162 r176  
    4545                return title;
    4646        }
     47
     48        Map giveAllFields() {
     49                def result = [:]
     50
     51                // Using reflection here gives way too many properties, like searchable, hasMany,
     52                // and it will probably extend when we use new plugins
     53                // It is probably best
     54                // - to either hardcode the above given properties
     55                // - or to move all fields to the template
     56               
     57                this.properties.each{ //public fields only
     58                        println it.name
     59                        result[it.name] = it.type.name //name of field and name of type
     60                }
     61
     62                return result;
     63        }
    4764}
  • trunk/grails-app/domain/dbnp/studycapturing/Subject.groovy

    r162 r176  
    5353                }
    5454        }
     55
     56        def setFieldValue(String fieldName, value) {
     57                this.properties.each { println it}
     58                if (this.properties.containsKey(fieldName)) {
     59                        this[fieldName] = value
     60                }
     61                else if (templateStringFields.containsKey(fieldName) && value.class == String) {
     62                        this.templateStringFields[fieldName] = value
     63                }
     64                else {
     65                        println "Field ${fieldName} not found"
     66                }
     67        }
    5568}
  • trunk/grails-app/domain/dbnp/studycapturing/Template.groovy

    r162 r176  
    1515        //nimble.User owner
    1616
    17         static hasMany = [subjectFields: TemplateSubjectField]
     17        static hasMany = [studyFields: TemplateStudyField, subjectFields: TemplateSubjectField]
    1818
    1919        static constraints = {
  • trunk/grails-app/domain/dbnp/studycapturing/TemplateField.groovy

    r162 r176  
    2121        }
    2222
    23         def String toString() {
     23        String toString() {
    2424                return name
    2525        }
Note: See TracChangeset for help on using the changeset viewer.