Changeset 232
- Timestamp:
- Mar 3, 2010, 5:18:22 PM (8 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BootStrap.groovy
r230 r232 68 68 ).with { if (!validate()) { errors.each { println it} } else save()} 69 69 70 def treatmentProtocol = new Protocol( 71 name: 'MADMAX Experimental Protocol', 70 def dietProtocol = new Protocol( 71 name: 'Diet treatment Protocol NuGO PPS3 leptin module', 72 reference: treatmentTerm 73 ).with { if (!validate()) { errors.each { println it} } else save()} 74 75 def boostProtocol = new Protocol( 76 name: 'Boost treatment Protocol NuGO PPS3 leptin module', 72 77 reference: treatmentTerm 73 78 ).with { if (!validate()) { errors.each { println it} } else save()} … … 78 83 ).with { if (!validate()) { errors.each { println it} } else save()} 79 84 80 treatmentProtocol85 dietProtocol 81 86 .addToParameters(new ProtocolParameter( 82 87 name: 'Diet', 83 88 type: ProtocolParameterType.STRINGLIST, 84 89 listEntries: ['10% fat (palm oil)','45% fat (palm oil)'])) 90 .save() 91 92 boostProtocol 85 93 .addToParameters(new ProtocolParameter( 86 94 name: 'Compound', 87 95 type: ProtocolParameterType.STRINGLIST, 88 96 listEntries: ['Vehicle','Leptin'])) 89 .addToParameters(new ProtocolParameter(90 name: 'Administration',91 type: ProtocolParameterType.STRING))92 97 .save() 93 98 … … 134 139 def genderField = new TemplateField( 135 140 name: 'Gender',type: TemplateFieldType.STRINGLIST, 136 listEntries: ['Male','Female']) 137 .with { if (!validate()) { errors.each { println it} } else save()} 141 listEntries: [new TemplateFieldListItem(name:'Male'),new TemplateFieldListItem(name: 'Female')]) 142 .with { if (!validate()) { errors.each { println it} } else save()} 143 138 144 def ageField = new TemplateField( 139 145 name: 'Age',type: TemplateFieldType.INTEGER) 140 146 .with { if (!validate()) { errors.each { println it} } else save()} 147 148 // Nutritional study template 149 150 def studyTemplate = new Template( 151 name: 'Nutritional study', entity: dbnp.studycapturing.Study 152 ).addToFields(new TemplateField( 153 name: 'NuGO Code',type: TemplateFieldType.STRING) 154 ).with { if (!validate()) { errors.each { println it} } else save()} 155 141 156 142 157 // Mouse template … … 145 160 ).addToFields(new TemplateField( 146 161 name: 'Genotype',type: TemplateFieldType.STRINGLIST, 147 listEntries: [ 'C57/Bl6j','wild type']))162 listEntries: [new TemplateFieldListItem(name:'C57/Bl6j'),new TemplateFieldListItem(name:'wild type')])) 148 163 .addToFields(genderField) 149 164 .addToFields(ageField) … … 172 187 173 188 //events 174 def event Treatment = new EventDescription(175 name: ' Treatment',176 description: ' Experimental Treatment Protocol NuGO PPS3 leptin module',189 def eventDiet = new EventDescription( 190 name: 'Diet treatment', 191 description: 'Diet treatment (fat percentage)', 177 192 classification: treatmentTerm, 178 protocol: treatmentProtocol, 193 protocol: dietProtocol, 194 isSamplingEvent: false 195 ).with { if (!validate()) { errors.each { println it} } else save()} 196 197 def eventBoost = new EventDescription( 198 name: 'Boost treatment', 199 description: 'Boost treatment (leptin or vehicle)', 200 classification: treatmentTerm, 201 protocol: boostProtocol, 179 202 isSamplingEvent: false 180 203 ).with { if (!validate()) { errors.each { println it} } else save()} … … 187 210 ).with { if (!validate()) { errors.each { println it} } else save()} 188 211 189 def bloodSamplingEvent = new EventDescription(212 def bloodSamplingEventDescription = new EventDescription( 190 213 name: 'Blood extraction', 191 214 description: 'Blood extraction targeted at lipid assays', … … 206 229 // studies 207 230 def exampleStudy = new Study( 231 template: studyTemplate, 208 232 title:"NuGO PPS3 mouse study leptin module", 209 233 code:"PPS3_leptin_module", … … 214 238 ).with { if (!validate()) { errors.each { println it} } else save()} 215 239 240 def evLF = new Event( 241 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 242 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 243 eventDescription: eventDiet, 244 parameterStringValues: ['Diet':'10% fat (palm oil)'] 245 ).with { if (!validate()) { errors.each { println it} } else save()} 246 247 def evHF = new Event( 248 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 249 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 250 eventDescription: eventDiet, 251 parameterStringValues: ['Diet':'45% fat (palm oil)'] 252 ).with { if (!validate()) { errors.each { println it} } else save()} 253 254 def evBV = new Event( 255 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 256 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 257 eventDescription: eventBoost, 258 parameterStringValues: ['Compound':'Vehicle'] 259 ).with { if (!validate()) { errors.each { println it} } else save()} 260 261 def evBL = new Event( 262 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 263 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 264 eventDescription: eventBoost, 265 parameterStringValues: ['Compound':'Leptin'] 266 ).with { if (!validate()) { errors.each { println it} } else save()} 267 268 def evLF4 = new Event( 269 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 270 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 271 eventDescription: eventDiet, 272 parameterStringValues: ['Diet':'10% fat (palm oil)'] 273 ).with { if (!validate()) { errors.each { println it} } else save()} 274 275 def evHF4 = new Event( 276 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 277 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 278 eventDescription: eventDiet, 279 parameterStringValues: ['Diet':'45% fat (palm oil)'] 280 ).with { if (!validate()) { errors.each { println it} } else save()} 281 282 def evBV4 = new Event( 283 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 284 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 285 eventDescription: eventBoost, 286 parameterStringValues: ['Compound':'Vehicle'] 287 ).with { if (!validate()) { errors.each { println it} } else save()} 288 289 def evBL4 = new Event( 290 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 291 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 292 eventDescription: eventBoost, 293 parameterStringValues: ['Compound':'Leptin'] 294 ).with { if (!validate()) { errors.each { println it} } else save()} 295 296 def evS = new SamplingEvent( 297 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 298 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 299 eventDescription: samplingEvent, 300 parameterFloatValues: ['Sample weight':5F] 301 ).with { if (!validate()) { errors.each { println it} } else save()} 302 303 def evS4 = new SamplingEvent( 304 startTime: Date.parse('yyyy-MM-dd','2008-02-04'), 305 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 306 eventDescription: samplingEvent, 307 parameterFloatValues: ['Sample weight':5F] 308 ).with { if (!validate()) { errors.each { println it} } else save()} 309 310 // Add events to study 311 exampleStudy 312 .addToEvents(evLF) 313 .addToEvents(evHF) 314 .addToEvents(evBV) 315 .addToEvents(evBL) 316 .addToEvents(evLF4) 317 .addToEvents(evHF4) 318 .addToEvents(evBV4) 319 .addToEvents(evBL4) 320 .addToSamplingEvents(evS) 321 .addToSamplingEvents(evS4) 322 .save() 323 324 def LFBV1 = new EventGroup(name:"10% fat + vehicle for 1 week") 325 .addToEvents(evLF) 326 .addToEvents(evBV) 327 .with { if (!validate()) { errors.each { println it} } else save()} 328 329 def LFBL1 = new EventGroup(name:"10% fat + leptin for 1 week") 330 .addToEvents(evLF) 331 .addToEvents(evBL) 332 .with { if (!validate()) { errors.each { println it} } else save()} 333 334 def HFBV1 = new EventGroup(name:"45% fat + vehicle for 1 week") 335 .addToEvents(evHF) 336 .addToEvents(evBV) 337 .with { if (!validate()) { errors.each { println it} } else save()} 338 339 def HFBL1 = new EventGroup(name:"45% fat + leptin for 1 week") 340 .addToEvents(evHF) 341 .addToEvents(evBL) 342 .with { if (!validate()) { errors.each { println it} } else save()} 343 344 def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks") 345 .addToEvents(evLF4) 346 .addToEvents(evBV4) 347 .with { if (!validate()) { errors.each { println it} } else save()} 348 349 def LFBL4 = new EventGroup(name:"10% fat + leptin for 4 weeks") 350 .addToEvents(evLF4) 351 .addToEvents(evBL4) 352 .with { if (!validate()) { errors.each { println it} } else save()} 353 354 def HFBV4 = new EventGroup(name:"45% fat + vehicle for 4 weeks") 355 .addToEvents(evHF4) 356 .addToEvents(evBV4) 357 .with { if (!validate()) { errors.each { println it} } else save()} 358 359 def HFBL4 = new EventGroup(name:"45% fat + leptin for 4 weeks") 360 .addToEvents(evHF4) 361 .addToEvents(evBL4) 362 .with { if (!validate()) { errors.each { println it} } else save()} 363 364 365 216 366 def x=1 217 12.times {367 80.times { 218 368 def currentSubject = new Subject( 219 369 name: "A" + x++, … … 225 375 226 376 exampleStudy.addToSubjects(currentSubject) 227 .addToEvents(new Event(228 subject: currentSubject,229 startTime: Date.parse('yyyy-MM-dd','2008-01-07'),230 endTime: Date.parse('yyyy-MM-dd','2008-01-14'),231 eventDescription: eventTreatment,232 parameterStringValues: ['Diet':'10% fat (palm oil)','Compound':'Vehicle','Administration':'intraperitoneal injection'])233 )234 .addToSamplingEvents(new SamplingEvent(235 subject: currentSubject,236 startTime: Date.parse('yyyy-MM-dd','2008-01-14'),237 endTime: Date.parse('yyyy-MM-dd','2008-01-14'),238 eventDescription: samplingEvent,239 parameterFloatValues: ['Sample weight':5F])240 )241 377 .with { if (!validate()) { errors.each { println it} } else save()} 378 379 // Add subject to appropriate EventGroup 380 if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } 381 else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } 382 else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } 383 else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } 384 else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } 385 else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } 386 else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } 387 else { LFBV1.addToSubjects(currentSubject).save() } 388 242 389 } 243 390 … … 245 392 246 393 def humanStudy = new Study( 394 template: studyTemplate, 247 395 title:"NuGO PPS human study", 248 396 code:"PPSH", … … 252 400 startDate: Date.parse('yyyy-MM-dd','2009-01-01') 253 401 ).with { if (!validate()) { errors.each { println it} } else save()} 402 403 def fastingEvent = new Event( 404 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 405 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 406 eventDescription: fastingTreatment, 407 parameterStringValues: ['Fasting period':'8h']); 408 409 def bloodSamplingEvent = new SamplingEvent( 410 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 411 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 412 eventDescription: bloodSamplingEventDescription, 413 parameterFloatValues: ['Sample volume':4.5F]); 414 415 def rootGroup = new EventGroup(name: 'Root group'); 416 rootGroup.addToEvents fastingEvent 417 rootGroup.addToEvents bloodSamplingEvent 418 rootGroup.save() 254 419 255 420 def y=1 … … 275 440 ).with { if (!validate()) { errors.each { println it} } else save()} 276 441 442 def currentSample = new Sample( 443 name: currentSubject.name + '_B', 444 material: bloodTerm, 445 parentSubject: currentSubject, 446 parentEvent: bloodSamplingEvent); 447 448 rootGroup.addToSubjects currentSubject 449 rootGroup.save() 450 277 451 humanStudy.addToSubjects(currentSubject) 278 .addToEvents(new Event( 279 subject: currentSubject, 280 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 281 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 282 eventDescription: fastingTreatment, 283 parameterStringValues: ['Fasting period':'8h']) 284 ) 285 .addToSamplingEvents(new SamplingEvent( 286 subject: currentSubject, 287 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 288 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 289 eventDescription: bloodSamplingEvent, 290 parameterFloatValues: ['Sample volume':4.5F]) 291 ) 292 .addToSamples(new Sample( 293 name: currentSubject.name + '_B', 294 material: bloodTerm) 295 ) 452 .addToSamples(currentSample) 453 .addToEventGroups rootGroup 296 454 .with { if (!validate()) { errors.each { println it} } else save()} 297 455 } -
trunk/grails-app/domain/dbnp/studycapturing/Event.groovy
r209 r232 14 14 */ 15 15 class Event implements Serializable { 16 Subject subject17 16 EventDescription eventDescription 18 17 Date startTime … … 29 28 30 29 static constraints = { 31 subject(nullable: true, blank: true) // TODO: subject is to be removed from Event, and into EventGroup32 30 startTime(nullable:false) 33 31 endTime(validator: {val, obj -> -
trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy
r224 r232 6 6 * The Sample class describes an actual sample which results from a SamplingEvent. 7 7 */ 8 class Sample {8 class Sample extends TemplateEntity { 9 9 static searchable = true 10 10 11 Subject parentSubject 12 SamplingEvent parentEvent 11 13 14 String name // should be unique with respect to the parent study (which can be inferred) 15 Term material 16 // a member that describes the quantity of the sample? --> should be in the templates 12 17 13 String name // should be unique with respect to the parent study (which can be inferred) 14 Term material 15 // don't we need a member that describes the quantity of the sample? --> should be in the templates 16 17 static constraints = { 18 } 18 static constraints = { 19 } 19 20 20 21 } -
trunk/grails-app/domain/dbnp/studycapturing/SamplingEvent.groovy
r190 r232 5 5 * 6 6 * NOTE: according to documentation, super classes and subclasses share the same table. 7 * thus, there is actually no reason not to merge the sampling with the Event super class.8 * this is especially true, since the subclass adds only one has-many relation ship.7 * thus, we could merge the sampling with the Event super class and include a boolean 8 * However, using a separate class makes it more clear in the code that Event and SamplingEvent are treated differently 9 9 */ 10 10 11 11 class SamplingEvent extends Event { 12 12 13 static hasMany = [samples : Sample]14 15 13 static constraints = { 16 14 } -
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r229 r232 28 28 events: Event, 29 29 samplingEvents: SamplingEvent, 30 eventGroups: EventGroup, 30 31 samples: Sample, 31 32 assays: Assay, -
trunk/grails-app/domain/dbnp/studycapturing/TemplateField.groovy
r224 r232 14 14 String unit 15 15 16 static hasMany = [listEntries : String] // to store the entries to choose from when the type is 'item from predefined list' 17 //TODO: make TemplateFieldListItem and make a convenience setter for a string array 16 static hasMany = [listEntries : TemplateFieldListItem] // to store the entries to choose from when the type is 'item from predefined list' 18 17 19 18 static constraints = { … … 25 24 return name 26 25 } 26 27 //TODO: make a convenience setter for a string array 28 /*def setListEntries(ArrayList entries) { 29 list=[] 30 entries.each { 31 list.add(new TemplateFieldListItem(name: it)) 32 } 33 this 34 }*/ 35 27 36 } -
trunk/grails-app/views/study/show.gsp
r229 r232 233 233 <g:each in="${studyInstance.events}" var="e"> 234 234 <tr> 235 <td> <g:link controller="event" action="edit" id="${e.id}">${e.subject.id}</g:link></td>235 <td>-</td> 236 236 <td>${e.getPrettyDuration(studyInstance.startDate,e.startTime)}</td> 237 237 <td>${e.getPrettyDuration()}</td> … … 249 249 <g:each in="${studyInstance.samplingEvents}" var="e"> 250 250 <tr> 251 <td> <g:link controller="event" action="edit" id="${e.id}">${e.subject.id}</g:link></td>251 <td>-</td> 252 252 <td>${e.getPrettyDuration(studyInstance.startDate,e.startTime)}</td> 253 253 <td>${e.getPrettyDuration()}</td>
Note: See TracChangeset
for help on using the changeset viewer.