Changeset 774 for trunk/grails-app/domain
- Timestamp:
- Aug 4, 2010, 4:12:38 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r754 r774 136 136 return this.template 137 137 } 138 139 140 /** 141 * Delete a specific subject from this study, including all its relations 142 * @param subject The subject to be deleted 143 * @return A String which contains a (user-readable) message describing the changes to the database 144 */ 145 String deleteSubject(Subject subject) { 146 147 String msg = "Subject ${subject.name} was deleted" 148 149 // Delete the subject from the event groups it was referenced in 150 this.eventGroups.each { 151 if (it.subjects.contains(subject)) { 152 it.removeFromSubjects(subject) 153 msg += ", deleted from event group '${it.name}'" 154 } 155 } 156 157 // Delete the samples that have this subject as parent 158 this.samples.findAll { it.parentSubject.equals(subject) }.each { 159 // This should remove the sample itself too, because of the cascading belongsTo relation 160 this.removeFromSamples(it) 161 // But apparently it needs an explicit delete() too 162 it.delete() 163 msg += ", sample '${it.name}' was deleted" 164 } 165 166 // This should remove the subject itself too, because of the cascading belongsTo relation 167 this.removeFromSubjects(subject) 168 // But apparently it needs an explicit delete() too 169 subject.delete() 170 171 return msg 172 } 138 173 }
Note: See TracChangeset
for help on using the changeset viewer.