From f02424082c6790c8496c02f4b94e5d4d25a33435 Mon Sep 17 00:00:00 2001 From: William Welling Date: Mon, 22 Jan 2024 08:25:04 -0600 Subject: [PATCH] Rollback remove field profile on constraint violation exception This prevents the orphaned submission list column from field profile to exist when the field profile is deleted. --- .../org/tdl/vireo/controller/WorkflowStepController.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/tdl/vireo/controller/WorkflowStepController.java b/src/main/java/org/tdl/vireo/controller/WorkflowStepController.java index ea20e863d..3d8eb233d 100644 --- a/src/main/java/org/tdl/vireo/controller/WorkflowStepController.java +++ b/src/main/java/org/tdl/vireo/controller/WorkflowStepController.java @@ -13,6 +13,10 @@ import edu.tamu.weaver.validation.aspect.annotation.WeaverValidatedModel; import edu.tamu.weaver.validation.aspect.annotation.WeaverValidation; import java.util.Optional; + +import javax.transaction.Transactional; + +import org.hibernate.exception.ConstraintViolationException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.PathVariable; @@ -130,6 +134,7 @@ public ApiResponse removeFieldProfile(@PathVariable Long requestingOrgId, @PathV @PostMapping(value = "/{requestingOrgId}/{workflowStepId}/remove-field-profile/{fieldProfileId}") @PreAuthorize("hasRole('MANAGER')") + @Transactional(rollbackOn = ConstraintViolationException.class) public ApiResponse removeFieldProfileById(@PathVariable Long requestingOrgId, @PathVariable Long workflowStepId, @PathVariable Long fieldProfileId) throws WorkflowStepNonOverrideableException, HeritableModelNonOverrideableException, ComponentNotPresentOnOrgException { Optional organization = organizationRepo.findById(requestingOrgId);