RED-8828 - Fix error when resizing dict based redaction
This commit is contained in:
parent
9354cbb6bc
commit
70d591dc55
@ -682,6 +682,8 @@ public class EntityCreationService {
|
||||
|
||||
addEntityToGraph(mergedEntity, node);
|
||||
insertToKieSession(mergedEntity);
|
||||
|
||||
entitiesToMerge.stream().filter(e -> !e.equals(mergedEntity)).forEach(node.getEntities()::remove);
|
||||
return mergedEntity;
|
||||
}
|
||||
|
||||
@ -765,6 +767,11 @@ public class EntityCreationService {
|
||||
DocumentTree documentTree = node.getDocumentTree();
|
||||
try {
|
||||
if (node.getEntities().contains(entity)) {
|
||||
// If entity already exists but is missing textBefore/textAfter re-add it and enrich the entity with the missing values
|
||||
if (entity.getTextBefore() == null || entity.getTextAfter() == null) {
|
||||
node.getEntities().remove(entity);
|
||||
addNewEntityToGraph(entity, documentTree);
|
||||
} else {
|
||||
// If entity already exists and it has a different text range, we add the text range to the list of duplicated text ranges
|
||||
node.getEntities()
|
||||
.stream()//
|
||||
@ -772,18 +779,25 @@ public class EntityCreationService {
|
||||
.filter(e -> !e.getTextRange().equals(entity.getTextRange()))//
|
||||
.findAny()//
|
||||
.ifPresent(entityToDuplicate -> addDuplicateEntityToGraph(entityToDuplicate, entity.getTextRange(), node));
|
||||
}
|
||||
} else {
|
||||
entity.addIntersectingNode(documentTree.getRoot().getNode());
|
||||
addEntityToGraph(entity, documentTree);
|
||||
}
|
||||
} catch (NoSuchElementException e) {
|
||||
addNewEntityToGraph(entity, documentTree);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addNewEntityToGraph(TextEntity entity, DocumentTree documentTree) {
|
||||
|
||||
entity.setDeepestFullyContainingNode(documentTree.getRoot().getNode());
|
||||
entityEnrichmentService.enrichEntity(entity, entity.getDeepestFullyContainingNode().getTextBlock());
|
||||
entity.addIntersectingNode(documentTree.getRoot().getNode());
|
||||
addToPages(entity);
|
||||
addEntityToNodeEntitySets(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addDuplicateEntityToGraph(TextEntity entityToDuplicate, TextRange newTextRange, SemanticNode node) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user