Ignore:
Timestamp:
May 12, 2010, 11:48:05 AM (9 years ago)
Author:
duh
Message:
  • removed a domain field did not work properly (example: setting as startdate resulted in an error as that string was not typecasted to a date instance) --> now handeled correctly
File:
1 edited

Legend:

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

    r410 r413  
    353353                // Set the field value
    354354                if (isDomainField(field)) {
    355                         this[field.name] = value
    356                 }
    357                 else {
     355                        if (!value) {
     356                                println "removing [" + ((super) ? super.class : '??') + "] domain field: [" + fieldName + "]"
     357
     358                                // remove value
     359                                this[field.name] = null
     360                        } else {
     361                                println "setting [" + ((super) ? super.class : '??') + "] domain field: [" + fieldName + "] ([" + value.toString() + "] of type [" + value.class + "])"
     362
     363                                // set value
     364                                this[field.name] = value
     365                        }
     366                } else {
    358367                        // Caution: this assumes that all template...Field Maps are already initialized (as is done now above as [:])
    359368                        // If that is ever changed, the results are pretty much unpredictable (random Java object pointers?)!
    360369                        def store = getStore(field.type)
    361370                        if (!value && store[fieldName]) {
    362                                 println "removing " + ((super) ? super.class : '??') + " template field: " + fieldName
     371                                println "removing [" + ((super) ? super.class : '??') + "] template field: [" + fieldName + "]"
    363372
    364373                                // remove the item from the Map (if present)
    365374                                store.remove(fieldName)
    366375                        } else if (value) {
    367                                 println "setting " + ((super) ? super.class : '??') + " template field: " + fieldName + " ([" + value.toString() + "] of type [" + value.class + "])"
     376                                println "setting [" + ((super) ? super.class : '??') + "] template field: [" + fieldName + "] ([" + value.toString() + "] of type [" + value.class + "])"
    368377
    369378                                // set value
     
    375384        }
    376385
     386        /**
     387         * Check if a given field is a domain field
     388         * @param field
     389         * @return boolean
     390         */
    377391        boolean isDomainField(TemplateField field) {
    378392                return this.giveDomainFields()*.name.contains(field.name)
Note: See TracChangeset for help on using the changeset viewer.