RED-8702: Explore document databases to store entityLog
* bugfix for failing tests
This commit is contained in:
parent
3b4c34eafe
commit
c2c53f8998
@ -26,20 +26,12 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
|
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
|
||||||
public class EntityChangeLogService {
|
public class EntityChangeLogService {
|
||||||
|
|
||||||
//EntityLogMongoService entityLogMongoService;
|
|
||||||
|
|
||||||
|
|
||||||
@Timed("redactmanager_computeChanges")
|
@Timed("redactmanager_computeChanges")
|
||||||
public EntryChanges computeChanges(//String dossierId,
|
public EntryChanges computeChanges(List<EntityLogEntry> previousEntityLogEntries, List<EntityLogEntry> newEntityLogEntries, int analysisNumber) {
|
||||||
//String fileId,
|
|
||||||
List<EntityLogEntry> previousEntityLogEntries,
|
|
||||||
List<EntityLogEntry> newEntityLogEntries,
|
|
||||||
int analysisNumber) {
|
|
||||||
|
|
||||||
var now = OffsetDateTime.now();
|
var now = OffsetDateTime.now();
|
||||||
if (previousEntityLogEntries.isEmpty()) {
|
if (previousEntityLogEntries.isEmpty()) {
|
||||||
newEntityLogEntries.forEach(entry -> entry.getChanges().add(new Change(analysisNumber, ChangeType.ADDED, now)));
|
newEntityLogEntries.forEach(entry -> entry.getChanges().add(new Change(analysisNumber, ChangeType.ADDED, now)));
|
||||||
//entityLogMongoService.insertEntityLogEntries(dossierId, fileId, newEntityLogEntries);
|
|
||||||
return new EntryChanges(newEntityLogEntries, new ArrayList<>());
|
return new EntryChanges(newEntityLogEntries, new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,18 +55,13 @@ public class EntityChangeLogService {
|
|||||||
toUpdate.add(entityLogEntry);
|
toUpdate.add(entityLogEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//entityLogMongoService.insertEntityLogEntries(dossierId, fileId, toInsert);
|
|
||||||
//entityLogMongoService.updateEntityLogEntries(dossierId, fileId, toUpdate);
|
|
||||||
|
|
||||||
toUpdate.addAll(addRemovedEntriesAsRemoved(//dossierId, fileId,
|
toUpdate.addAll(addRemovedEntriesAsRemoved(previousEntityLogEntries, newEntityLogEntries, analysisNumber, now));
|
||||||
previousEntityLogEntries, newEntityLogEntries, analysisNumber, now));
|
|
||||||
return new EntryChanges(toInsert, toUpdate);
|
return new EntryChanges(toInsert, toUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<EntityLogEntry> addRemovedEntriesAsRemoved(//String dossierId,
|
private List<EntityLogEntry> addRemovedEntriesAsRemoved(List<EntityLogEntry> previousEntityLogEntries,
|
||||||
//String fileId,
|
|
||||||
List<EntityLogEntry> previousEntityLogEntries,
|
|
||||||
List<EntityLogEntry> newEntityLogEntries,
|
List<EntityLogEntry> newEntityLogEntries,
|
||||||
int analysisNumber,
|
int analysisNumber,
|
||||||
OffsetDateTime now) {
|
OffsetDateTime now) {
|
||||||
@ -89,7 +76,6 @@ public class EntityChangeLogService {
|
|||||||
.filter(entry -> !entry.getState().equals(EntryState.REMOVED))
|
.filter(entry -> !entry.getState().equals(EntryState.REMOVED))
|
||||||
.peek(entry -> entry.getChanges().add(new Change(analysisNumber, ChangeType.REMOVED, now)))
|
.peek(entry -> entry.getChanges().add(new Change(analysisNumber, ChangeType.REMOVED, now)))
|
||||||
.forEach(entry -> entry.setState(EntryState.REMOVED));
|
.forEach(entry -> entry.setState(EntryState.REMOVED));
|
||||||
//entityLogMongoService.updateEntityLogEntries(dossierId, fileId, removedEntries);
|
|
||||||
newEntityLogEntries.addAll(removedEntries);
|
newEntityLogEntries.addAll(removedEntries);
|
||||||
return removedEntries;
|
return removedEntries;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -128,7 +128,7 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
|
|||||||
|
|
||||||
String EFSA_SANITISATION_RULES = loadFromClassPath("drools/efsa_sanitisation.drl");
|
String EFSA_SANITISATION_RULES = loadFromClassPath("drools/efsa_sanitisation.drl");
|
||||||
when(rulesClient.getRules(TEST_DOSSIER_TEMPLATE_ID, RuleFileType.ENTITY)).thenReturn(JSONPrimitive.of(EFSA_SANITISATION_RULES));
|
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");
|
System.out.println("Start Full integration test");
|
||||||
analyzeDocumentStructure(LayoutParsingType.REDACT_MANAGER, request);
|
analyzeDocumentStructure(LayoutParsingType.REDACT_MANAGER, request);
|
||||||
System.out.println("Finished structure analysis");
|
System.out.println("Finished structure analysis");
|
||||||
@ -194,7 +194,7 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
|
|||||||
|
|
||||||
String EFSA_SANITISATION_RULES = loadFromClassPath("drools/efsa_sanitisation.drl");
|
String EFSA_SANITISATION_RULES = loadFromClassPath("drools/efsa_sanitisation.drl");
|
||||||
when(rulesClient.getRules(TEST_DOSSIER_TEMPLATE_ID, RuleFileType.ENTITY)).thenReturn(JSONPrimitive.of(EFSA_SANITISATION_RULES));
|
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");
|
System.out.println("Start Full integration test");
|
||||||
analyzeDocumentStructure(LayoutParsingType.REDACT_MANAGER, request);
|
analyzeDocumentStructure(LayoutParsingType.REDACT_MANAGER, request);
|
||||||
System.out.println("Finished structure analysis");
|
System.out.println("Finished structure analysis");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user