Merge branch 'RED-7738-bp1' into 'release/1.363.x'
RED-7738: Do not catch database execetions that breaks transactions See merge request redactmanager/persistence-service!173
This commit is contained in:
commit
928b37cb9f
@ -92,7 +92,7 @@ public class AddRedactionPersistenceService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void hardDelete(String fileId, String annotationId) {
|
public void hardDelete(String fileId, String annotationId) {
|
||||||
|
|
||||||
manualRedactionRepository.deleteById(new AnnotationEntityId(annotationId, fileId));
|
manualRedactionRepository.deleteIfPresentById(new AnnotationEntityId(annotationId, fileId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
|||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
@ -47,7 +48,7 @@ public class ForceRedactionPersistenceService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void hardDelete(String fileId, String annotationId) {
|
public void hardDelete(String fileId, String annotationId) {
|
||||||
|
|
||||||
forceRedactionRepository.deleteById(new AnnotationEntityId(annotationId, fileId));
|
forceRedactionRepository.deleteIfPresentById(new AnnotationEntityId(annotationId, fileId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,7 @@ public class ImageRecategorizationPersistenceService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void hardDelete(String fileId, String annotationId) {
|
public void hardDelete(String fileId, String annotationId) {
|
||||||
|
|
||||||
imageRecategorizationRepository.deleteById(new AnnotationEntityId(annotationId, fileId));
|
imageRecategorizationRepository.deleteIfPresentById(new AnnotationEntityId(annotationId, fileId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
|||||||
|
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ public class LegalBasisChangePersistenceService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void hardDelete(String fileId, String annotationId) {
|
public void hardDelete(String fileId, String annotationId) {
|
||||||
|
|
||||||
legalBasisChangeRepository.deleteById(new AnnotationEntityId(annotationId, fileId));
|
legalBasisChangeRepository.deleteIfPresentById(new AnnotationEntityId(annotationId, fileId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -61,7 +61,7 @@ public class RemoveRedactionPersistenceService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void hardDelete(String fileId, String annotationId) {
|
public void hardDelete(String fileId, String annotationId) {
|
||||||
|
|
||||||
removeRedactionRepository.deleteById(new AnnotationEntityId(annotationId, fileId));
|
removeRedactionRepository.deleteIfPresentById(new AnnotationEntityId(annotationId, fileId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -62,7 +62,7 @@ public class ResizeRedactionPersistenceService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void hardDelete(String fileId, String annotationId) {
|
public void hardDelete(String fileId, String annotationId) {
|
||||||
|
|
||||||
resizeRedactionRepository.deleteById(new AnnotationEntityId(annotationId, fileId));
|
resizeRedactionRepository.deleteIfPresentById(new AnnotationEntityId(annotationId, fileId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -39,4 +39,8 @@ public interface ForceRedactionRepository extends JpaRepository<ManualForceRedac
|
|||||||
@Query("update ManualForceRedactionEntity mfr set mfr.processedDate = :processedDate where mfr.id = :annotationEntityId")
|
@Query("update ManualForceRedactionEntity mfr set mfr.processedDate = :processedDate where mfr.id = :annotationEntityId")
|
||||||
void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate);
|
void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate);
|
||||||
|
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
Integer deleteIfPresentById(AnnotationEntityId annotationEntityId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,4 +39,7 @@ public interface ImageRecategorizationRepository extends JpaRepository<ManualIma
|
|||||||
@Query("update ManualImageRecategorizationEntity mir set mir.processedDate = :processedDate where mir.id = :annotationEntityId")
|
@Query("update ManualImageRecategorizationEntity mir set mir.processedDate = :processedDate where mir.id = :annotationEntityId")
|
||||||
void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate);
|
void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
Integer deleteIfPresentById(AnnotationEntityId annotationEntityId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,4 +31,7 @@ public interface LegalBasisChangeRepository extends JpaRepository<ManualLegalBas
|
|||||||
@Query("select mlbc from ManualLegalBasisChangeEntity mlbc where mlbc.id.fileId = :fileId and (:includeDeletions = true or mlbc.softDeletedTime is null)")
|
@Query("select mlbc from ManualLegalBasisChangeEntity mlbc where mlbc.id.fileId = :fileId and (:includeDeletions = true or mlbc.softDeletedTime is null)")
|
||||||
List<ManualLegalBasisChangeEntity> findByFileIdIncludeDeletions(String fileId, boolean includeDeletions);
|
List<ManualLegalBasisChangeEntity> findByFileIdIncludeDeletions(String fileId, boolean includeDeletions);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
Integer deleteIfPresentById(AnnotationEntityId annotationEntityId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,4 +55,7 @@ public interface ManualRedactionRepository extends JpaRepository<ManualRedaction
|
|||||||
@Query("update ManualRedactionEntryEntity m set m.processedDate = :processedDate where m.id = :annotationEntityId")
|
@Query("update ManualRedactionEntryEntity m set m.processedDate = :processedDate where m.id = :annotationEntityId")
|
||||||
void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate);
|
void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
Integer deleteIfPresentById(AnnotationEntityId annotationEntityId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,4 +41,7 @@ public interface RemoveRedactionRepository extends JpaRepository<IdRemovalEntity
|
|||||||
@Query("update IdRemovalEntity idr set idr.processedDate = :processedDate where idr.id = :annotationEntityId")
|
@Query("update IdRemovalEntity idr set idr.processedDate = :processedDate where idr.id = :annotationEntityId")
|
||||||
void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate);
|
void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
Integer deleteIfPresentById(AnnotationEntityId annotationEntityId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,4 +46,7 @@ public interface ResizeRedactionRepository extends JpaRepository<ManualResizeRed
|
|||||||
@Query("update ManualResizeRedactionEntity mir set mir.processedDate = :processedDate where mir.id = :annotationEntityId")
|
@Query("update ManualResizeRedactionEntity mir set mir.processedDate = :processedDate where mir.id = :annotationEntityId")
|
||||||
void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate);
|
void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
Integer deleteIfPresentById(AnnotationEntityId annotationEntityId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,41 +82,13 @@ public class ManualRedactionProviderService {
|
|||||||
|
|
||||||
public void hardDeleteManualRedactions(String fileId, String annotationId) {
|
public void hardDeleteManualRedactions(String fileId, String annotationId) {
|
||||||
|
|
||||||
try {
|
|
||||||
addRedactionPersistenceService.hardDelete(fileId, annotationId);
|
addRedactionPersistenceService.hardDelete(fileId, annotationId);
|
||||||
} catch (EmptyResultDataAccessException e) {
|
|
||||||
log.info("Ignored silently during deletion: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
removeRedactionPersistenceService.hardDelete(fileId, annotationId);
|
removeRedactionPersistenceService.hardDelete(fileId, annotationId);
|
||||||
} catch (EmptyResultDataAccessException e) {
|
|
||||||
log.info("Ignored silently during deletion: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
forceRedactionPersistenceService.hardDelete(fileId, annotationId);
|
forceRedactionPersistenceService.hardDelete(fileId, annotationId);
|
||||||
} catch (EmptyResultDataAccessException e) {
|
|
||||||
log.info("Ignored silently during deletion: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
recategorizationPersistenceService.hardDelete(fileId, annotationId);
|
recategorizationPersistenceService.hardDelete(fileId, annotationId);
|
||||||
} catch (EmptyResultDataAccessException e) {
|
|
||||||
log.info("Ignored silently during deletion: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
legalBasisChangePersistenceService.hardDelete(fileId, annotationId);
|
legalBasisChangePersistenceService.hardDelete(fileId, annotationId);
|
||||||
} catch (EmptyResultDataAccessException e) {
|
|
||||||
log.info("Ignored silently during deletion: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
resizeRedactionPersistenceService.hardDelete(fileId, annotationId);
|
resizeRedactionPersistenceService.hardDelete(fileId, annotationId);
|
||||||
} catch (EmptyResultDataAccessException e) {
|
|
||||||
log.info("Ignored silently during deletion: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
commentPersistenceService.hardDelete(fileId, annotationId);
|
commentPersistenceService.hardDelete(fileId, annotationId);
|
||||||
} catch (EmptyResultDataAccessException e) {
|
|
||||||
log.info("Ignored silently during deletion: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.iqser.red.service.peristence.v1.server.integration.tests;
|
package com.iqser.red.service.peristence.v1.server.integration.tests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -79,6 +80,52 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private FileClient fileClient;
|
private FileClient fileClient;
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemoveLocalRedaction(){
|
||||||
|
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||||
|
|
||||||
|
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
|
||||||
|
|
||||||
|
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
||||||
|
|
||||||
|
var type = typeProvider.testAndProvideType(dossierTemplate, null, "manual");
|
||||||
|
|
||||||
|
var addRedaction = manualRedactionClient.addAddRedaction(dossier.getId(),
|
||||||
|
file.getId(),
|
||||||
|
Collections.singletonList(AddRedactionRequest.builder()
|
||||||
|
.positions(List.of(Rectangle.builder().topLeftY(1).topLeftX(1).height(1).width(1).build()))
|
||||||
|
.section("section test")
|
||||||
|
.addToDictionary(false)
|
||||||
|
.addToDossierDictionary(false)
|
||||||
|
.status(AnnotationStatus.REQUESTED)
|
||||||
|
.typeId(type.getId())
|
||||||
|
.user("user")
|
||||||
|
.reason("1")
|
||||||
|
.value("test")
|
||||||
|
.legalBasis("1")
|
||||||
|
.rectangle(true)
|
||||||
|
.textAfter("Text After")
|
||||||
|
.textBefore("Text Before")
|
||||||
|
.sourceId("SourceId")
|
||||||
|
.build())).iterator().next();
|
||||||
|
var loadedAddRedaction = manualRedactionClient.getAddRedaction(file.getId(), addRedaction.getAnnotationId());
|
||||||
|
assertThat(loadedAddRedaction.isRectangle()).isEqualTo(true);
|
||||||
|
|
||||||
|
manualRedactionClient.addRemoveRedaction(dossier.getId(), file.getId(), List.of(RemoveRedactionRequest.builder()
|
||||||
|
.annotationId(addRedaction.getAnnotationId())
|
||||||
|
.comment("comment")
|
||||||
|
.status(AnnotationStatus.APPROVED)
|
||||||
|
.user("test")
|
||||||
|
.removeFromDictionary(false)
|
||||||
|
.build()));
|
||||||
|
|
||||||
|
// Add should be deleted.
|
||||||
|
assertThatThrownBy(() -> manualRedactionClient.getAddRedaction(file.getId(), addRedaction.getAnnotationId()))
|
||||||
|
.isInstanceOf(FeignException.class);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void testManualRedaction3641() {
|
public void testManualRedaction3641() {
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
import com.iqser.red.service.peristence.v1.server.jobs.CustomQuartzConfiguration;
|
||||||
import org.assertj.core.util.Lists;
|
import org.assertj.core.util.Lists;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -94,6 +95,8 @@ import lombok.SneakyThrows;
|
|||||||
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, properties = "spring-hibernate-query-utils.n-plus-one-queries-detection.error-level=INFO")
|
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, properties = "spring-hibernate-query-utils.n-plus-one-queries-detection.error-level=INFO")
|
||||||
public abstract class AbstractPersistenceServerServiceTest {
|
public abstract class AbstractPersistenceServerServiceTest {
|
||||||
|
|
||||||
|
@MockBean
|
||||||
|
private CustomQuartzConfiguration customQuartzConfiguration;
|
||||||
@MockBean
|
@MockBean
|
||||||
private AmqpAdmin amqpAdmin;
|
private AmqpAdmin amqpAdmin;
|
||||||
@MockBean
|
@MockBean
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user