RED-10200: fix failing acceptance, function tests
This commit is contained in:
parent
dd545daeb7
commit
d022b1a5c9
@ -4,16 +4,12 @@ import static java.lang.String.format;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import com.iqser.red.service.redaction.v1.server.model.document.entity.Containment;
|
|
||||||
import com.iqser.red.service.redaction.v1.server.model.document.entity.EntityType;
|
import com.iqser.red.service.redaction.v1.server.model.document.entity.EntityType;
|
||||||
import com.iqser.red.service.redaction.v1.server.model.document.entity.Equality;
|
|
||||||
import com.iqser.red.service.redaction.v1.server.model.document.entity.Intersection;
|
|
||||||
import com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity;
|
import com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity;
|
||||||
import com.iqser.red.service.redaction.v1.server.model.document.nodes.Document;
|
import com.iqser.red.service.redaction.v1.server.model.document.nodes.Document;
|
||||||
import com.iqser.red.service.redaction.v1.server.model.document.nodes.GenericSemanticNode;
|
import com.iqser.red.service.redaction.v1.server.model.document.nodes.GenericSemanticNode;
|
||||||
@ -380,24 +376,7 @@ public class DocumentTree {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TextEntity textEntity : entity.getDeepestFullyContainingNode().getEntities()) {
|
entity.computeRelations();
|
||||||
if (entity.intersects(textEntity) && !entity.equals(textEntity) && !textEntity.getEntityType().equals(EntityType.TEMPORARY)) {
|
|
||||||
if (textEntity.getTextRange().equals(entity.getTextRange())) {
|
|
||||||
textEntity.getRelations().computeIfAbsent(entity, k -> new HashSet<>()).add(new Equality(entity, textEntity));
|
|
||||||
entity.getRelations().computeIfAbsent(textEntity, k -> new HashSet<>()).add(new Equality(textEntity, entity));
|
|
||||||
} else if (textEntity.containedBy(entity)) {
|
|
||||||
textEntity.getRelations().computeIfAbsent(entity, k -> new HashSet<>()).add(new Intersection(textEntity, entity));
|
|
||||||
entity.getRelations().computeIfAbsent(textEntity, k -> new HashSet<>()).add(new Containment(entity, textEntity));
|
|
||||||
} else if (entity.containedBy(textEntity)) {
|
|
||||||
textEntity.getRelations().computeIfAbsent(entity, k -> new HashSet<>()).add(new Containment(textEntity, entity));
|
|
||||||
entity.getRelations().computeIfAbsent(textEntity, k -> new HashSet<>()).add(new Intersection(entity, textEntity));
|
|
||||||
} else {
|
|
||||||
textEntity.getRelations().computeIfAbsent(entity, k -> new HashSet<>()).add(new Intersection(textEntity, entity));
|
|
||||||
entity.getRelations().computeIfAbsent(textEntity, k -> new HashSet<>()).add(new Intersection(entity, textEntity));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -367,6 +367,13 @@ public interface IEntity {
|
|||||||
void removeEntityEventListener(EntityEventListener listener);
|
void removeEntityEventListener(EntityEventListener listener);
|
||||||
|
|
||||||
|
|
||||||
|
default void notifyEntityInserted() {
|
||||||
|
|
||||||
|
for (EntityEventListener listener : getEntityEventListeners()) {
|
||||||
|
listener.onEntityInserted(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
default void notifyEntityUpdated() {
|
default void notifyEntityUpdated() {
|
||||||
|
|
||||||
for (EntityEventListener listener : getEntityEventListeners()) {
|
for (EntityEventListener listener : getEntityEventListeners()) {
|
||||||
|
|||||||
@ -339,6 +339,7 @@ public class TextEntity implements IEntity {
|
|||||||
.orElse(getMatchedRule().isWriteValueWithLineBreaks() ? getValueWithLineBreaks() : value);
|
.orElse(getMatchedRule().isWriteValueWithLineBreaks() ? getValueWithLineBreaks() : value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addEntityEventListener(EntityEventListener listener) {
|
public void addEntityEventListener(EntityEventListener listener) {
|
||||||
|
|
||||||
@ -353,4 +354,27 @@ public class TextEntity implements IEntity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void computeRelations() {
|
||||||
|
|
||||||
|
for (TextEntity textEntity : this.getDeepestFullyContainingNode().getEntities()) {
|
||||||
|
if (this.intersects(textEntity) && !this.equals(textEntity) && !textEntity.getEntityType().equals(EntityType.TEMPORARY)) {
|
||||||
|
if (textEntity.getTextRange().equals(this.getTextRange())) {
|
||||||
|
textEntity.getRelations().computeIfAbsent(this, k -> new HashSet<>()).add(new Equality(this, textEntity));
|
||||||
|
this.getRelations().computeIfAbsent(textEntity, k -> new HashSet<>()).add(new Equality(textEntity, this));
|
||||||
|
} else if (textEntity.containedBy(this)) {
|
||||||
|
textEntity.getRelations().computeIfAbsent(this, k -> new HashSet<>()).add(new Intersection(textEntity, this));
|
||||||
|
this.getRelations().computeIfAbsent(textEntity, k -> new HashSet<>()).add(new Containment(this, textEntity));
|
||||||
|
} else if (this.containedBy(textEntity)) {
|
||||||
|
textEntity.getRelations().computeIfAbsent(this, k -> new HashSet<>()).add(new Containment(textEntity, this));
|
||||||
|
this.getRelations().computeIfAbsent(textEntity, k -> new HashSet<>()).add(new Intersection(this, textEntity));
|
||||||
|
} else {
|
||||||
|
textEntity.getRelations().computeIfAbsent(this, k -> new HashSet<>()).add(new Intersection(textEntity, this));
|
||||||
|
this.getRelations().computeIfAbsent(textEntity, k -> new HashSet<>()).add(new Intersection(this, textEntity));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.iqser.red.service.redaction.v1.server.service;
|
|||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -79,6 +80,9 @@ public class ManualChangesApplicationService {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public void resizeEntityAndReinsert(TextEntity entityToBeResized, ManualResizeRedaction manualResizeRedaction) {
|
public void resizeEntityAndReinsert(TextEntity entityToBeResized, ManualResizeRedaction manualResizeRedaction) {
|
||||||
|
|
||||||
|
entityToBeResized.notifyEntityRemoved();
|
||||||
|
entityToBeResized.removeFromGraph();
|
||||||
|
|
||||||
PositionOnPage positionOnPageToBeResized = entityToBeResized.getPositionsOnPagePerPage()
|
PositionOnPage positionOnPageToBeResized = entityToBeResized.getPositionsOnPagePerPage()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(redactionPosition -> redactionPosition.getId().equals(manualResizeRedaction.getAnnotationId()))
|
.filter(redactionPosition -> redactionPosition.getId().equals(manualResizeRedaction.getAnnotationId()))
|
||||||
@ -120,7 +124,12 @@ public class ManualChangesApplicationService {
|
|||||||
node = null;
|
node = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entityToBeResized.notifyEntityUpdated();
|
|
||||||
|
entityToBeResized.getRelations().keySet()
|
||||||
|
.forEach(textEntity -> textEntity.getRelations().remove(entityToBeResized));
|
||||||
|
entityToBeResized.setRelations(new HashMap<>());
|
||||||
|
entityToBeResized.computeRelations();
|
||||||
|
entityToBeResized.notifyEntityInserted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1653,16 +1653,15 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
|
|||||||
.findFirst()
|
.findFirst()
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
List<Rectangle> positions = List.of(Rectangle.builder().topLeftX(56.8f).topLeftY(293.564f).width(29.2922f).height(15.408f).page(1).build());
|
|
||||||
request.setManualRedactions(ManualRedactions.builder()
|
request.setManualRedactions(ManualRedactions.builder()
|
||||||
.entriesToAdd(Set.of(ManualRedactionEntry.builder()
|
.entriesToAdd(Set.of(ManualRedactionEntry.builder()
|
||||||
.annotationId("newId")
|
.annotationId("newId")
|
||||||
.fileId(TEST_FILE_ID)
|
.fileId(TEST_FILE_ID)
|
||||||
.user("user")
|
.user("user")
|
||||||
.requestDate(OffsetDateTime.now())
|
.requestDate(OffsetDateTime.now())
|
||||||
.value("David")
|
.value("David Ksenia")
|
||||||
.type("CBI_author")
|
.type("CBI_author")
|
||||||
.positions(positions)
|
.positions(List.of(Rectangle.builder().topLeftX(56.8f).topLeftY(295.2f).width(65.59f).height(12.64f).page(1).build()))
|
||||||
.build()))
|
.build()))
|
||||||
.resizeRedactions(Set.of(ManualResizeRedaction.builder()
|
.resizeRedactions(Set.of(ManualResizeRedaction.builder()
|
||||||
.updateDictionary(false)
|
.updateDictionary(false)
|
||||||
@ -1671,7 +1670,7 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
|
|||||||
.user("user")
|
.user("user")
|
||||||
.requestDate(OffsetDateTime.now())
|
.requestDate(OffsetDateTime.now())
|
||||||
.value("David")
|
.value("David")
|
||||||
.positions(positions)
|
.positions(List.of(Rectangle.builder().topLeftX(56.8f).topLeftY(293.564f).width(29.2922f).height(15.408f).page(1).build()))
|
||||||
.addToAllDossiers(false)
|
.addToAllDossiers(false)
|
||||||
.build()))
|
.build()))
|
||||||
.build());
|
.build());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user