DM-483 - Prevent endless loops

* cleanups and renaming redaction log to entity log
This commit is contained in:
Andrei Isvoran 2023-10-12 15:14:56 +03:00
parent 92ea6fdb99
commit 5cf8a06761
4 changed files with 9 additions and 9 deletions

View File

@ -105,7 +105,7 @@ public class RedactionStorageService {
try { try {
return storageService.readJSONObject(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, FileType.ENTITY_LOG), EntityLog.class); return storageService.readJSONObject(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, FileType.ENTITY_LOG), EntityLog.class);
} catch (StorageObjectDoesNotExist e) { } catch (StorageObjectDoesNotExist e) {
log.debug("RedactionLog not available."); log.debug("EntityLog not available.");
return null; return null;
} }

View File

@ -112,7 +112,7 @@ public class DocumineFloraTest extends AbstractRedactionIntegrationTest {
// Fix In BodyTextFrameService destroys header detection in files/new/SYNGENTA_EFSA_sanitisation_GFL_v1_moreSections.pdf // Fix In BodyTextFrameService destroys header detection in files/new/SYNGENTA_EFSA_sanitisation_GFL_v1_moreSections.pdf
// TODO unify logic // TODO unify logic
AnalyzeRequest request = uploadFileToStorage("files/Documine/Flora/402Study.pdf"); AnalyzeRequest request = uploadFileToStorage("files/Documine/Flora/402Study-ocred.pdf");
System.out.println("Start Full integration test"); System.out.println("Start Full integration test");
analyzeDocumentStructure(LayoutParsingType.DOCUMINE, request); analyzeDocumentStructure(LayoutParsingType.DOCUMINE, request);

View File

@ -82,13 +82,13 @@ public class AnnotationService {
private void annotate(PDDocument document, EntityLog entityLog) throws IOException { private void annotate(PDDocument document, EntityLog entityLog) throws IOException {
Map<Integer, List<EntityLogEntry>> redactionLogPerPage = groupingByPageNumber(entityLog); Map<Integer, List<EntityLogEntry>> entityLogPerPage = groupingByPageNumber(entityLog);
for (int page = 1; page <= document.getNumberOfPages(); page++) { for (int page = 1; page <= document.getNumberOfPages(); page++) {
PDPage pdPage = document.getPage(page - 1); PDPage pdPage = document.getPage(page - 1);
List<EntityLogEntry> logEntries = redactionLogPerPage.get(page); List<EntityLogEntry> logEntries = entityLogPerPage.get(page);
if (logEntries != null && !logEntries.isEmpty()) { if (logEntries != null && !logEntries.isEmpty()) {
addAnnotations(logEntries, pdPage, page); addAnnotations(logEntries, pdPage, page);
} }
@ -98,20 +98,20 @@ public class AnnotationService {
private Map<Integer, List<EntityLogEntry>> groupingByPageNumber(EntityLog redactionLog) { private Map<Integer, List<EntityLogEntry>> groupingByPageNumber(EntityLog redactionLog) {
Map<Integer, List<EntityLogEntry>> redactionLogPerPage = new HashMap<>(); Map<Integer, List<EntityLogEntry>> entityLogPerPage = new HashMap<>();
if (redactionLog == null) { if (redactionLog == null) {
return redactionLogPerPage; return entityLogPerPage;
} }
for (EntityLogEntry entry : redactionLog.getEntityLogEntry()) { for (EntityLogEntry entry : redactionLog.getEntityLogEntry()) {
int page = 0; int page = 0;
for (Position position : entry.getPositions()) { for (Position position : entry.getPositions()) {
if (position.getPageNumber() != page) { if (position.getPageNumber() != page) {
redactionLogPerPage.computeIfAbsent(position.getPageNumber(), x -> new ArrayList<>()).add(entry); entityLogPerPage.computeIfAbsent(position.getPageNumber(), x -> new ArrayList<>()).add(entry);
page = position.getPageNumber(); page = position.getPageNumber();
} }
} }
} }
return redactionLogPerPage; return entityLogPerPage;
} }