Skip to content

Commit aa918ab

Browse files
cmdcolinclaude
andcommitted
Fix deleteOrganismFeatures: use REQUIRES_NEW propagation in service methods
The controller class has @transactional(readOnly=true). Service methods with default PROPAGATION_REQUIRED join the read-only transaction, making delete() calls silently ignored. Using REQUIRES_NEW forces a writable transaction. Also: - Use preferenceService.getOrganismForTokenInDB for consistent organism lookup - Add debug logging to trace deletion flow - Fix response.status ordering (before render) in error handler Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 3f8569f commit aa918ab

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

grails-app/controllers/org/bbop/apollo/OrganismController.groovy

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ class OrganismController {
167167
render responseObject as JSON
168168
}
169169

170-
@Transactional
171170
def deleteOrganismFeatures() {
172171
JSONObject organismJson = permissionService.handleInput(request, params)
172+
log.info "deleteOrganismFeatures called with organism: ${organismJson.organism}"
173173
try {
174174
permissionService.hasPermissions(organismJson,PermissionEnum.READ)
175175
if ( !permissionService.hasGlobalPermissions(organismJson, PermissionEnum.ADMINISTRATE)
@@ -188,13 +188,15 @@ class OrganismController {
188188
throw new Exception("Can not find organism for ${organismJson.organism} to remove features of")
189189
}
190190

191+
log.info "Found organism: ${organism.commonName} (id=${organism.id})"
192+
191193
if (organismJson.sequences) {
192194
List<String> sequenceNames = organismJson.sequences.toString().split(",")
193195
List<Sequence> sequences = Sequence.findAllByOrganismAndNameInList(organism, sequenceNames)
194-
int deleted = organismService.deleteAllFeaturesForSequences(sequences)
196+
def deleted = organismService.deleteAllFeaturesForSequences(sequences)
195197
log.info "Deleted ${deleted} features for sequences ${sequenceNames} of organism ${organism.commonName}"
196198
} else {
197-
int deleted = organismService.deleteAllFeaturesForOrganism(organism)
199+
def deleted = organismService.deleteAllFeaturesForOrganism(organism)
198200
log.info "Deleted ${deleted} features for organism ${organism.commonName}"
199201
}
200202

grails-app/services/org/bbop/apollo/OrganismService.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.bbop.apollo
22

33
import grails.gorm.transactions.Transactional
44
import groovy.io.FileType
5+
import org.springframework.transaction.annotation.Propagation
56
import org.bbop.apollo.gwt.shared.FeatureStringEnum
67
import org.bbop.apollo.sequence.SequenceTranslationHandler
78
import org.bbop.apollo.sequence.TranslationTable
@@ -42,6 +43,7 @@ class OrganismService {
4243
return null
4344

4445
}
46+
@Transactional(propagation = Propagation.REQUIRES_NEW)
4547
def deleteAllFeaturesForSequences(List<Sequence> sequences) {
4648

4749
int totalDeleted = 0
@@ -98,6 +100,7 @@ class OrganismService {
98100
return totalDeleted
99101

100102
}
103+
@Transactional(propagation = Propagation.REQUIRES_NEW)
101104
def deleteAllFeaturesForOrganism(Organism organism) {
102105

103106
int totalDeleted = 0

0 commit comments

Comments
 (0)