Changeset 805 for trunk/grails-app/domain
- Timestamp:
- Aug 12, 2010, 5:50:54 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r796 r805 242 242 return msg 243 243 } 244 244 245 /** 245 246 * Delete an eventGroup from the study, including all its relations … … 248 249 */ 249 250 String deleteEventGroup(EventGroup eventGroup) { 251 // TODO THIS DOESNT WORK!!!! 252 println "-" 253 println "-" 254 println "-" 255 println "-" 256 println "-" 257 println "REMOVING AND ENENTGROUP DOES NOT DELETE SAMPLES" 258 println "-" 259 println "-" 260 println "-" 261 println "-" 262 println "-" 263 264 265 250 266 String msg = "EventGroup ${eventGroup} was deleted" 267 268 // remove all samples that originate from this eventGroup 269 if (eventGroup.samplingEvents.size()) { 270 // find all samples related to this eventGroup 271 // - subject comparison is relatively straightforward and 272 // behaves as expected 273 // - event comparison behaves strange, so now we compare 274 // 1. database id's or, 275 // 2. object identifiers or, 276 // 3. objects itself 277 // this seems now to work as expected 278 this.samples.findAll { sample -> 279 ( 280 (eventGroup.subjects.findAll { 281 it.equals(sample.parentSubject) 282 }) 283 && 284 (eventGroup.samplingEvents.findAll { 285 ( 286 (it.id && sample.parentEvent.id && it.id==sample.parentEvent.id) 287 || 288 (it.getIdentifier() == sample.parentEvent.getIdentifier()) 289 || 290 it.equals(sample.parentEvent) 291 ) 292 }) 293 ) 294 }.each() { 295 // remove sample from study 296 println ".removing sample "+it 297 this.removeFromSamples( it ) 298 } 299 } 300 301 // remove all samplingEvents from this eventGroup 302 eventGroup.samplingEvents.findAll{}.each() { eventGroup.removeFromSamplingEvents(it) } 303 304 // remove all subject from this eventGroup 305 eventGroup.subjects.findAll{}.each() { eventGroup.removeFromSubjects(it) } 251 306 252 307 // remove the eventGroup from the study
Note: See TracChangeset
for help on using the changeset viewer.