RED-8828 - Fix error when resizing dict based redaction
This commit is contained in:
parent
d48e698167
commit
b9553e1f8d
@ -748,19 +748,19 @@ public class EntityCreationService {
|
|||||||
DocumentTree documentTree = node.getDocumentTree();
|
DocumentTree documentTree = node.getDocumentTree();
|
||||||
try {
|
try {
|
||||||
if (node.getEntities().contains(entity)) {
|
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 already exists and it has a different text range, we add the text range to the list of duplicated text ranges
|
||||||
if (entity.getTextBefore() == null || entity.getTextAfter() == null) {
|
Optional<TextEntity> optionalTextEntity = node.getEntities()
|
||||||
|
.stream()//
|
||||||
|
.filter(e -> e.equals(entity))//
|
||||||
|
.filter(e -> !e.getTextRange().equals(entity.getTextRange()))//
|
||||||
|
.findAny();
|
||||||
|
if (optionalTextEntity.isPresent()) {
|
||||||
|
addDuplicateEntityToGraph(optionalTextEntity.get(), entity.getTextRange(), node);
|
||||||
|
} else {
|
||||||
node.getEntities().remove(entity);
|
node.getEntities().remove(entity);
|
||||||
addNewEntityToGraph(entity, documentTree);
|
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()//
|
|
||||||
.filter(e -> e.equals(entity))//
|
|
||||||
.filter(e -> !e.getTextRange().equals(entity.getTextRange()))//
|
|
||||||
.findAny()//
|
|
||||||
.ifPresent(entityToDuplicate -> addDuplicateEntityToGraph(entityToDuplicate, entity.getTextRange(), node));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
entity.addIntersectingNode(documentTree.getRoot().getNode());
|
entity.addIntersectingNode(documentTree.getRoot().getNode());
|
||||||
addEntityToGraph(entity, documentTree);
|
addEntityToGraph(entity, documentTree);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user