Changeset 150 for trunk/grails-app/controllers/dbnp/studycapturing
- Timestamp:
- Jan 29, 2010, 6:08:49 PM (13 years ago)
- Location:
- trunk/grails-app/controllers/dbnp/studycapturing
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/studycapturing/EventController.groovy
r123 r150 2 2 import java.text.SimpleDateFormat 3 3 import dbnp.data.Term 4 import dbnp.data.Ontology 4 5 5 6 class EventController { … … 25 26 26 27 def createForEventDescription = { 27 28 28 if( params["id"]==null) 29 29 { … … 50 50 // Output format: "01/20/2010 20:45" 51 51 // Note: the "am" amd "pm" suffixes are removed. 52 53 52 def parseDate = { st -> 54 53 def subst = st.substring(0,16) … … 69 68 def save = { 70 69 println "In EventController.save: ${params}" 71 72 70 params["startTime"] = parseDate(params["startTime"]) // parse the date strings 73 71 params["endTime"] = parseDate(params["endTime"]) … … 139 137 def eDate = new Date( params["endTime"]) 140 138 def description = EventDescription.findById((params["eventDescription"])["id"]) 141 return [ testo:params.clone(), sDate:sDate, eDate:eDate, description:description ]139 return [eventInstance:eventInstance, testo:params.clone(), sDate:sDate, eDate:eDate, description:description ] 142 140 } 143 141 … … 149 147 redirect(action: "list") 150 148 } 151 return [testo:params.clone(), sDate:eventInstance.startTime, eDate:eventInstance.endTime, description:eventInstance.eventDescription] 152 } 153 154 } 155 156 149 return [eventInstance:eventInstance, testo:params.clone(), sDate:eventInstance.startTime, eDate:eventInstance.endTime, description:eventInstance.eventDescription] 150 } 151 152 } 157 153 158 154 … … 204 200 } 205 201 206 207 208 def createDummies = { 209 210 ["ONE","TWO"].each{ x -> println x } 211 def t = new Term() 212 t.name = "homo politicus russicus" 213 t.ontology = "Ontology: Monkies and Typewriters" 214 t.accession = "up or down" 215 t.save() 216 217 def pp = new ProtocolParameter() 218 pp.name = "LSD reatment" 219 pp.unit = "Tt" 220 pp.description = "feed the LSD to the subject" 221 pp.reference = t 222 pp.type = "String" // should become ProtocolParameterType at some point 223 pp.save() 224 225 def p = new Protocol() 226 p.name = "Hugo (dummy #1)" 227 p.reference = t 228 p.save() 229 p.addToParameters(pp) 230 231 def ppi = new ProtocolParameterInstance() 232 ppi.value = "1.2" 233 ppi.protocolParameter = pp 234 ppi.save() 235 236 def ppi2 = new ProtocolParameterInstance() 237 ppi2.value = "23.5" 238 ppi2.protocolParameter = pp 239 ppi2.save() 240 241 def pi = new ProtocolInstance() 242 pi.protocol = p.find("from Protocol p ") 243 pi.save() 244 pi.addToValues(ppi) 245 pi.addToValues(ppi2) 246 247 def s= new Subject() 248 s.name = "Vladimir Putin" 249 s.species = t 250 s.save() 251 252 def ed = new EventDescription() 253 ed.name = "dummmy name" 254 ed.description = "dummmy description" 255 ed.protocol = pi 256 ed.classification = Term.find("from Term t") 257 ed.save() 258 259 def sdfh = new SimpleDateFormat("dd/MM/yyyy hh:mm") 260 def eventInstance = new Event() 261 def someDate = sdfh.parse("29/11/2008 18:00") 262 eventInstance.subject = s 263 eventInstance.eventDescription= ed 264 eventInstance.startTime = someDate 265 eventInstance.endTime = someDate 266 if( eventInstance.save() ) 267 { redirect( action:show, id: eventInstance.id ) } 268 else { chain( action:list ) } 269 270 271 272 } 202 def showMySample = { 203 render( view:"showMySample" ) 204 } 205 206 273 207 } -
trunk/grails-app/controllers/dbnp/studycapturing/EventDescriptionController.groovy
r123 r150 47 47 48 48 def showMyProtocol = { 49 println params // dbg, remove 49 50 50 def protocol = ( params.protocol ) ? Protocol.get(params.protocol) : Protocol.find("for Protocol id")51 def description = EventDescription.get(params.id)52 def protocolInstance = description.protocol51 def protocol = ( params.protocolid) ? Protocol.get(params.protocolid) : Protocol.find("for Protocol id") 52 def event = Event.get(params.id) 53 def protocolInstance = event.eventDescription.protocol 53 54 54 55 println params 56 println event 55 57 println protocol 56 println description57 58 println protocolInstance 58 59 59 60 if( protocol.id==protocolInstance.protocol.id ) { 61 println "redner this FILLED rubish" 62 println protocolInstance 63 println "the fuck?" 64 render( view:"showMyProtocolFilled", model:["protocolInstance":protocolInstance] ) 60 if( protocolInstance && protocolInstance && protocol.id==protocolInstance.id ) { 61 def parameterStringValues = event.parameterStringValues 62 println parameterStringValues 63 print "showFull" 64 render( view:"showMyProtocolFilled", model:["protocolInstance":protocolInstance,"event":event,"parameterStringValues":parameterStringValues] ) 65 65 } 66 66 else { 67 print ln "redner this EMPTY rubish"68 render( view: "showMyProtocolEmpty", model:[protocol:protocol] )69 //render( view:"showMyProtocolEmpty", model:[protocol:protocol])67 print "showEmpty" 68 if(protocol!=null) render( view: "showMyProtocolEmpty", model:["protocolInstance":protocol] ) 69 else render( "NULL" ) 70 70 } 71 71 } … … 131 131 132 132 133 /* Jahn - For development only 134 * Create one dummy instance of EventDescription */ 135 def createDummies = 136 { 137 def newInstance = new EventDescription() 138 newInstance.name = "dummmy name" 139 newInstance.description = "dummmy description" 140 newInstance.protocol = ProtocolInstance.find("from ProtocolInstance p ") 141 newInstance.classification = Term.find("from Term t") 142 143 if( newInstance.save() ) 144 { redirect( action:show, id: newInstance.id ) } 145 else { chain( action:list ) } 146 } 147 148 149 def test = { render("test") } 133 def test = { println "test" 134 render("test") } 150 135 }
Note: See TracChangeset
for help on using the changeset viewer.