RED-7156: some files stuck in error state
* fix pmd errors
This commit is contained in:
parent
330a3880a0
commit
4a8ee21971
@ -48,21 +48,21 @@ public class CustomEntityCreationAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Stream<RedactionEntity> toRedactionEntity(RedactionLog redactionLog, SemanticNode node) {
|
public List<RedactionEntity> toRedactionEntity(RedactionLog redactionLog, SemanticNode node) {
|
||||||
|
|
||||||
List<EntityIdentifier> entityIdentifiers = redactionLog.getRedactionLogEntry().stream().map(EntityIdentifier::fromRedactionLogEntry).toList();
|
List<EntityIdentifier> entityIdentifiers = redactionLog.getRedactionLogEntry().stream().map(EntityIdentifier::fromRedactionLogEntry).toList();
|
||||||
return toRedactionEntity(entityIdentifiers, node);
|
return toRedactionEntity(entityIdentifiers, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Stream<RedactionEntity> createRedactionEntities(Set<ManualRedactionEntry> manualRedactionEntries, SemanticNode node) {
|
public List<RedactionEntity> createRedactionEntities(Set<ManualRedactionEntry> manualRedactionEntries, SemanticNode node) {
|
||||||
|
|
||||||
List<EntityIdentifier> entityIdentifiers = manualRedactionEntries.stream().map(EntityIdentifier::fromManualRedactionEntry).toList();
|
List<EntityIdentifier> entityIdentifiers = manualRedactionEntries.stream().map(EntityIdentifier::fromManualRedactionEntry).toList();
|
||||||
return toRedactionEntity(entityIdentifiers, node);
|
return toRedactionEntity(entityIdentifiers, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Stream<RedactionEntity> toRedactionEntity(List<EntityIdentifier> entityIdentifiers, SemanticNode node) {
|
private List<RedactionEntity> toRedactionEntity(List<EntityIdentifier> entityIdentifiers, SemanticNode node) {
|
||||||
|
|
||||||
Set<Integer> pageNumbers = entityIdentifiers.stream().flatMap(entry -> entry.entityPosition().stream().map(RectangleWithPage::pageNumber)).collect(Collectors.toSet());
|
Set<Integer> pageNumbers = entityIdentifiers.stream().flatMap(entry -> entry.entityPosition().stream().map(RectangleWithPage::pageNumber)).collect(Collectors.toSet());
|
||||||
Set<String> entryValues = entityIdentifiers.stream().map(EntityIdentifier::value).map(String::toLowerCase).collect(Collectors.toSet());
|
Set<String> entryValues = entityIdentifiers.stream().map(EntityIdentifier::value).map(String::toLowerCase).collect(Collectors.toSet());
|
||||||
@ -78,7 +78,7 @@ public class CustomEntityCreationAdapter {
|
|||||||
.map(Optional::get)
|
.map(Optional::get)
|
||||||
.toList();
|
.toList();
|
||||||
tempEntitiesByValue.values().stream().flatMap(Collection::stream).forEach(RedactionEntity::removeFromGraph);
|
tempEntitiesByValue.values().stream().flatMap(Collection::stream).forEach(RedactionEntity::removeFromGraph);
|
||||||
return correctEntities.stream();
|
return correctEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -77,7 +77,7 @@ public class EntityRedactionService {
|
|||||||
public void addManualAddRedactionEntities(Set<ManualRedactionEntry> manualRedactionEntries, Document document) {
|
public void addManualAddRedactionEntities(Set<ManualRedactionEntry> manualRedactionEntries, Document document) {
|
||||||
|
|
||||||
// Entities are automatically added to the DocumentGraph and don't need to be inserted again.
|
// Entities are automatically added to the DocumentGraph and don't need to be inserted again.
|
||||||
List<RedactionEntity> entities = customEntityCreationAdapter.createRedactionEntities(manualRedactionEntries, document).toList();
|
customEntityCreationAdapter.createRedactionEntities(manualRedactionEntries, document);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -89,7 +90,7 @@ public class MigrationPocTest extends BuildDocumentIntegrationTest {
|
|||||||
|
|
||||||
// IMPORTANT: always use the graph which is mapped from the DocumentData, since rounding errors occur during storage.
|
// IMPORTANT: always use the graph which is mapped from the DocumentData, since rounding errors occur during storage.
|
||||||
Document document = DocumentGraphMapper.toDocumentGraph(DocumentData.fromDocument(buildGraph("files/new/crafted document.pdf")));
|
Document document = DocumentGraphMapper.toDocumentGraph(DocumentData.fromDocument(buildGraph("files/new/crafted document.pdf")));
|
||||||
Set<RedactionEntity> migratedEntities = redactionLogAdapter.toRedactionEntity(originalRedactionLog, document).collect(Collectors.toSet());
|
redactionLogAdapter.toRedactionEntity(originalRedactionLog, document);
|
||||||
|
|
||||||
var migratedRedactionLogEntries = redactionLogCreatorService.createRedactionLog(document, TEST_DOSSIER_TEMPLATE_ID);
|
var migratedRedactionLogEntries = redactionLogCreatorService.createRedactionLog(document, TEST_DOSSIER_TEMPLATE_ID);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user