Changeset 819
- Timestamp:
- Aug 17, 2010, 3:37:15 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 8 8 [:] 9 9 .settings 10 .skip-studies
-
- Property svn:ignore
-
trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy
r805 r819 318 318 if (!flow.event || (flow.event instanceof Event && type == "sample") || (flow.event instanceof SamplingEvent && type == "event")) { 319 319 // create new instance 320 flow.event = (type == "event") ? new Event(template: template , parent: flow.study) : new SamplingEvent(template: template, parent: flow.study)320 flow.event = (type == "event") ? new Event(template: template) : new SamplingEvent(template: template) 321 321 } else { 322 322 flow.event.template = template … … 351 351 flash.errors = [:] 352 352 353 // add event to study 354 if (flow.event instanceof SamplingEvent) { 355 flow.study.addToSamplingEvents( flow.event ) 356 } else { 357 flow.study.addToEvents( flow.event ) 358 } 359 353 360 // validate event 354 361 if (flow.event.validate()) { 355 // validates properly356 if (flow.event instanceof SamplingEvent) {357 flow.study.addToSamplingEvents( flow.event )358 } else {359 flow.study.addToEvents( flow.event )360 }361 362 362 // remove event from the flowscope 363 363 flow.remove('event') … … 366 366 } else { 367 367 // event does not validate 368 // remove from study 369 if (flow.event instanceof SamplingEvent) { 370 flow.study.removeFromSamplingEvents( flow.event ) 371 } else { 372 flow.study.removeFromEvents( flow.event ) 373 } 374 375 // append errors 368 376 this.appendErrors(flow.event, flash.errors) 369 377 error() … … 406 414 flow.study.addToEventGroups( 407 415 new EventGroup( 408 name : groupName, 409 parent : flow.study 416 name : groupName 410 417 ) 411 418 ) … … 527 534 flow.study.addToSamples( 528 535 new Sample( 529 parent: flow.study,530 536 parentSubject: subject, 531 537 parentEvent: samplingEvent, … … 631 637 // save study 632 638 println ".saving study" 633 if (!flow.study.save( )) {639 if (!flow.study.save(flush:true)) { 634 640 this.appendErrors(flow.study, flash.errors) 635 641 throw new Exception('error saving study') … … 945 951 name : subjectName, 946 952 species : species, 947 template : template, 948 parent : flow.study 953 template : template 949 954 ) 955 956 // add it to the study 957 flow.study.addToSubjects( subject ) 950 958 951 959 // validate subject 952 960 if (subject.validate()) { 953 // add it to the study954 flow.study.addToSubjects( subject )955 961 println ".added subject "+subject 956 962 } else { 957 963 // whoops? 964 flow.study.removeFromSubjects( subject ) 965 966 // append errors 958 967 this.appendErrors(subject, flash.errors) 959 968 errors = true -
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r817 r819 249 249 // This should remove the event group itself too, because of the cascading belongsTo relation 250 250 this.removeFromSamplingEvents(samplingEvent) 251 251 252 // But apparently it needs an explicit delete() too 252 253 // (Which can be verified by outcommenting this line, then SampleTests.testDeleteViaParentSamplingEvent fails … … 262 263 */ 263 264 String deleteEventGroup(EventGroup eventGroup) { 264 // TODO THIS DOESNT WORK!!!!265 println "-"266 println "-"267 println "-"268 println "-"269 println "-"270 println "REMOVING AN EVENTGROUP DOES NOT DELETE SAMPLES"271 println "-"272 println "-"273 println "-"274 println "-"275 println "-"276 277 278 279 265 String msg = "EventGroup ${eventGroup} was deleted" 280 266 … … 318 304 msg += ", sample '${it.name}' was deleted" 319 305 this.removeFromSamples( it ) 306 320 307 // Also here, contrary to documentation, an extra delete() is needed 308 // otherwise date is not properly deleted! 321 309 it.delete() 322 310 } … … 344 332 println ".remove eventGroup '${eventGroup.name}' from study '${this.title}'" 345 333 this.removeFromEventGroups(eventGroup) 334 346 335 // Also here, contrary to documentation, an extra delete() is needed 336 // otherwise cascaded deletes are not properly performed 347 337 eventGroup.delete() 348 338
Note: See TracChangeset
for help on using the changeset viewer.