Pull request #288: RED-2795 Bugfix with inconsistent types for recategorizing Images in specific cases
Merge in RED/redaction-service from bugfix/RED-2795 to master * commit '415df2b3658b4525120a15fb0f341164a73bb3d4': RED-2795 Bugfix with inconsistent types for recategorizing Images in specific cases
This commit is contained in:
commit
fa4b2263bc
@ -1,17 +1,36 @@
|
|||||||
package com.iqser.red.service.redaction.v1.server.redaction.service;
|
package com.iqser.red.service.redaction.v1.server.redaction.service;
|
||||||
|
|
||||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.*;
|
import java.time.OffsetDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.model.annotations.Comment;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.model.annotations.IdRemoval;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ManualForceRedaction;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ManualImageRecategorization;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ManualLegalBasisChange;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ManualRedactionEntry;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ManualRedactions;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ManualResizeRedaction;
|
||||||
|
import com.iqser.red.service.redaction.v1.model.ManualRedactionType;
|
||||||
|
import com.iqser.red.service.redaction.v1.model.Point;
|
||||||
import com.iqser.red.service.redaction.v1.model.Rectangle;
|
import com.iqser.red.service.redaction.v1.model.Rectangle;
|
||||||
import com.iqser.red.service.redaction.v1.model.*;
|
import com.iqser.red.service.redaction.v1.model.RedactionLog;
|
||||||
|
import com.iqser.red.service.redaction.v1.model.RedactionLogEntry;
|
||||||
|
import com.iqser.red.service.redaction.v1.model.SectionGrid;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@ -23,8 +42,9 @@ public class RedactionLogMergeService {
|
|||||||
private final SectionTextService sectionTextService;
|
private final SectionTextService sectionTextService;
|
||||||
|
|
||||||
|
|
||||||
public RedactionLog mergeRedactionLogData(RedactionLog redactionLog, SectionGrid sectionGrid, String dossierTemplateId,
|
public RedactionLog mergeRedactionLogData(RedactionLog redactionLog, SectionGrid sectionGrid,
|
||||||
ManualRedactions manualRedactions, Set<Integer> excludedPages) {
|
String dossierTemplateId, ManualRedactions manualRedactions,
|
||||||
|
Set<Integer> excludedPages) {
|
||||||
|
|
||||||
log.info("Merging Redaction log with manual redactions");
|
log.info("Merging Redaction log with manual redactions");
|
||||||
if (manualRedactions != null) {
|
if (manualRedactions != null) {
|
||||||
@ -56,7 +76,7 @@ public class RedactionLogMergeService {
|
|||||||
|
|
||||||
Set<String> processedIds = new HashSet<>();
|
Set<String> processedIds = new HashSet<>();
|
||||||
redactionLog.getRedactionLogEntry().removeIf(entry -> {
|
redactionLog.getRedactionLogEntry().removeIf(entry -> {
|
||||||
if(processedIds.contains(entry.getId())){
|
if (processedIds.contains(entry.getId())) {
|
||||||
log.info("Duplicate annotation found with id {}", entry.getId());
|
log.info("Duplicate annotation found with id {}", entry.getId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -120,12 +140,19 @@ public class RedactionLogMergeService {
|
|||||||
redactionLogEntry.setType(imageRecategorization.getType());
|
redactionLogEntry.setType(imageRecategorization.getType());
|
||||||
redactionLogEntry.setHasBeenRecategorized(true);
|
redactionLogEntry.setHasBeenRecategorized(true);
|
||||||
redactionLogEntry.setSection("Image:" + redactionLogEntry.getType());
|
redactionLogEntry.setSection("Image:" + redactionLogEntry.getType());
|
||||||
|
|
||||||
|
if (dictionaryService.isHint(imageRecategorization.getType(), dossierTemplateId)) {
|
||||||
|
redactionLogEntry.setRedacted(false);
|
||||||
|
redactionLogEntry.setHint(true);
|
||||||
|
} else {
|
||||||
|
redactionLogEntry.setHint(false);
|
||||||
|
}
|
||||||
|
|
||||||
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", recategorized by manual override");
|
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", recategorized by manual override");
|
||||||
} else if (imageRecategorization.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
} else if (imageRecategorization.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||||
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", requested to recategorize");
|
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", requested to recategorize");
|
||||||
redactionLogEntry.setStatus(AnnotationStatus.REQUESTED);
|
redactionLogEntry.setStatus(AnnotationStatus.REQUESTED);
|
||||||
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, false, redactionLogEntry
|
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, false, redactionLogEntry.isRedacted(), false));
|
||||||
.isRedacted(), false));
|
|
||||||
redactionLogEntry.setRecategorizationType(imageRecategorization.getType());
|
redactionLogEntry.setRecategorizationType(imageRecategorization.getType());
|
||||||
} else {
|
} else {
|
||||||
redactionLogEntry.setStatus(AnnotationStatus.DECLINED);
|
redactionLogEntry.setStatus(AnnotationStatus.DECLINED);
|
||||||
@ -144,14 +171,12 @@ public class RedactionLogMergeService {
|
|||||||
redactionLogEntry.setRedacted(false);
|
redactionLogEntry.setRedacted(false);
|
||||||
redactionLogEntry.setStatus(AnnotationStatus.APPROVED);
|
redactionLogEntry.setStatus(AnnotationStatus.APPROVED);
|
||||||
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", removed by manual override");
|
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", removed by manual override");
|
||||||
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, false, redactionLogEntry
|
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, false, redactionLogEntry.isRedacted(), true));
|
||||||
.isRedacted(), true));
|
|
||||||
redactionLogEntry.setHasBeenRemovedByManualOverride(true);
|
redactionLogEntry.setHasBeenRemovedByManualOverride(true);
|
||||||
} else if (manualRemoval.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
} else if (manualRemoval.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||||
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", requested to remove");
|
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", requested to remove");
|
||||||
redactionLogEntry.setStatus(AnnotationStatus.REQUESTED);
|
redactionLogEntry.setStatus(AnnotationStatus.REQUESTED);
|
||||||
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, true, redactionLogEntry
|
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, true, redactionLogEntry.isRedacted(), false));
|
||||||
.isRedacted(), false));
|
|
||||||
} else {
|
} else {
|
||||||
redactionLogEntry.setStatus(AnnotationStatus.DECLINED);
|
redactionLogEntry.setStatus(AnnotationStatus.DECLINED);
|
||||||
}
|
}
|
||||||
@ -170,16 +195,14 @@ public class RedactionLogMergeService {
|
|||||||
if (manualForceRedact.getStatus().equals(AnnotationStatus.APPROVED)) {
|
if (manualForceRedact.getStatus().equals(AnnotationStatus.APPROVED)) {
|
||||||
redactionLogEntry.setRedacted(true);
|
redactionLogEntry.setRedacted(true);
|
||||||
redactionLogEntry.setStatus(AnnotationStatus.APPROVED);
|
redactionLogEntry.setStatus(AnnotationStatus.APPROVED);
|
||||||
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, false, redactionLogEntry
|
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, false, redactionLogEntry.isRedacted(), false));
|
||||||
.isRedacted(), false));
|
|
||||||
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", forced by manual override");
|
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", forced by manual override");
|
||||||
redactionLogEntry.setHasBeenForced(true);
|
redactionLogEntry.setHasBeenForced(true);
|
||||||
redactionLogEntry.setLegalBasis(manualForceRedact.getLegalBasis());
|
redactionLogEntry.setLegalBasis(manualForceRedact.getLegalBasis());
|
||||||
} else if (manualForceRedact.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
} else if (manualForceRedact.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||||
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", requested to force redact");
|
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", requested to force redact");
|
||||||
redactionLogEntry.setStatus(AnnotationStatus.REQUESTED);
|
redactionLogEntry.setStatus(AnnotationStatus.REQUESTED);
|
||||||
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, true, redactionLogEntry
|
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, true, redactionLogEntry.isRedacted(), false));
|
||||||
.isRedacted(), false));
|
|
||||||
redactionLogEntry.setLegalBasis(manualForceRedact.getLegalBasis());
|
redactionLogEntry.setLegalBasis(manualForceRedact.getLegalBasis());
|
||||||
} else {
|
} else {
|
||||||
redactionLogEntry.setStatus(AnnotationStatus.DECLINED);
|
redactionLogEntry.setStatus(AnnotationStatus.DECLINED);
|
||||||
@ -210,8 +233,7 @@ public class RedactionLogMergeService {
|
|||||||
} else if (manualLegalBasisChange.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
} else if (manualLegalBasisChange.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||||
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", legal basis change requested");
|
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", legal basis change requested");
|
||||||
redactionLogEntry.setStatus(AnnotationStatus.REQUESTED);
|
redactionLogEntry.setStatus(AnnotationStatus.REQUESTED);
|
||||||
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, true, redactionLogEntry
|
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, true, redactionLogEntry.isRedacted(), false));
|
||||||
.isRedacted(), false));
|
|
||||||
redactionLogEntry.setLegalBasisChangeValue(manualLegalBasisChange.getLegalBasis());
|
redactionLogEntry.setLegalBasisChangeValue(manualLegalBasisChange.getLegalBasis());
|
||||||
} else {
|
} else {
|
||||||
redactionLogEntry.setStatus(AnnotationStatus.DECLINED);
|
redactionLogEntry.setStatus(AnnotationStatus.DECLINED);
|
||||||
@ -228,8 +250,7 @@ public class RedactionLogMergeService {
|
|||||||
String manualOverrideReason = null;
|
String manualOverrideReason = null;
|
||||||
if (manualResizeRedact.getStatus().equals(AnnotationStatus.APPROVED)) {
|
if (manualResizeRedact.getStatus().equals(AnnotationStatus.APPROVED)) {
|
||||||
redactionLogEntry.setStatus(AnnotationStatus.APPROVED);
|
redactionLogEntry.setStatus(AnnotationStatus.APPROVED);
|
||||||
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, false, redactionLogEntry
|
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, false, redactionLogEntry.isRedacted(), false));
|
||||||
.isRedacted(), false));
|
|
||||||
redactionLogEntry.setPositions(convertPositions(manualResizeRedact.getPositions()));
|
redactionLogEntry.setPositions(convertPositions(manualResizeRedact.getPositions()));
|
||||||
redactionLogEntry.setValue(manualResizeRedact.getValue());
|
redactionLogEntry.setValue(manualResizeRedact.getValue());
|
||||||
redactionLogEntry.setHasBeenResized(true);
|
redactionLogEntry.setHasBeenResized(true);
|
||||||
@ -237,8 +258,7 @@ public class RedactionLogMergeService {
|
|||||||
} else if (manualResizeRedact.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
} else if (manualResizeRedact.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||||
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", requested to resize redact");
|
manualOverrideReason = mergeReasonIfNecessary(redactionLogEntry.getReason(), ", requested to resize redact");
|
||||||
redactionLogEntry.setStatus(AnnotationStatus.REQUESTED);
|
redactionLogEntry.setStatus(AnnotationStatus.REQUESTED);
|
||||||
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, true, redactionLogEntry
|
redactionLogEntry.setColor(getColor(redactionLogEntry.getType(), dossierTemplateId, true, redactionLogEntry.isRedacted(), false));
|
||||||
.isRedacted(), false));
|
|
||||||
redactionLogEntry.setPositions(convertPositions(manualResizeRedact.getPositions()));
|
redactionLogEntry.setPositions(convertPositions(manualResizeRedact.getPositions()));
|
||||||
} else {
|
} else {
|
||||||
redactionLogEntry.setStatus(AnnotationStatus.DECLINED);
|
redactionLogEntry.setStatus(AnnotationStatus.DECLINED);
|
||||||
@ -290,9 +310,13 @@ public class RedactionLogMergeService {
|
|||||||
return redactionLogEntries;
|
return redactionLogEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Rectangle> convertPositions(List<com.iqser.red.service.persistence.service.v1.api.model.annotations.Rectangle> positions) {
|
|
||||||
return positions.stream().map(pos -> new Rectangle(new Point(pos.getTopLeftX(), pos.getTopLeftY()), pos.getWidth(), pos
|
private List<Rectangle> convertPositions(
|
||||||
.getHeight(), pos.getPage())).collect(Collectors.toList());
|
List<com.iqser.red.service.persistence.service.v1.api.model.annotations.Rectangle> positions) {
|
||||||
|
|
||||||
|
return positions.stream()
|
||||||
|
.map(pos -> new Rectangle(new Point(pos.getTopLeftX(), pos.getTopLeftY()), pos.getWidth(), pos.getHeight(), pos.getPage()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -375,6 +399,5 @@ public class RedactionLogMergeService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user