RED-8034: Always load entityLog from persistence-service because excluded pages are calculated there
This commit is contained in:
parent
73aedb58db
commit
b2271b3e5a
@ -23,9 +23,7 @@ public class ReportRequestMessage {
|
||||
private String dossierId;
|
||||
|
||||
private String dossierTemplateId;
|
||||
|
||||
private Boolean includeUnprocessed;
|
||||
|
||||
|
||||
@Builder.Default
|
||||
private List<String> fileIds = new ArrayList<>();
|
||||
|
||||
|
||||
@ -14,6 +14,5 @@ public class ReportResultMessage {
|
||||
private String userId;
|
||||
private String downloadId;
|
||||
private String reportFileInformationStorageId;
|
||||
private Boolean includeUnprocessed;
|
||||
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ public class EntityLogConverterService {
|
||||
|
||||
|
||||
@Timed("redactmanager_getReportEntries")
|
||||
public List<ReportRedactionEntry> getReportEntries(String dossierId, String fileId, boolean isExcluded, boolean includeUnprocessed) {
|
||||
public List<ReportRedactionEntry> getReportEntries(String dossierId, String fileId, boolean isExcluded) {
|
||||
|
||||
if (isExcluded) {
|
||||
return new ArrayList<>();
|
||||
@ -64,11 +64,7 @@ public class EntityLogConverterService {
|
||||
EntityLog entityLog;
|
||||
Map<String, String> mapOfEntityDisplayName;
|
||||
try {
|
||||
if (includeUnprocessed) {
|
||||
entityLog = entityLogClient.getEntityLog(dossierId, fileId, null, includeUnprocessed);
|
||||
} else {
|
||||
entityLog = reportStorageService.getEntityLog(dossierId, fileId, new ArrayList<>());
|
||||
}
|
||||
entityLog = entityLogClient.getEntityLog(dossierId, fileId, null, true);
|
||||
mapOfEntityDisplayName = fillMapOfTypeAndEntityDisplayName(dossierId);
|
||||
} catch (StorageObjectDoesNotExist e) {
|
||||
return new ArrayList<>();
|
||||
@ -133,7 +129,7 @@ public class EntityLogConverterService {
|
||||
settings.getMaxRedactionEntryValueLength());
|
||||
}
|
||||
|
||||
if (settings.getMaxSectionLength() > 0 && entry.getSection() != null && entry.getSection().length() > settings.getMaxSectionLength()){
|
||||
if (settings.getMaxSectionLength() > 0 && entry.getSection() != null && entry.getSection().length() > settings.getMaxSectionLength()) {
|
||||
entry.setSection(entry.getSection().substring(0, settings.getMaxSectionLength()) + "...");
|
||||
log.warn("Truncated section in dossier {}, file {} on pages {} to {} chars",
|
||||
dossierId,
|
||||
@ -142,7 +138,6 @@ public class EntityLogConverterService {
|
||||
settings.getMaxSectionLength());
|
||||
}
|
||||
|
||||
|
||||
if (!entry.getManualChanges().isEmpty() && (entry.getEntryType() == EntryType.IMAGE || entry.getEntryType() == EntryType.IMAGE_HINT) && entry.getManualChanges()
|
||||
.get(entry.getManualChanges().size() - 1)
|
||||
.getProcessedDate() == null && entry.getManualChanges()
|
||||
|
||||
@ -78,7 +78,7 @@ public class ReportGenerationService {
|
||||
var fileStatus = fileStatusClient.getFileStatus(dossierId, fileId);
|
||||
generatePlaceholderService.resolveFileAttributeValues(fileStatus, placeholderModel);
|
||||
|
||||
List<ReportRedactionEntry> reportEntries = entityLogConverterService.getReportEntries(dossierId, fileId, fileStatus.isExcluded(), reportMessage.getIncludeUnprocessed());
|
||||
List<ReportRedactionEntry> reportEntries = entityLogConverterService.getReportEntries(dossierId, fileId, fileStatus.isExcluded());
|
||||
|
||||
generateMultiFileExcelReports(reportTemplates.multiFileWorkbookReportTemplates, placeholderModel, fileStatus, isLastFile, dossierName, reportEntries);
|
||||
|
||||
|
||||
@ -44,20 +44,16 @@ public class ReportMessageReceiver {
|
||||
log.info("Start generating reports for downloadId {}", reportMessage.getDownloadId());
|
||||
|
||||
var reportFileInformationStorageId = reportGenerationService.generateReports(reportMessage);
|
||||
addToReportResultQueue(reportMessage.getUserId(), reportMessage.getDownloadId(), reportFileInformationStorageId, 1,
|
||||
reportMessage.getIncludeUnprocessed() == null || reportMessage.getIncludeUnprocessed());
|
||||
addToReportResultQueue(reportMessage.getUserId(), reportMessage.getDownloadId(), reportFileInformationStorageId);
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
log.info("Successfully generated reports for downloadId {}, took {}", reportMessage.getDownloadId(), end - start);
|
||||
}
|
||||
|
||||
|
||||
private void addToReportResultQueue(String userId, String downloadId, String reportFileInformationStorageId, int priority, boolean includeUnprocessed) {
|
||||
private void addToReportResultQueue(String userId, String downloadId, String reportFileInformationStorageId) {
|
||||
|
||||
rabbitTemplate.convertAndSend(REPORT_RESULT_QUEUE, new ReportResultMessage(userId, downloadId, reportFileInformationStorageId, includeUnprocessed), message -> {
|
||||
message.getMessageProperties().setPriority(priority);
|
||||
return message;
|
||||
});
|
||||
rabbitTemplate.convertAndSend(REPORT_RESULT_QUEUE, new ReportResultMessage(userId, downloadId, reportFileInformationStorageId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -234,6 +234,7 @@ public class RedactionReportV2IntegrationTest {
|
||||
|
||||
var entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
|
||||
fileSystemBackedStorageService.storeJSONObject(TenantContext.getTenantId(), StorageIdUtils.getStorageId("dossierId", "fileId" + id, FileType.ENTITY_LOG), entityLog);
|
||||
when(entityLogClient.getEntityLog("dossierId", "fileId" + id, null, true)).thenReturn(entityLog);
|
||||
}
|
||||
|
||||
|
||||
@ -242,7 +243,6 @@ public class RedactionReportV2IntegrationTest {
|
||||
public void testBasicExcelReportFlow() {
|
||||
|
||||
var reportRequestMessage = prepareFlow(2, "templates/Excel QC (incl. Skipped Redactions).xlsx");
|
||||
reportRequestMessage.setIncludeUnprocessed(false);
|
||||
processRequest(reportRequestMessage, ".xlsx");
|
||||
|
||||
MetricValidationUtils.validateMetric(prometheusMeterRegistry, "redactmanager_generateReports", 1, null);
|
||||
@ -257,7 +257,6 @@ public class RedactionReportV2IntegrationTest {
|
||||
public void testMultifileWordReportFlow() {
|
||||
|
||||
var reportRequestMessage = prepareFlow(2, "templates/Justification Appendix A1.docx");
|
||||
reportRequestMessage.setIncludeUnprocessed(false);
|
||||
processRequest(reportRequestMessage, ".docx");
|
||||
|
||||
MetricValidationUtils.validateMetric(prometheusMeterRegistry, "redactmanager_generateReports", 1, null);
|
||||
@ -274,7 +273,6 @@ public class RedactionReportV2IntegrationTest {
|
||||
public void test2FilesConcurrently() {
|
||||
|
||||
var reportRequestMessage = prepareFlow(1, "templates/report.xlsx", "templates/report-advanced.xlsx");
|
||||
reportRequestMessage.setIncludeUnprocessed(false);
|
||||
processRequest(reportRequestMessage, ".xlsx");
|
||||
|
||||
MetricValidationUtils.validateMetric(prometheusMeterRegistry, "redactmanager_generateReports", 1, null);
|
||||
@ -289,7 +287,6 @@ public class RedactionReportV2IntegrationTest {
|
||||
public void testIncludeUnprocessed() {
|
||||
|
||||
var reportRequestMessage = prepareFlow(2, "templates/Excel QC (incl. Skipped Redactions).xlsx");
|
||||
reportRequestMessage.setIncludeUnprocessed(true);
|
||||
when(entityLogClient.getEntityLog(anyString(), anyString(), any(), eq(true))).thenReturn(new EntityLog(1,
|
||||
1,
|
||||
List.of(EntityLogEntry.builder()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user