Changeset 812 for trunk/grails-app/domain
- Timestamp:
- Aug 16, 2010, 6:04:00 PM (10 years ago)
- Location:
- trunk/grails-app/domain/dbnp/studycapturing
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy
r784 r812 12 12 13 13 // A Sample always belongs to one study. 14 static belongsTo = [parent : Study ]14 static belongsTo = [parent : Study, parentSubject : Subject, parentEvent : SamplingEvent] 15 15 16 16 // A Sample optionally has a parent Subject from which it was taken, this Subject should be in the same parent study. 17 SubjectparentSubject17 //long parentSubject 18 18 19 19 // Also, it has a parent SamplingEvent describing the actual sampling, also within the same parent study. 20 SamplingEvent parentEvent 20 // Strange enough, we need to define parentEvent as a long here, otherwise the SamplingEvent gets serialized into the database (?!!) 21 //long parentEvent 21 22 22 23 String name // should be unique with respect to the parent study (which can be inferred) -
trunk/grails-app/domain/dbnp/studycapturing/SamplingEvent.groovy
r803 r812 89 89 return samples == null ? [] : samples 90 90 } 91 92 def String toString() { 93 return fieldExists('Description') ? getFieldValue('Description') : "" 94 } 95 91 96 } -
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r811 r812 237 237 } 238 238 239 // remove event from the study 239 // Delete the samples that have this sampling event as parent 240 this.samples.findAll { it.parentEvent.equals(samplingEvent) }.each { 241 // This should remove the sample itself too, because of the cascading belongsTo relation 242 this.removeFromSamples(it) 243 // But apparently it needs an explicit delete() too 244 it.delete() 245 msg += ", sample '${it.name}' was deleted" 246 } 247 248 // Remove event from the study 249 // This should remove the event group itself too, because of the cascading belongsTo relation 240 250 this.removeFromSamplingEvents(samplingEvent) 251 // But apparently it needs an explicit delete() too 252 // (Which can be verified by outcommenting this line, then SampleTests.testDeleteViaParentSamplingEvent fails 253 samplingEvent.delete() 241 254 242 255 return msg … … 300 313 // ------- 301 314 302 println ".removing sample '${it.name}' from study '${this. name}'"315 println ".removing sample '${it.name}' from study '${this.title}'" 303 316 msg += ", sample '${it.name}' was deleted" 304 317 this.removeFromSamples( it ) … … 321 334 322 335 // remove the eventGroup from the study 323 println ".remove eventGroup '${eventGroup.name}' from study '${this. name}'"336 println ".remove eventGroup '${eventGroup.name}' from study '${this.title}'" 324 337 this.removeFromEventGroups(eventGroup) 325 338
Note: See TracChangeset
for help on using the changeset viewer.