RED-9084: Paragraph/Location value missing for manual redaction on re-uploaded preview file

This commit is contained in:
Maverick Studer 2024-05-06 17:08:46 +02:00
parent af8a7dac42
commit b5f0c25752
7 changed files with 32 additions and 6 deletions

View File

@ -7,7 +7,7 @@ description = "redaction-service-api-v1"
dependencies { dependencies {
implementation("org.springframework:spring-web:6.0.12") implementation("org.springframework:spring-web:6.0.12")
implementation("com.iqser.red.service:persistence-service-internal-api-v1:2.410.0") implementation("com.iqser.red.service:persistence-service-internal-api-v1:2.411.0")
} }
publishing { publishing {

View File

@ -16,7 +16,7 @@ val layoutParserVersion = "0.116.0"
val jacksonVersion = "2.15.2" val jacksonVersion = "2.15.2"
val droolsVersion = "9.44.0.Final" val droolsVersion = "9.44.0.Final"
val pdfBoxVersion = "3.0.0" val pdfBoxVersion = "3.0.0"
val persistenceServiceVersion = "2.410.0" val persistenceServiceVersion = "2.411.0"
val springBootStarterVersion = "3.1.5" val springBootStarterVersion = "3.1.5"
val springCloudVersion = "4.0.4" val springCloudVersion = "4.0.4"
val testContainersVersion = "1.19.7" val testContainersVersion = "1.19.7"

View File

@ -130,11 +130,12 @@ public class PrecursorEntity implements IEntity {
.orElse("")) .orElse(""))
.type(Optional.ofNullable(importedRedaction.getType()) .type(Optional.ofNullable(importedRedaction.getType())
.orElse(IMPORTED_REDACTION_TYPE)) .orElse(IMPORTED_REDACTION_TYPE))
.section(importedRedaction.getManualOverwriteSection())
.entityType(entityType) .entityType(entityType)
.isDictionaryEntry(false) .isDictionaryEntry(false)
.isDossierDictionaryEntry(false) .isDossierDictionaryEntry(false)
.rectangle(value.isBlank() || entryType.equals(EntryType.IMAGE) || entryType.equals(EntryType.IMAGE_HINT) || entryType.equals(EntryType.AREA)) .rectangle(value.isBlank() || entryType.equals(EntryType.IMAGE) || entryType.equals(EntryType.IMAGE_HINT) || entryType.equals(EntryType.AREA))
.manualOverwrite(new ManualChangeOverwrite(entityType)) .manualOverwrite(new ManualChangeOverwrite(entityType, importedRedaction.getManualOverwriteSection()))
.engines(Set.of(Engine.IMPORTED)) .engines(Set.of(Engine.IMPORTED))
.build(); .build();
} }

View File

@ -34,6 +34,7 @@ public class ManualChangeOverwrite {
IdRemoval.class, "removed by manual override", // IdRemoval.class, "removed by manual override", //
ManualRecategorization.class, "recategorized by manual override"); ManualRecategorization.class, "recategorized by manual override");
@Builder.Default
List<BaseAnnotation> manualChanges = new LinkedList<>(); List<BaseAnnotation> manualChanges = new LinkedList<>();
boolean changed; boolean changed;
List<String> descriptions; List<String> descriptions;
@ -59,6 +60,13 @@ public class ManualChangeOverwrite {
public ManualChangeOverwrite(EntityType entityType) { public ManualChangeOverwrite(EntityType entityType) {
this.entityType = entityType; this.entityType = entityType;
this.manualChanges = new LinkedList<>();
}
public ManualChangeOverwrite(EntityType entityType, String section) {
this(entityType);
this.section = section;
} }

View File

@ -83,6 +83,18 @@ public class TextEntity implements IEntity {
} }
public static TextEntity initialEntityNode(TextRange textRange, String type, EntityType entityType, String id, String manualOverwriteSection) {
return TextEntity.builder()
.id(id)
.type(type)
.entityType(entityType)
.textRange(textRange)
.manualOverwrite(ManualChangeOverwrite.builder().entityType(entityType).section(manualOverwriteSection).build())
.build();
}
private static String buildId(SemanticNode node, TextRange textRange, String type, EntityType entityType) { private static String buildId(SemanticNode node, TextRange textRange, String type, EntityType entityType) {
Map<Page, List<Rectangle2D>> rectanglesPerLinePerPage = node.getPositionsPerPage(textRange); Map<Page, List<Rectangle2D>> rectanglesPerLinePerPage = node.getPositionsPerPage(textRange);

View File

@ -157,7 +157,7 @@ public class EntityLogCreatorService {
.forEach(imageNode -> entries.add(createEntityLogEntry(imageNode, dossierTemplateId))); .forEach(imageNode -> entries.add(createEntityLogEntry(imageNode, dossierTemplateId)));
notFoundPrecursorEntries.stream() notFoundPrecursorEntries.stream()
.filter(entity -> !entity.removed()) .filter(entity -> !entity.removed())
.forEach(precursorEntity -> entries.add(createEntityLogEntry(precursorEntity, dossierTemplateId))); .forEach(precursorEntity -> entries.add(createEntityLogEntry(precursorEntity)));
return entries; return entries;
} }
@ -213,7 +213,7 @@ public class EntityLogCreatorService {
} }
private EntityLogEntry createEntityLogEntry(PrecursorEntity precursorEntity, String dossierTemplateId) { private EntityLogEntry createEntityLogEntry(PrecursorEntity precursorEntity) {
String type = precursorEntity.getManualOverwrite().getType() String type = precursorEntity.getManualOverwrite().getType()
.orElse(precursorEntity.getType()); .orElse(precursorEntity.getType());

View File

@ -125,7 +125,12 @@ public class EntityFromPrecursorCreationService {
precursorEntity.getEntityType(), precursorEntity.getEntityType(),
closestEntity.getDeepestFullyContainingNode()); closestEntity.getDeepestFullyContainingNode());
} else { } else {
correctEntity = TextEntity.initialEntityNode(closestEntity.getTextRange(), precursorEntity.type(), precursorEntity.getEntityType(), precursorEntity.getId()); correctEntity = TextEntity.initialEntityNode(closestEntity.getTextRange(),
precursorEntity.type(),
precursorEntity.getEntityType(),
precursorEntity.getId(),
precursorEntity.getManualOverwrite().getSection()
.orElse(null));
} }
correctEntity.setDeepestFullyContainingNode(closestEntity.getDeepestFullyContainingNode()); correctEntity.setDeepestFullyContainingNode(closestEntity.getDeepestFullyContainingNode());
correctEntity.setIntersectingNodes(new ArrayList<>(closestEntity.getIntersectingNodes())); correctEntity.setIntersectingNodes(new ArrayList<>(closestEntity.getIntersectingNodes()));