RED-7286 - Fix for downloading archived dossier

This commit is contained in:
Andrei Isvoran 2023-09-13 10:07:17 +03:00
parent 84a238c76a
commit 9a7ad0910b
3 changed files with 17 additions and 16 deletions

View File

@ -15,6 +15,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AnnotationStatus;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.Dossier;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.Type;
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.ManualRedactionType;
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.Rectangle;
@ -42,7 +43,7 @@ public class RedactionLogConverterService {
@Timed("redactmanager_getReportEntries")
public List<ReportRedactionEntry> getReportEntries(String dossierId, String fileId, boolean isExcluded) {
public List<ReportRedactionEntry> getReportEntries(String dossierId, String fileId, boolean isExcluded, Dossier dossier) {
if (isExcluded) {
return new ArrayList<>();
@ -58,7 +59,7 @@ public class RedactionLogConverterService {
}
var legalBasisMappings = redactionLog.getLegalBasis();
return convertAndSort(redactionLog, legalBasisMappings, mapOfEntityDisplayName, dossierId);
return convertAndSort(redactionLog, legalBasisMappings, mapOfEntityDisplayName, dossier);
}
@ -82,11 +83,11 @@ public class RedactionLogConverterService {
public List<ReportRedactionEntry> convertAndSort(RedactionLog redactionLog,
List<RedactionLogLegalBasis> legalBasisMappings,
Map<String, String> mapOfEntityDisplayName,
String dossierId) {
Dossier dossier) {
List<ReportRedactionEntry> reportEntries = new ArrayList<>();
var allTypes = dictionaryClient.getAllTypesForDossierTemplate(dossierClient.getDossierById(dossierId, false, false).getDossierTemplateId(), false);
var allTypes = dictionaryClient.getAllTypesForDossierTemplate(dossier.getDossierTemplateId(), false);
redactionLog.getRedactionLogEntry().forEach(entry -> {
var isSkipped = !entry.isRedacted() && !entry.isHint() && !isHintType(allTypes, entry.getType());

View File

@ -80,7 +80,7 @@ public class ReportGenerationService {
var fileStatus = fileStatusClient.getFileStatus(dossierId, fileId);
generatePlaceholderService.resolveFileAttributeValues(fileStatus, placeholderModel);
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.getReportEntries(dossierId, fileId, fileStatus.isExcluded());
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.getReportEntries(dossierId, fileId, fileStatus.isExcluded(), dossier);
generateMultiFileExcelReports(reportTemplates.multiFileWorkbookReportTemplates, placeholderModel, fileStatus, isLastFile, dossierName, reportEntries);

View File

@ -156,7 +156,7 @@ public class RedactionReportIntegrationTest {
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLog.json").getInputStream(), RedactionLog.class);
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier.getDossierId());
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier);
var wordTemplateResource = new ClassPathResource("templates/Justification Appendix A1.docx");
var imageResource = new ClassPathResource("files/exampleImage.jpg");
@ -193,7 +193,7 @@ public class RedactionReportIntegrationTest {
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLog.json").getInputStream(), RedactionLog.class);
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier.getDossierId());
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier);
var wordTemplateResource = new ClassPathResource("templates/Justification Appendix A2.docx");
var imageResource = new ClassPathResource("files/exampleImage.jpg");
@ -272,7 +272,7 @@ public class RedactionReportIntegrationTest {
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLog.json").getInputStream(), RedactionLog.class);
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier.getDossierId());
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier);
ClassPathResource templateResource = new ClassPathResource("templates/IUCLID_Template.docx");
XWPFDocument doc = new XWPFDocument(templateResource.getInputStream());
@ -298,7 +298,7 @@ public class RedactionReportIntegrationTest {
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLog.json").getInputStream(), RedactionLog.class);
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier.getDossierId());
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier);
ClassPathResource templateResource = new ClassPathResource("templates/Seeds - New Justification Form.docx");
XWPFDocument doc = new XWPFDocument(templateResource.getInputStream());
@ -324,14 +324,14 @@ public class RedactionReportIntegrationTest {
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLog.json").getInputStream(), RedactionLog.class);
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier.getDossierId());
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier);
FileModel fileModelSecondFile = FileModel.builder().filename("secondFile").build();
RedactionLog redactionLogSecondFile = objectMapper.readValue(new ClassPathResource("files/excelReportRedactionLog.json").getInputStream(), RedactionLog.class);
List<ReportRedactionEntry> reportEntriesSecondFile = redactionLogConverterService.convertAndSort(redactionLogSecondFile,
legalBasisMapping,
new HashMap<>(),
dossier.getDossierId());
dossier);
ClassPathResource templateResource = new ClassPathResource("templates/Seeds-NewJustificationForm.docx");
XWPFDocument doc = new XWPFDocument(templateResource.getInputStream());
@ -358,7 +358,7 @@ public class RedactionReportIntegrationTest {
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLog.json").getInputStream(), RedactionLog.class);
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier.getDossierId());
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier);
var wordTemplateResource = new ClassPathResource("templates/6464 appendix_b EFSA dRAR justification.docx");
var imageResource = new ClassPathResource("files/exampleImage.jpg");
@ -396,7 +396,7 @@ public class RedactionReportIntegrationTest {
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
Map<String, String> mapOfEntityDisplayName = createEntityDisplayNames(redactionLog);
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, mapOfEntityDisplayName, dossier.getDossierId());
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, mapOfEntityDisplayName, dossier);
ClassPathResource templateResource = new ClassPathResource("templates/Excel Report.xlsx");
@ -425,7 +425,7 @@ public class RedactionReportIntegrationTest {
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
Map<String, String> mapOfEntityDisplayName = createEntityDisplayNames(redactionLog);
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, mapOfEntityDisplayName, dossier.getDossierId());
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, mapOfEntityDisplayName, dossier);
FileModel fileModel = FileModel.builder().filename("filename").build();
@ -443,7 +443,7 @@ public class RedactionReportIntegrationTest {
List<ReportRedactionEntry> reportEntriesSecondFile = redactionLogConverterService.convertAndSort(redactionLogSecondFile,
legalBasisMapping,
mapOfEntityDisplayName,
dossier.getDossierId());
dossier);
FileModel fileModelSecondFile = FileModel.builder().filename("secondFile").build();
excelTemplateReportGenerationService.generateExcelReport(reportEntriesSecondFile,
placeholders,
@ -470,7 +470,7 @@ public class RedactionReportIntegrationTest {
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
Map<String, String> mapOfEntityDisplayName = createEntityDisplayNames(redactionLog);
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, mapOfEntityDisplayName, dossier.getDossierId());
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, mapOfEntityDisplayName, dossier);
var imageResource = new ClassPathResource("files/exampleImage.jpg");
FileModel fileModel = FileModel.builder().filename("filename").build();