RED-8702: Explore document databases to store entityLog

* bugfix for failing tests
This commit is contained in:
maverickstuder 2024-03-28 14:09:50 +01:00
parent 3b4c34eafe
commit c2c53f8998
2 changed files with 5 additions and 19 deletions

View File

@ -26,20 +26,12 @@ import lombok.extern.slf4j.Slf4j;
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
public class EntityChangeLogService {
//EntityLogMongoService entityLogMongoService;
@Timed("redactmanager_computeChanges")
public EntryChanges computeChanges(//String dossierId,
//String fileId,
List<EntityLogEntry> previousEntityLogEntries,
List<EntityLogEntry> newEntityLogEntries,
int analysisNumber) {
public EntryChanges computeChanges(List<EntityLogEntry> previousEntityLogEntries, List<EntityLogEntry> newEntityLogEntries, int analysisNumber) {
var now = OffsetDateTime.now();
if (previousEntityLogEntries.isEmpty()) {
newEntityLogEntries.forEach(entry -> entry.getChanges().add(new Change(analysisNumber, ChangeType.ADDED, now)));
//entityLogMongoService.insertEntityLogEntries(dossierId, fileId, newEntityLogEntries);
return new EntryChanges(newEntityLogEntries, new ArrayList<>());
}
@ -63,18 +55,13 @@ public class EntityChangeLogService {
toUpdate.add(entityLogEntry);
}
}
//entityLogMongoService.insertEntityLogEntries(dossierId, fileId, toInsert);
//entityLogMongoService.updateEntityLogEntries(dossierId, fileId, toUpdate);
toUpdate.addAll(addRemovedEntriesAsRemoved(//dossierId, fileId,
previousEntityLogEntries, newEntityLogEntries, analysisNumber, now));
toUpdate.addAll(addRemovedEntriesAsRemoved(previousEntityLogEntries, newEntityLogEntries, analysisNumber, now));
return new EntryChanges(toInsert, toUpdate);
}
private List<EntityLogEntry> addRemovedEntriesAsRemoved(//String dossierId,
//String fileId,
List<EntityLogEntry> previousEntityLogEntries,
private List<EntityLogEntry> addRemovedEntriesAsRemoved(List<EntityLogEntry> previousEntityLogEntries,
List<EntityLogEntry> newEntityLogEntries,
int analysisNumber,
OffsetDateTime now) {
@ -89,7 +76,6 @@ public class EntityChangeLogService {
.filter(entry -> !entry.getState().equals(EntryState.REMOVED))
.peek(entry -> entry.getChanges().add(new Change(analysisNumber, ChangeType.REMOVED, now)))
.forEach(entry -> entry.setState(EntryState.REMOVED));
//entityLogMongoService.updateEntityLogEntries(dossierId, fileId, removedEntries);
newEntityLogEntries.addAll(removedEntries);
return removedEntries;
}

View File

@ -128,7 +128,7 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
String EFSA_SANITISATION_RULES = loadFromClassPath("drools/efsa_sanitisation.drl");
when(rulesClient.getRules(TEST_DOSSIER_TEMPLATE_ID, RuleFileType.ENTITY)).thenReturn(JSONPrimitive.of(EFSA_SANITISATION_RULES));
AnalyzeRequest request = uploadFileToStorage("files/syngenta/CustomerFiles/SYNGENTA_EFSA_sanitisation_GFL_v1_moreSections.pdf");
AnalyzeRequest request = uploadFileToStorage("files/new/SYNGENTA_EFSA_sanitisation_GFL_v1_moreSections.pdf");
System.out.println("Start Full integration test");
analyzeDocumentStructure(LayoutParsingType.REDACT_MANAGER, request);
System.out.println("Finished structure analysis");
@ -194,7 +194,7 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
String EFSA_SANITISATION_RULES = loadFromClassPath("drools/efsa_sanitisation.drl");
when(rulesClient.getRules(TEST_DOSSIER_TEMPLATE_ID, RuleFileType.ENTITY)).thenReturn(JSONPrimitive.of(EFSA_SANITISATION_RULES));
AnalyzeRequest request = uploadFileToStorage("files/syngenta/CustomerFiles/SYNGENTA_EFSA_sanitisation_GFL_v1_moreSections.pdf");
AnalyzeRequest request = uploadFileToStorage("files/new/SYNGENTA_EFSA_sanitisation_GFL_v1_moreSections.pdf");
System.out.println("Start Full integration test");
analyzeDocumentStructure(LayoutParsingType.REDACT_MANAGER, request);
System.out.println("Finished structure analysis");