diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/pom.xml b/redaction-report-service-v1/redaction-report-service-server-v1/pom.xml index 95b8959..d032209 100644 --- a/redaction-report-service-v1/redaction-report-service-server-v1/pom.xml +++ b/redaction-report-service-v1/redaction-report-service-server-v1/pom.xml @@ -49,6 +49,13 @@ + + + com.iqser.red.service + file-management-service-api-v1 + 2.8.3.1 + + org.apache.poi poi diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/client/FileStatusClient.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/client/FileStatusClient.java new file mode 100644 index 0000000..86e0d73 --- /dev/null +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/client/FileStatusClient.java @@ -0,0 +1,10 @@ +package com.iqser.red.service.redaction.report.v1.server.client; + +import org.springframework.cloud.openfeign.FeignClient; + +import com.iqser.red.service.file.management.v1.api.resources.StatusResource; + +@FeignClient(name = "StatusResource", url = "${file-management-service.url}") +public interface FileStatusClient extends StatusResource { + +} diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ReportGenerationService.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ReportGenerationService.java index be37011..a254cf6 100644 --- a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ReportGenerationService.java +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ReportGenerationService.java @@ -1,9 +1,11 @@ package com.iqser.red.service.redaction.report.v1.server.service; import com.iqser.red.service.configuration.v1.api.model.LegalBasisMapping; +import com.iqser.red.service.file.management.v1.api.model.FileStatus; import com.iqser.red.service.redaction.report.v1.api.model.ReportRequestMessage; import com.iqser.red.service.redaction.report.v1.api.model.ReportType; import com.iqser.red.service.redaction.report.v1.api.model.StoredFileInformation; +import com.iqser.red.service.redaction.report.v1.server.client.FileStatusClient; import com.iqser.red.service.redaction.report.v1.server.client.LegalBasisMappingClient; import com.iqser.red.service.redaction.report.v1.server.model.ReportRedactionEntry; import com.iqser.red.service.redaction.report.v1.server.storage.ReportStorageService; @@ -28,6 +30,7 @@ public class ReportGenerationService { private final WordReportGenerationService wordReportGenerationService; private final LegalBasisMappingClient legalBasisMappingClient; private final RedactionLogConverterService redactionLogConverterService; + private final FileStatusClient fileStatusClient; public List generateReport(ReportRequestMessage reportMessage) { @@ -47,6 +50,8 @@ public class ReportGenerationService { int i = 1; for (String fileId : reportMessage.getFileIds()) { + FileStatus fileStatus = fileStatusClient.getFileStatus(reportMessage.getProjectId(), fileId); + long start = System.currentTimeMillis(); RedactionLog redactionLog = reportStorageService.getRedactionLog(reportMessage.getProjectId(), fileId); if (legalBasisMappings == null) { @@ -56,24 +61,24 @@ public class ReportGenerationService { List reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMappings); if (reportMessage.getReportTypes().contains(ReportType.EXCEL_MULTI_FILE)) { - excelReportService.addEntries(excelMultiFileSheet, reportEntries, redactionLog.getFilename(), excelRowIndex); + excelReportService.addEntries(excelMultiFileSheet, reportEntries, fileStatus.getFilename(), excelRowIndex); } if (reportMessage.getReportTypes().contains(ReportType.EXCEL_SINGLE_FILE)) { - byte[] excelSingleReport = excelReportService.generateSingleFileReport(reportEntries, redactionLog.getFilename()); + byte[] excelSingleReport = excelReportService.generateSingleFileReport(reportEntries, fileStatus.getFilename()); String storageId = reportStorageService.storeObject(reportMessage.getDownloadId(), excelSingleReport); storedFileInformation.add(new StoredFileInformation(fileId, storageId, ReportType.EXCEL_SINGLE_FILE)); } if (reportMessage.getReportTypes().contains(ReportType.WORD_SINGLE_FILE_APPENDIX_A1_TEMPLATE)) { - byte[] wordEFSATemplate = wordReportGenerationService.generateReport(ReportType.WORD_SINGLE_FILE_APPENDIX_A1_TEMPLATE, reportEntries, redactionLog + byte[] wordEFSATemplate = wordReportGenerationService.generateReport(ReportType.WORD_SINGLE_FILE_APPENDIX_A1_TEMPLATE, reportEntries, fileStatus .getFilename()); String storageId = reportStorageService.storeObject(reportMessage.getDownloadId(), wordEFSATemplate); storedFileInformation.add(new StoredFileInformation(fileId, storageId, ReportType.WORD_SINGLE_FILE_APPENDIX_A1_TEMPLATE)); } if (reportMessage.getReportTypes().contains(ReportType.WORD_SINGLE_FILE_APPENDIX_A2_TEMPLATE)) { - byte[] wordSyngentaTemplate = wordReportGenerationService.generateReport(ReportType.WORD_SINGLE_FILE_APPENDIX_A2_TEMPLATE, reportEntries, redactionLog + byte[] wordSyngentaTemplate = wordReportGenerationService.generateReport(ReportType.WORD_SINGLE_FILE_APPENDIX_A2_TEMPLATE, reportEntries, fileStatus .getFilename()); String storageId = reportStorageService.storeObject(reportMessage.getDownloadId(), wordSyngentaTemplate); storedFileInformation.add(new StoredFileInformation(fileId, storageId, ReportType.WORD_SINGLE_FILE_APPENDIX_A2_TEMPLATE)); diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/application.yml b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/application.yml index 5afcffb..1d9c4c2 100644 --- a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/application.yml +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/application.yml @@ -2,6 +2,7 @@ info: description: Redaction Report Server v1 configuration-service.url: "http://configuration-service-v1:8080" +file-management-service.url: "http://file-management-service-v1:8080" server: port: 8080 diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java index 72b19c9..f018f52 100644 --- a/redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java @@ -19,6 +19,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.iqser.red.service.configuration.v1.api.model.LegalBasisMapping; import com.iqser.red.service.redaction.report.v1.api.model.ReportType; +import com.iqser.red.service.redaction.report.v1.server.client.FileStatusClient; import com.iqser.red.service.redaction.report.v1.server.client.LegalBasisMappingClient; import com.iqser.red.service.redaction.report.v1.server.configuration.MessagingConfiguration; import com.iqser.red.service.redaction.report.v1.server.model.ReportRedactionEntry; @@ -53,6 +54,9 @@ public class RedactionReportIntegrationTest { @MockBean private MessagingConfiguration messagingConfiguration; + @MockBean + private FileStatusClient fileStatusClient; + @Autowired private RedactionLogConverterService redactionLogConverterService;