RED-3616: Do not remove annotation that intersects with skipped imported redactions
This commit is contained in:
parent
49d47a0682
commit
941448492b
@ -25,6 +25,12 @@
|
|||||||
<groupId>com.iqser.red.service</groupId>
|
<groupId>com.iqser.red.service</groupId>
|
||||||
<artifactId>persistence-service-api-v1</artifactId>
|
<artifactId>persistence-service-api-v1</artifactId>
|
||||||
<version>${persistence-service.version}</version>
|
<version>${persistence-service.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.iqser.red.service</groupId>
|
||||||
|
<artifactId>redaction-service-api-v1</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -66,6 +66,9 @@ public class RedactionLogEntry {
|
|||||||
|
|
||||||
private Set<String> reference = new HashSet<>();
|
private Set<String> reference = new HashSet<>();
|
||||||
|
|
||||||
|
@Builder.Default
|
||||||
|
private Set<String> importedRedactionIntersections = new HashSet<>();
|
||||||
|
|
||||||
public boolean lastChangeIsRemoved() {
|
public boolean lastChangeIsRemoved() {
|
||||||
return last(changes).map(c -> c.getType() == ChangeType.REMOVED).orElse(false);
|
return last(changes).map(c -> c.getType() == ChangeType.REMOVED).orElse(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -197,7 +197,7 @@ public class RedactionController implements RedactionResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.info("Loaded redaction log with computationalVersion: {}", redactionLog.getAnalysisVersion());
|
log.info("Loaded redaction log with computationalVersion: {}", redactionLog.getAnalysisVersion());
|
||||||
var merged = redactionLogMergeService.mergeRedactionLogData(redactionLog, sectionGrid, redactionRequest.getDossierTemplateId(), redactionRequest.getManualRedactions(), redactionRequest.getExcludedPages(), redactionRequest.getTypes(), redactionRequest.getColors());
|
var merged = redactionLogMergeService.mergeRedactionLogData(redactionLog, sectionGrid, redactionRequest.getManualRedactions(), redactionRequest.getExcludedPages(), redactionRequest.getTypes(), redactionRequest.getColors());
|
||||||
|
|
||||||
merged.getRedactionLogEntry().removeIf(e -> e.isFalsePositive() && !redactionRequest.isIncludeFalsePositives());
|
merged.getRedactionLogEntry().removeIf(e -> e.isFalsePositive() && !redactionRequest.isIncludeFalsePositives());
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
package com.iqser.red.service.redaction.v1.server.redaction.service;
|
package com.iqser.red.service.redaction.v1.server.redaction.service;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -24,14 +24,15 @@ public class ImportedRedactionService {
|
|||||||
|
|
||||||
|
|
||||||
public List<RedactionLogEntry> processImportedRedactions(String dossierTemplateId, String dossierId, String fileId,
|
public List<RedactionLogEntry> processImportedRedactions(String dossierTemplateId, String dossierId, String fileId,
|
||||||
List<RedactionLogEntry> redactionLogEntries, boolean addImportedRedactions) {
|
List<RedactionLogEntry> redactionLogEntries,
|
||||||
|
boolean addImportedRedactions) {
|
||||||
|
|
||||||
var importedRedactions = redactionStorageService.getImportedRedactions(dossierId, fileId);
|
var importedRedactions = redactionStorageService.getImportedRedactions(dossierId, fileId);
|
||||||
if (importedRedactions == null) {
|
if (importedRedactions == null) {
|
||||||
return redactionLogEntries;
|
return redactionLogEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
redactionLogEntries.removeIf(redactionLogEntry -> hasIntersections(redactionLogEntry, importedRedactions));
|
redactionLogEntries.forEach(redactionLogEntry -> addIntersections(redactionLogEntry, importedRedactions));
|
||||||
|
|
||||||
if (addImportedRedactions) {
|
if (addImportedRedactions) {
|
||||||
return addImportedRedactionsRedactionLogEntries(dossierTemplateId, redactionLogEntries, importedRedactions);
|
return addImportedRedactionsRedactionLogEntries(dossierTemplateId, redactionLogEntries, importedRedactions);
|
||||||
@ -42,8 +43,8 @@ public class ImportedRedactionService {
|
|||||||
|
|
||||||
|
|
||||||
private List<RedactionLogEntry> addImportedRedactionsRedactionLogEntries(String dossierTemplateId,
|
private List<RedactionLogEntry> addImportedRedactionsRedactionLogEntries(String dossierTemplateId,
|
||||||
List<RedactionLogEntry> redactionLogEntries,
|
List<RedactionLogEntry> redactionLogEntries,
|
||||||
ImportedRedactions importedRedactions) {
|
ImportedRedactions importedRedactions) {
|
||||||
|
|
||||||
for (List<ImportedRedaction> importedRedactionsValues : importedRedactions.getImportedRedactions().values()) {
|
for (List<ImportedRedaction> importedRedactionsValues : importedRedactions.getImportedRedactions().values()) {
|
||||||
for (ImportedRedaction importedRedaction : importedRedactionsValues) {
|
for (ImportedRedaction importedRedaction : importedRedactionsValues) {
|
||||||
@ -53,7 +54,7 @@ public class ImportedRedactionService {
|
|||||||
.imported(true)
|
.imported(true)
|
||||||
.redacted(true)
|
.redacted(true)
|
||||||
.positions(importedRedaction.getPositions())
|
.positions(importedRedaction.getPositions())
|
||||||
.color(getColor("imported_redaction", dossierTemplateId))
|
.color(getColor(IMPORTED_REDACTION_TYPE, dossierTemplateId))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
redactionLogEntries.add(redactionLogEntry);
|
redactionLogEntries.add(redactionLogEntry);
|
||||||
@ -64,7 +65,7 @@ public class ImportedRedactionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean hasIntersections(RedactionLogEntry redactionLogEntry, ImportedRedactions importedRedactions) {
|
private void addIntersections(RedactionLogEntry redactionLogEntry, ImportedRedactions importedRedactions) {
|
||||||
|
|
||||||
for (Rectangle rectangle : redactionLogEntry.getPositions()) {
|
for (Rectangle rectangle : redactionLogEntry.getPositions()) {
|
||||||
if (importedRedactions.getImportedRedactions().containsKey(rectangle.getPage())) {
|
if (importedRedactions.getImportedRedactions().containsKey(rectangle.getPage())) {
|
||||||
@ -72,13 +73,15 @@ public class ImportedRedactionService {
|
|||||||
for (ImportedRedaction importedRedaction : importedRedactionsOnPage) {
|
for (ImportedRedaction importedRedaction : importedRedactionsOnPage) {
|
||||||
for (Rectangle importedRedactionPosition : importedRedaction.getPositions()) {
|
for (Rectangle importedRedactionPosition : importedRedaction.getPositions()) {
|
||||||
if (intersects(importedRedactionPosition, rectangle)) {
|
if (intersects(importedRedactionPosition, rectangle)) {
|
||||||
return true;
|
if(redactionLogEntry.getImportedRedactionIntersections() == null){
|
||||||
|
redactionLogEntry.setImportedRedactionIntersections(new HashSet<>());
|
||||||
|
}
|
||||||
|
redactionLogEntry.getImportedRedactionIntersections().add(importedRedaction.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -27,13 +27,15 @@ public class RedactionLogMergeService {
|
|||||||
private final SectionTextService sectionTextService;
|
private final SectionTextService sectionTextService;
|
||||||
|
|
||||||
|
|
||||||
public RedactionLog mergeRedactionLogData(RedactionLog redactionLog, SectionGrid sectionGrid,
|
public RedactionLog mergeRedactionLogData(RedactionLog redactionLog, SectionGrid sectionGrid, ManualRedactions manualRedactions,
|
||||||
String dossierTemplateId, ManualRedactions manualRedactions,
|
|
||||||
Set<Integer> excludedPages, List<Type> types, Colors colors) {
|
Set<Integer> excludedPages, List<Type> types, Colors colors) {
|
||||||
|
|
||||||
|
var skippedImportedRedactions = new HashSet<>();
|
||||||
|
|
||||||
log.info("Merging Redaction log with manual redactions");
|
log.info("Merging Redaction log with manual redactions");
|
||||||
if (manualRedactions != null) {
|
if (manualRedactions != null) {
|
||||||
|
|
||||||
|
|
||||||
var manualRedactionLogEntries = addManualAddEntries(sectionGrid, manualRedactions.getEntriesToAdd(), manualRedactions.getComments(), colors, types);
|
var manualRedactionLogEntries = addManualAddEntries(sectionGrid, manualRedactions.getEntriesToAdd(), manualRedactions.getComments(), colors, types);
|
||||||
|
|
||||||
redactionLog.getRedactionLogEntry().addAll(manualRedactionLogEntries);
|
redactionLog.getRedactionLogEntry().addAll(manualRedactionLogEntries);
|
||||||
@ -46,6 +48,10 @@ public class RedactionLogMergeService {
|
|||||||
.filter(mr -> entry.getId().equals(mr.getId()))
|
.filter(mr -> entry.getId().equals(mr.getId()))
|
||||||
.collect(Collectors.toList()), entry, types, colors);
|
.collect(Collectors.toList()), entry, types, colors);
|
||||||
|
|
||||||
|
if(entry.isImported() && !entry.isRedacted()){
|
||||||
|
skippedImportedRedactions.add(entry.getId());
|
||||||
|
}
|
||||||
|
|
||||||
entry.setComments(manualRedactions.getComments().get(entry.getId()));
|
entry.setComments(manualRedactions.getComments().get(entry.getId()));
|
||||||
|
|
||||||
if (excludedPages != null && !excludedPages.isEmpty()) {
|
if (excludedPages != null && !excludedPages.isEmpty()) {
|
||||||
@ -61,6 +67,12 @@ public class RedactionLogMergeService {
|
|||||||
|
|
||||||
Set<String> processedIds = new HashSet<>();
|
Set<String> processedIds = new HashSet<>();
|
||||||
redactionLog.getRedactionLogEntry().removeIf(entry -> {
|
redactionLog.getRedactionLogEntry().removeIf(entry -> {
|
||||||
|
if(entry.getImportedRedactionIntersections() != null) {
|
||||||
|
entry.getImportedRedactionIntersections().removeAll(skippedImportedRedactions);
|
||||||
|
if (!entry.getImportedRedactionIntersections().isEmpty() && (!entry.isImage() || entry.isImage() && !entry.isRedacted())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
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;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user