RED-2429: As a user I want to resize a redaction
This commit is contained in:
parent
3dc0218a28
commit
b4d00a5602
@ -22,6 +22,7 @@ public class ManualResizeRedaction {
|
|||||||
private OffsetDateTime requestDate;
|
private OffsetDateTime requestDate;
|
||||||
private OffsetDateTime processedDate;
|
private OffsetDateTime processedDate;
|
||||||
private OffsetDateTime softDeletedTime;
|
private OffsetDateTime softDeletedTime;
|
||||||
|
private String value;
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
private List<Rectangle> positions = new ArrayList<>();
|
private List<Rectangle> positions = new ArrayList<>();
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,7 @@ public class ResizeRedactionRequest {
|
|||||||
private AnnotationStatus status;
|
private AnnotationStatus status;
|
||||||
private String comment;
|
private String comment;
|
||||||
private int page;
|
private int page;
|
||||||
|
private String value;
|
||||||
|
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
private List<Rectangle> positions = new ArrayList<>();
|
private List<Rectangle> positions = new ArrayList<>();
|
||||||
|
|||||||
@ -44,6 +44,8 @@ public class ManualResizeRedactionEntity {
|
|||||||
private OffsetDateTime softDeletedTime;
|
private OffsetDateTime softDeletedTime;
|
||||||
@Column
|
@Column
|
||||||
private int page;
|
private int page;
|
||||||
|
@Column
|
||||||
|
private String value;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private FileEntity fileStatus;
|
private FileEntity fileStatus;
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
package com.iqser.red.service.persistence.management.v1.processor.service.persistence;
|
package com.iqser.red.service.persistence.management.v1.processor.service.persistence;
|
||||||
|
|
||||||
|
import static com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter.convert;
|
||||||
|
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -18,8 +19,6 @@ import com.iqser.red.service.persistence.management.v1.processor.service.persist
|
|||||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ResizeRedactionRequest;
|
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ResizeRedactionRequest;
|
||||||
|
|
||||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter.convert;
|
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -28,6 +27,7 @@ public class ResizeRedactionPersistenceService {
|
|||||||
|
|
||||||
private final ResizeRedactionRepository resizeRedactionRepository;
|
private final ResizeRedactionRepository resizeRedactionRepository;
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void insert(String fileId, ResizeRedactionRequest resizeRedactionRequest) {
|
public void insert(String fileId, ResizeRedactionRequest resizeRedactionRequest) {
|
||||||
|
|
||||||
@ -40,8 +40,10 @@ public class ResizeRedactionPersistenceService {
|
|||||||
resizeRedactionRepository.save(manualResizeRedaction);
|
resizeRedactionRepository.save(manualResizeRedaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void updateStatus(String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
public void updateStatus(String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||||
|
|
||||||
resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> {
|
resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> {
|
||||||
mre.setProcessedDate(OffsetDateTime.now());
|
mre.setProcessedDate(OffsetDateTime.now());
|
||||||
mre.setStatus(annotationStatus);
|
mre.setStatus(annotationStatus);
|
||||||
@ -51,31 +53,42 @@ 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.deleteById(new AnnotationEntityId(annotationId, fileId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void softDelete(String fileId, String annotationId, OffsetDateTime softDeleteTime) {
|
public void softDelete(String fileId, String annotationId, OffsetDateTime softDeleteTime) {
|
||||||
resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> mre.setSoftDeletedTime(softDeleteTime));
|
|
||||||
|
resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
||||||
|
.ifPresent(mre -> mre.setSoftDeletedTime(softDeleteTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void undelete(String fileId, String annotationId) {
|
public void undelete(String fileId, String annotationId) {
|
||||||
resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> mre.setSoftDeletedTime(null));
|
|
||||||
|
resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
||||||
|
.ifPresent(mre -> mre.setSoftDeletedTime(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ManualResizeRedactionEntity findResizeRedaction(String fileId, String annotationId) {
|
public ManualResizeRedactionEntity findResizeRedaction(String fileId, String annotationId) {
|
||||||
|
|
||||||
return resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
return resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
||||||
.filter(mre -> mre.getSoftDeletedTime() == null)
|
.filter(mre -> mre.getSoftDeletedTime() == null)
|
||||||
.orElseThrow(() ->
|
.orElseThrow(() -> new NotFoundException("Unknown file/annotation combination: " + fileId + "/" + annotationId));
|
||||||
new NotFoundException("Unknown file/annotation combination: " + fileId + "/" + annotationId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Set<ManualResizeRedactionEntity> findResizeRedactions(String fileId, boolean includeDeletions) {
|
public Set<ManualResizeRedactionEntity> findResizeRedactions(String fileId, boolean includeDeletions) {
|
||||||
|
|
||||||
return resizeRedactionRepository.findByIdFileId(fileId).stream().filter(mre -> includeDeletions || mre.getSoftDeletedTime() == null).collect(Collectors.toSet());
|
return resizeRedactionRepository.findByIdFileId(fileId)
|
||||||
|
.stream()
|
||||||
|
.filter(mre -> includeDeletions || mre.getSoftDeletedTime() == null)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -169,11 +169,12 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
|||||||
assertThat(loadedImageRecategorization2.getStatus()).isEqualTo(AnnotationStatus.REQUESTED);
|
assertThat(loadedImageRecategorization2.getStatus()).isEqualTo(AnnotationStatus.REQUESTED);
|
||||||
|
|
||||||
var resizeRedaction = manualRedactionClient.addResizeRedaction(dossier.getId(), file.getId(), ResizeRedactionRequest.builder()
|
var resizeRedaction = manualRedactionClient.addResizeRedaction(dossier.getId(), file.getId(), ResizeRedactionRequest.builder()
|
||||||
.annotationId(addRedaction.getAnnotationId()).page(1).comment("comment").status(AnnotationStatus.REQUESTED).positions(List.of(Rectangle.builder().topLeftY(2).topLeftX(2).height(2).width(2).build())).user("test").build());
|
.annotationId(addRedaction.getAnnotationId()).page(1).comment("comment").status(AnnotationStatus.REQUESTED).positions(List.of(Rectangle.builder().topLeftY(2).topLeftX(2).height(2).width(2).build())).user("test").value("some value").build());
|
||||||
var loadedResizeRedaction = manualRedactionClient.getResizeRedaction(file.getId(), resizeRedaction.getAnnotationId());
|
var loadedResizeRedaction = manualRedactionClient.getResizeRedaction(file.getId(), resizeRedaction.getAnnotationId());
|
||||||
assertThat(loadedResizeRedaction.getStatus()).isEqualTo(AnnotationStatus.REQUESTED);
|
assertThat(loadedResizeRedaction.getStatus()).isEqualTo(AnnotationStatus.REQUESTED);
|
||||||
assertThat(loadedResizeRedaction.getUser()).isEqualTo("test");
|
assertThat(loadedResizeRedaction.getUser()).isEqualTo("test");
|
||||||
assertThat(loadedResizeRedaction.getPositions()).isNotEmpty();
|
assertThat(loadedResizeRedaction.getPositions()).isNotEmpty();
|
||||||
|
assertThat(loadedResizeRedaction.getValue()).isEqualTo("some value");
|
||||||
|
|
||||||
manualRedactionClient.updateResizeRedactionStatus(dossier.getId(), file.getId(), resizeRedaction.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.APPROVED));
|
manualRedactionClient.updateResizeRedactionStatus(dossier.getId(), file.getId(), resizeRedaction.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.APPROVED));
|
||||||
loadedResizeRedaction = manualRedactionClient.getResizeRedaction(file.getId(), resizeRedaction.getAnnotationId());
|
loadedResizeRedaction = manualRedactionClient.getResizeRedaction(file.getId(), resizeRedaction.getAnnotationId());
|
||||||
@ -229,11 +230,12 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
|||||||
manualRedactions.getLegalBasisChanges().forEach(e -> manualRedactionClient.deleteLegalBasisChange(dossier.getId(), file.getId(), e.getAnnotationId()));
|
manualRedactions.getLegalBasisChanges().forEach(e -> manualRedactionClient.deleteLegalBasisChange(dossier.getId(), file.getId(), e.getAnnotationId()));
|
||||||
|
|
||||||
var resizeRedaction2 = manualRedactionClient.addResizeRedaction(dossier.getId(), file.getId(), ResizeRedactionRequest.builder()
|
var resizeRedaction2 = manualRedactionClient.addResizeRedaction(dossier.getId(), file.getId(), ResizeRedactionRequest.builder()
|
||||||
.annotationId(addRedaction.getAnnotationId()).page(1).comment("comment").status(AnnotationStatus.APPROVED).positions(List.of(Rectangle.builder().topLeftY(2).topLeftX(2).height(2).width(2).build())).user("test").build());
|
.annotationId(addRedaction.getAnnotationId()).page(1).comment("comment").status(AnnotationStatus.APPROVED).positions(List.of(Rectangle.builder().topLeftY(2).topLeftX(2).height(2).width(2).build())).user("test").value("some value").build());
|
||||||
var loadedResizeRedaction2 = manualRedactionClient.getResizeRedaction(file.getId(), resizeRedaction2.getAnnotationId());
|
var loadedResizeRedaction2 = manualRedactionClient.getResizeRedaction(file.getId(), resizeRedaction2.getAnnotationId());
|
||||||
assertThat(loadedResizeRedaction2.getStatus()).isEqualTo(AnnotationStatus.APPROVED);
|
assertThat(loadedResizeRedaction2.getStatus()).isEqualTo(AnnotationStatus.APPROVED);
|
||||||
assertThat(loadedResizeRedaction2.getUser()).isEqualTo("test");
|
assertThat(loadedResizeRedaction2.getUser()).isEqualTo("test");
|
||||||
assertThat(loadedResizeRedaction2.getPositions()).isNotEmpty();
|
assertThat(loadedResizeRedaction2.getPositions()).isNotEmpty();
|
||||||
|
assertThat(loadedResizeRedaction2.getValue()).isEqualTo("some value");
|
||||||
|
|
||||||
manualRedactionClient.updateResizeRedactionStatus(dossier.getId(), file.getId(), resizeRedaction2.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.REQUESTED));
|
manualRedactionClient.updateResizeRedactionStatus(dossier.getId(), file.getId(), resizeRedaction2.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.REQUESTED));
|
||||||
loadedResizeRedaction2 = manualRedactionClient.getResizeRedaction(file.getId(), resizeRedaction2.getAnnotationId());
|
loadedResizeRedaction2 = manualRedactionClient.getResizeRedaction(file.getId(), resizeRedaction2.getAnnotationId());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user