Skip to content

Commit

Permalink
Rollback remove field profile on constraint violation exception
Browse files Browse the repository at this point in the history
This prevents the orphaned submission list column from field profile to exist when the field profile is deleted.
  • Loading branch information
wwelling committed Jan 22, 2024
1 parent 3d959cc commit f024240
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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> organization = organizationRepo.findById(requestingOrgId);

Expand Down

0 comments on commit f024240

Please sign in to comment.