RED-7979 - Force Hint leads to 500 BE Error
This commit is contained in:
parent
a09645669c
commit
17bc14e9c1
@ -39,14 +39,14 @@ public class ManualEntity implements IEntity {
|
|||||||
|
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
PriorityQueue<MatchedRule> matchedRuleList = new PriorityQueue<>();
|
PriorityQueue<MatchedRule> matchedRuleList = new PriorityQueue<>();
|
||||||
@Builder.Default
|
ManualChangeOverwrite manualOverwrite;
|
||||||
ManualChangeOverwrite manualOverwrite = new ManualChangeOverwrite();
|
|
||||||
|
|
||||||
|
|
||||||
public static ManualEntity fromManualRedactionEntry(ManualRedactionEntry manualRedactionEntry, boolean hint) {
|
public static ManualEntity fromManualRedactionEntry(ManualRedactionEntry manualRedactionEntry, boolean hint) {
|
||||||
|
|
||||||
List<RectangleWithPage> rectangleWithPages = manualRedactionEntry.getPositions().stream().map(RectangleWithPage::fromAnnotationRectangle).toList();
|
List<RectangleWithPage> rectangleWithPages = manualRedactionEntry.getPositions().stream().map(RectangleWithPage::fromAnnotationRectangle).toList();
|
||||||
ManualChangeOverwrite manualChangeOverwrite = new ManualChangeOverwrite();
|
var entityType = hint ? EntityType.HINT : EntityType.ENTITY;
|
||||||
|
ManualChangeOverwrite manualChangeOverwrite = new ManualChangeOverwrite(entityType);
|
||||||
manualChangeOverwrite.addChange(manualRedactionEntry);
|
manualChangeOverwrite.addChange(manualRedactionEntry);
|
||||||
return ManualEntity.builder()
|
return ManualEntity.builder()
|
||||||
.id(manualRedactionEntry.getAnnotationId())
|
.id(manualRedactionEntry.getAnnotationId())
|
||||||
@ -57,7 +57,7 @@ public class ManualEntity implements IEntity {
|
|||||||
.legalBasis(manualRedactionEntry.getLegalBasis())
|
.legalBasis(manualRedactionEntry.getLegalBasis())
|
||||||
.type(manualRedactionEntry.getType())
|
.type(manualRedactionEntry.getType())
|
||||||
.section(manualRedactionEntry.getSection())
|
.section(manualRedactionEntry.getSection())
|
||||||
.entityType(hint ? EntityType.HINT : EntityType.ENTITY)
|
.entityType(entityType)
|
||||||
.applied(true)
|
.applied(true)
|
||||||
.isDictionaryEntry(false)
|
.isDictionaryEntry(false)
|
||||||
.isDossierDictionaryEntry(false)
|
.isDossierDictionaryEntry(false)
|
||||||
@ -80,4 +80,8 @@ public class ManualEntity implements IEntity {
|
|||||||
return getManualOverwrite().getType().orElse(type);
|
return getManualOverwrite().getType().orElse(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EntityType getEntityType(boolean isHint) {
|
||||||
|
return isHint ? EntityType.HINT : EntityType.ENTITY;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ManualRedactions;
|
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.BaseAnnotation;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.BaseAnnotation;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.IdRemoval;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.IdRemoval;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualForceRedaction;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualForceRedaction;
|
||||||
@ -20,11 +19,9 @@ import com.iqser.red.service.redaction.v1.server.model.RectangleWithPage;
|
|||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.FieldDefaults;
|
import lombok.experimental.FieldDefaults;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||||
public class ManualChangeOverwrite {
|
public class ManualChangeOverwrite {
|
||||||
@ -50,7 +47,15 @@ public class ManualChangeOverwrite {
|
|||||||
Boolean ignored;
|
Boolean ignored;
|
||||||
Boolean resized;
|
Boolean resized;
|
||||||
Boolean recategorized;
|
Boolean recategorized;
|
||||||
|
EntityType entityType;
|
||||||
|
|
||||||
|
public ManualChangeOverwrite() {
|
||||||
|
this(EntityType.ENTITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ManualChangeOverwrite (EntityType entityType) {
|
||||||
|
this.entityType = entityType;
|
||||||
|
}
|
||||||
|
|
||||||
public void calculateCurrentOverride() {
|
public void calculateCurrentOverride() {
|
||||||
|
|
||||||
@ -100,7 +105,9 @@ public class ManualChangeOverwrite {
|
|||||||
if (manualChange instanceof ManualForceRedaction manualForceRedaction) {
|
if (manualChange instanceof ManualForceRedaction manualForceRedaction) {
|
||||||
removed = false;
|
removed = false;
|
||||||
ignored = false;
|
ignored = false;
|
||||||
applied = true;
|
if (!isHint(entityType)) {
|
||||||
|
applied = true;
|
||||||
|
}
|
||||||
legalBasis = manualForceRedaction.getLegalBasis();
|
legalBasis = manualForceRedaction.getLegalBasis();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,4 +228,9 @@ public class ManualChangeOverwrite {
|
|||||||
return positions == null ? Optional.empty() : Optional.of(positions);
|
return positions == null ? Optional.empty() : Optional.of(positions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isHint(EntityType entityType) {
|
||||||
|
|
||||||
|
return entityType.equals(EntityType.HINT);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,8 +41,7 @@ public class TextEntity implements IEntity {
|
|||||||
|
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
final PriorityQueue<MatchedRule> matchedRuleList = new PriorityQueue<>();
|
final PriorityQueue<MatchedRule> matchedRuleList = new PriorityQueue<>();
|
||||||
@Builder.Default
|
final ManualChangeOverwrite manualOverwrite;
|
||||||
final ManualChangeOverwrite manualOverwrite = new ManualChangeOverwrite();
|
|
||||||
|
|
||||||
boolean dictionaryEntry;
|
boolean dictionaryEntry;
|
||||||
boolean dossierDictionaryEntry;
|
boolean dossierDictionaryEntry;
|
||||||
@ -64,7 +63,7 @@ public class TextEntity implements IEntity {
|
|||||||
|
|
||||||
public static TextEntity initialEntityNode(TextRange textRange, String type, EntityType entityType) {
|
public static TextEntity initialEntityNode(TextRange textRange, String type, EntityType entityType) {
|
||||||
|
|
||||||
return TextEntity.builder().type(type).entityType(entityType).textRange(textRange).build();
|
return TextEntity.builder().type(type).entityType(entityType).textRange(textRange).manualOverwrite(new ManualChangeOverwrite(entityType)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -131,4 +131,45 @@ public class ManualChangesUnitTest extends BuildDocumentIntegrationTest {
|
|||||||
assertEquals("type", entity.getManualOverwrite().getType().orElse(entity.getType()));
|
assertEquals("type", entity.getManualOverwrite().getType().orElse(entity.getType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemoveHintForceHint() {
|
||||||
|
|
||||||
|
OffsetDateTime start = OffsetDateTime.now();
|
||||||
|
String reason = "whatever";
|
||||||
|
Document document = buildGraphNoImages("files/new/crafted document.pdf");
|
||||||
|
List<TextEntity> entities = entityCreationService.byString("David Ksenia", "test", EntityType.HINT, document).peek(e -> e.apply("T.0.0", reason)).toList();
|
||||||
|
assertFalse(entities.isEmpty());
|
||||||
|
TextEntity entity = entities.get(0);
|
||||||
|
assertTrue(entity.active());
|
||||||
|
assertTrue(entity.applied());
|
||||||
|
assertFalse(entity.removed());
|
||||||
|
assertFalse(entity.resized());
|
||||||
|
assertFalse(entity.ignored());
|
||||||
|
assertEquals("n-a", entity.getMatchedRule().getLegalBasis());
|
||||||
|
String annotationId = entity.getPositionsOnPagePerPage().get(0).getId();
|
||||||
|
|
||||||
|
// remove first
|
||||||
|
IdRemoval removal = IdRemoval.builder().requestDate(start).fileId(TEST_FILE_ID).annotationId(annotationId).status(AnnotationStatus.APPROVED).build();
|
||||||
|
entity.getManualOverwrite().addChange(removal);
|
||||||
|
assertTrue(entity.ignored());
|
||||||
|
assertFalse(entity.applied());
|
||||||
|
assertEquals(reason + ", removed by manual override", entity.buildReasonWithManualChangeDescriptions());
|
||||||
|
|
||||||
|
// force again
|
||||||
|
ManualForceRedaction forceRedaction = ManualForceRedaction.builder()
|
||||||
|
.requestDate(start.plusSeconds(1))
|
||||||
|
.fileId(TEST_FILE_ID)
|
||||||
|
.annotationId(annotationId)
|
||||||
|
.legalBasis("coolio")
|
||||||
|
.status(AnnotationStatus.APPROVED)
|
||||||
|
.build();
|
||||||
|
entity.getManualOverwrite().addChange(forceRedaction);
|
||||||
|
assertFalse(entity.applied());
|
||||||
|
assertFalse(entity.ignored());
|
||||||
|
assertFalse(entity.removed());
|
||||||
|
assertEquals(reason + ", removed by manual override, forced by manual override", entity.buildReasonWithManualChangeDescriptions());
|
||||||
|
assertEquals("coolio", entity.getManualOverwrite().getLegalBasis().orElse(entity.getMatchedRule().getLegalBasis()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user