RED-5449: Wrong behaviour of imported redactions only from PREVIEW-File
This commit is contained in:
parent
23a3d08e85
commit
f84f63cc64
@ -7,7 +7,7 @@ description = "redaction-service-api-v1"
|
||||
|
||||
dependencies {
|
||||
implementation("org.springframework:spring-web:6.0.12")
|
||||
implementation("com.iqser.red.service:persistence-service-internal-api-v1:2.279.0")
|
||||
implementation("com.iqser.red.service:persistence-service-internal-api-v1:2.320.0")
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
||||
@ -16,7 +16,7 @@ val layoutParserVersion = "0.86.0"
|
||||
val jacksonVersion = "2.15.2"
|
||||
val droolsVersion = "9.44.0.Final"
|
||||
val pdfBoxVersion = "3.0.0"
|
||||
val persistenceServiceVersion = "2.279.0"
|
||||
val persistenceServiceVersion = "2.320.0"
|
||||
val springBootStarterVersion = "3.1.5"
|
||||
|
||||
configurations {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.iqser.red.service.redaction.v1.server.model.component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Change;
|
||||
@ -87,7 +88,7 @@ public class Entity {
|
||||
.textAfter(e.getTextAfter())
|
||||
.startOffset(e.getStartOffset())
|
||||
.endOffset(e.getEndOffset())
|
||||
.length(e.getValue().length())
|
||||
.length(Optional.ofNullable(e.getValue()).orElse("").length())
|
||||
.imageHasTransparency(e.isImageHasTransparency())
|
||||
.isDictionaryEntry(e.isDictionaryEntry())
|
||||
.isDossierDictionaryEntry(e.isDossierDictionaryEntry())
|
||||
|
||||
@ -8,6 +8,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -92,16 +93,16 @@ public class ImportedRedactionService {
|
||||
// add all changes to entity log
|
||||
entityLog.getEntityLogEntry().addAll(newEntityLogsForImportedEntities);
|
||||
// remove all intersections and update with merged imported redactions
|
||||
calculateIntersections(newEntityLogsForImportedEntities, entityLog);
|
||||
calculateIntersections(newEntityLogsForImportedEntities, entityLog, analyzeRequest.getAnalysisNumber());
|
||||
}
|
||||
|
||||
private void calculateIntersections(List<EntityLogEntry> importedRedactionAndMergedEntries, EntityLog entityLog) {
|
||||
private void calculateIntersections(List<EntityLogEntry> importedRedactionAndMergedEntries, EntityLog entityLog, int analysisNumber) {
|
||||
if (!importedRedactionAndMergedEntries.isEmpty()) {
|
||||
// imported redactions present, intersections must be added with merged imported redactions
|
||||
Map<Integer, List<EntityLogEntry>> importedRedactionsMap = mapImportedRedactionsOnPage(importedRedactionAndMergedEntries);
|
||||
entityLog.getEntityLogEntry().stream().filter(entry -> !entry.getType().equals(ImportedRedactionService.IMPORTED_REDACTION_TYPE)).forEach(redactionLogEntry -> {
|
||||
redactionLogEntry.setImportedRedactionIntersections(new HashSet<>());
|
||||
addIntersections(redactionLogEntry, importedRedactionsMap);
|
||||
addIntersections(redactionLogEntry, importedRedactionsMap, analysisNumber);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -141,12 +142,12 @@ public class ImportedRedactionService {
|
||||
.id(importedRedaction.getId())
|
||||
.type(IMPORTED_REDACTION_TYPE)
|
||||
.entryType(EntryType.ENTITY)
|
||||
.value(Optional.ofNullable(importedRedaction.getValue()).orElse(""))
|
||||
.imported(true)
|
||||
.state(EntryState.APPLIED)
|
||||
.positions(importedRedaction.getPositions())
|
||||
.color(getColor(IMPORTED_REDACTION_TYPE, dossierTemplateId))
|
||||
.containingNodeId(Collections.emptyList())
|
||||
.value("")
|
||||
.build();
|
||||
redactionLogEntry.getChanges().add(new Change(1, ChangeType.ADDED, now));
|
||||
initialImportedRedactionsEntityLogEntries.add(redactionLogEntry);
|
||||
@ -202,7 +203,7 @@ public class ImportedRedactionService {
|
||||
return importedRedactionsMap;
|
||||
}
|
||||
|
||||
public void addIntersections(EntityLogEntry entityLogEntry, Map<Integer, List<EntityLogEntry>> importedRedactionsMap) {
|
||||
public void addIntersections(EntityLogEntry entityLogEntry, Map<Integer, List<EntityLogEntry>> importedRedactionsMap, int analysisNumber) {
|
||||
|
||||
for (Position rectangle : entityLogEntry.getPositions()) {
|
||||
var normalizedRectangle = normalize(rectangle);
|
||||
@ -215,6 +216,11 @@ public class ImportedRedactionService {
|
||||
entityLogEntry.setImportedRedactionIntersections(new HashSet<>());
|
||||
}
|
||||
entityLogEntry.getImportedRedactionIntersections().add(importedRedactionLogEntry.getId());
|
||||
|
||||
if(entityLogEntry.getState() != EntryState.REMOVED) {
|
||||
entityLogEntry.setState(EntryState.REMOVED);
|
||||
entityLogEntry.getChanges().add(new Change(analysisNumber, ChangeType.REMOVED, OffsetDateTime.now()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user