Ignore:
Timestamp:
Feb 3, 2010, 6:08:33 PM (10 years ago)
Author:
jahn
Message:

Fixed a bug in save().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/studycapturing/EventController.groovy

    r162 r170  
    6666
    6767
    68     // This action is not complete yet.
    69     // (1) Need to include Sampling events.
    70     // (2) This probably causes orphened PrtocolPrameters that have to be delt with.
    71     // (3) Parts of this might have to be moved into the Domain object's save() method.
    72     // (4) The correspoding view's params are bloated and contain redundancy.
    73     // (5) The whole thing should be moved to update.
    74     // (6) A "create" should be added.
    7568
    7669    def save = {
     
    7871        def event = Event.get(params["id"])
    7972
    80 
    81         if( event==null ) {                         // this is an entirely new event
     73        if( event==null ) {                                                        // this is an entirely new event
    8274            render(action: "list", total:Event.count() )
    8375        }
    8476
    85         params["startTime"] = parseDate(params["startTime"])     // parse the date strings
     77        params["startTime"] = parseDate(params["startTime"])                       // parse the date strings
    8678        params["endTime"] = parseDate(params["endTime"])
    8779
     
    9385        def protocolParameters = params["protocolParameter"]
    9486
    95 
    96         if(oldProtocol<=>newProtocol) {                                             // protocol id changed
     87        println "\n\nparams"
     88        params.each{ println it }
     89
     90        if(oldProtocol<=>newProtocol) {                                            // protocol id changed
    9791            event.eventDescription=EventDescription.get(newProtocol)
    9892            event.parameterStringValues.clear()                                    // this does not propagate orphened parameters
    9993            def protocol=Protocol.get(newProtocol)
    10094            protocolParameters.each{ key, value ->
    101                  def parameter=ProtocolParameter.get(key)
    102                  event.parameterStringValues[key] = value
     95                 def parameter=ProtocolParameter.get(key).name
     96                 event.parameterStringValues[parameter] = value
    10397            }
     98            println event.parameterStringValues
     99            event.eventDescription.protocol=protocol
    104100        }
    105101        else                                                                       // protocol is the same, values changed
     
    107103            protocolParameters.each{ key, value ->
    108104                 def parameter=ProtocolParameter.get(key)
    109                  event.parameterStringValues[key]=value
     105                 event.parameterStringValues[parameter.name]=value                 // changed from key to id
    110106            }
    111107
    112108        }
    113109
    114         println "parameterStringValues: " + event.parameterStringValues
    115 
    116         println "Old Protocol: " + event.eventDescription.protocol.id
    117         println "New Protocol: " + params["protocol.id"]
    118 
    119 
    120         println "Old: "
    121         println event.parameterStringValues.each {
    122                 k,v -> println "${k}: ${v}\n"
    123         }
    124 
    125         println "New:"
    126         protocolParameters.each{
    127                 k,v -> println "${k}: ${v}\n"
    128         }
    129110
    130111        if (event.save(flush: true)) {
     
    171152
    172153
     154
     155    // This action is not complete yet.
     156    // (1) Need to include SamplingEvents.
     157    // (2) This probably causes orphened PrtocolPrameters that have to be delt with.
     158    //     The orphanes have to be managed centrally with the Protocols.
     159    // (3) Parts of this might have to be moved into the Domain object's save() method.
     160    // (4) The correspoding view's params are bloated and contain redundancy.
     161    // (5) The whole thing should be moved to update.
     162    // (6) A "create" should be added.
    173163
    174164    def edit = {
     
    223213    }
    224214
     215
    225216    def delete = {
    226217        def eventInstance = Event.get(params.id)
Note: See TracChangeset for help on using the changeset viewer.