Pull request #65: RED-2080: removed reportTypes from Dossier class and logic

Merge in RED/redaction-report-service from RED-2080-rrs2 to master

* commit '5f13c4cb47234401b606bf6f2c96d0a958ff57d4':
  RED-2080: removed reportTypes from Dossier class and logic
This commit is contained in:
Ali Oezyetimoglu 2021-09-02 12:53:40 +02:00
commit bbca3d2d74
13 changed files with 74 additions and 254 deletions

View File

@ -27,9 +27,6 @@ public class ReportRequestMessage {
@Builder.Default
private List<String> fileIds = new ArrayList<>();
@Builder.Default
private Set<ReportType> reportTypes = new HashSet<>();
@Builder.Default
private Set<String> templateIds = new HashSet<>();

View File

@ -1,5 +1,5 @@
package com.iqser.red.service.redaction.report.v1.api.model;
public enum ReportType {
WORD_SINGLE_FILE_APPENDIX_A1_TEMPLATE, WORD_SINGLE_FILE_APPENDIX_A2_TEMPLATE, EXCEL_MULTI_FILE, EXCEL_SINGLE_FILE, WORD_SINGLE_FILE, EXCEL_TEMPLATE_SINGLE_FILE, EXCEL_TEMPLATE_MULTI_FILE
WORD_SINGLE_FILE, EXCEL_TEMPLATE_SINGLE_FILE, EXCEL_TEMPLATE_MULTI_FILE
}

View File

@ -1,98 +0,0 @@
package com.iqser.red.service.redaction.report.v1.server.service;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;
import com.iqser.red.service.redaction.report.v1.server.model.ReportRedactionEntry;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
@Service
@RequiredArgsConstructor
public class ExcelReportGenerationService {
public XSSFWorkbook createWorkbook() {
XSSFWorkbook workbook = new XSSFWorkbook();
return workbook;
}
public XSSFSheet createExcelSheet(XSSFWorkbook workbook) {
XSSFSheet sheet = workbook.createSheet("Justifications");
addHeader(sheet);
return sheet;
}
public byte[] generateSingleFileReport(List<ReportRedactionEntry> reportEntries, String filename) {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Justifications");
addHeader(sheet);
AtomicInteger rowIndex = new AtomicInteger(1);
addEntries(sheet, reportEntries, filename, rowIndex);
return toByteArray(workbook);
}
public void addEntries(XSSFSheet sheet, List<ReportRedactionEntry> reportEntries, String filename,
AtomicInteger rowIndex) {
reportEntries.forEach(entry -> {
XSSFRow row = sheet.createRow(rowIndex.get());
XSSFCell filenameCell = row.createCell(0);
filenameCell.setCellValue(filename);
XSSFCell pageColumn = row.createCell(1);
pageColumn.setCellValue(entry.getPage());
XSSFCell paragraphColumn = row.createCell(2);
paragraphColumn.setCellValue(entry.getSection());
XSSFCell justificationColumn = row.createCell(3);
justificationColumn.setCellValue(entry.getJustification());
rowIndex.getAndIncrement();
});
}
private void addHeader(XSSFSheet sheet) {
sheet.setColumnWidth(0, 10000);
sheet.setColumnWidth(1, 4000);
sheet.setColumnWidth(2, 20000);
sheet.setColumnWidth(3, 40000);
XSSFRow row = sheet.createRow(0);
XSSFCell filename = row.createCell(0);
filename.setCellValue("Volume or Document Name");
XSSFCell page = row.createCell(1);
page.setCellValue("Electronic page No.");
XSSFCell paragraph = row.createCell(2);
paragraph.setCellValue("Paragraph");
XSSFCell justification = row.createCell(3);
justification.setCellValue("Justification and reference to Article 63 of Regulation (EC) No 1107/2009");
}
@SneakyThrows
public byte[] toByteArray(XSSFWorkbook doc) {
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
doc.write(byteArrayOutputStream);
doc.close();
return byteArrayOutputStream.toByteArray();
}
}
}

View File

@ -1,14 +1,22 @@
package com.iqser.red.service.redaction.report.v1.server.service;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.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.file.management.v1.api.model.Dossier;
import com.iqser.red.service.file.management.v1.api.model.FileStatus;
import com.iqser.red.service.file.management.v1.api.model.ReportTemplate;
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.DossierClient;
import com.iqser.red.service.redaction.report.v1.server.client.FileStatusClient;
import com.iqser.red.service.redaction.report.v1.server.client.RedactionLogClient;
import com.iqser.red.service.redaction.report.v1.server.client.ReportTemplateClient;
import com.iqser.red.service.redaction.report.v1.server.model.MultiFileWorkbook;
@ -20,23 +28,12 @@ import com.iqser.red.storage.commons.exception.StorageObjectDoesNotExist;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@Slf4j
@Service
@RequiredArgsConstructor
public class ReportGenerationService {
private final ReportStorageService reportStorageService;
private final ExcelReportGenerationService excelReportService;
private final WordReportGenerationService wordReportGenerationService;
private final RedactionLogConverterService redactionLogConverterService;
private final FileStatusClient fileStatusClient;
@ -48,15 +45,6 @@ public class ReportGenerationService {
public List<StoredFileInformation> generateReport(ReportRequestMessage reportMessage) {
XSSFWorkbook excelMultiFileWorkbook = null;
XSSFSheet excelMultiFileSheet = null;
AtomicInteger excelRowIndex = new AtomicInteger(1);
if (reportMessage.getReportTypes().contains(ReportType.EXCEL_MULTI_FILE)) {
excelMultiFileWorkbook = excelReportService.createWorkbook();
excelMultiFileSheet = excelReportService.createExcelSheet(excelMultiFileWorkbook);
}
List<StoredFileInformation> storedFileInformation = new ArrayList<>();
Dossier project = dossierClient.getDossierById(reportMessage.getDossierId());
@ -78,7 +66,7 @@ public class ReportGenerationService {
} else {
singleFilesTemplates.add(reportTemplate);
}
} catch (Exception e){
} catch (Exception e) {
log.warn("Skipping reportTemplate with id {}", templateId);
}
}
@ -91,22 +79,12 @@ public class ReportGenerationService {
long start = System.currentTimeMillis();
List<ReportRedactionEntry> reportEntries = getReportEntries(reportMessage.getDossierId(), reportMessage.getFileIds().get(j), fileStatus.isExcluded());
if (reportMessage.getReportTypes().contains(ReportType.EXCEL_MULTI_FILE)) {
excelReportService.addEntries(excelMultiFileSheet, reportEntries, fileStatus.getFilename(), excelRowIndex);
}
if (reportMessage.getReportTypes().contains(ReportType.EXCEL_SINGLE_FILE)) {
byte[] excelSingleReport = excelReportService.generateSingleFileReport(reportEntries, fileStatus.getFilename());
String storageId = reportStorageService.storeObject(reportMessage.getDownloadId(), excelSingleReport);
storedFileInformation.add(new StoredFileInformation(reportMessage.getFileIds()
.get(j), storageId, ReportType.EXCEL_SINGLE_FILE, null));
}
List<ReportRedactionEntry> reportEntries = getReportEntries(reportMessage.getDossierId(), reportMessage.getFileIds()
.get(j), fileStatus.isExcluded());
for (MultiFileWorkbook multiFileWorkbook : multiFileWorkbooks) {
excelTemplateReportGenerationService.generateReport(reportEntries, reportMessage.getDossierTemplateId(), multiFileWorkbook
.getWorkbook(), fileStatus, project, j == reportMessage.getFileIds().size() - 1 ? true : false);
excelTemplateReportGenerationService.generateReport(reportEntries, reportMessage.getDossierTemplateId(), multiFileWorkbook.getWorkbook(), fileStatus, project, j == reportMessage.getFileIds()
.size() - 1 ? true : false);
}
for (ReportTemplate reportTemplate : singleFilesTemplates) {
if (reportTemplate.getFileName().endsWith(".xlsx")) {
@ -123,28 +101,12 @@ public class ReportGenerationService {
e.printStackTrace();
}
} else {
byte[] template = wordReportGenerationService.generateReport(ReportType.WORD_SINGLE_FILE, reportEntries, reportMessage
.getDossierTemplateId(), reportTemplate, fileStatus, project);
byte[] template = wordReportGenerationService.generateReport(ReportType.WORD_SINGLE_FILE, reportEntries, reportMessage.getDossierTemplateId(), reportTemplate, fileStatus, project);
String storageId = reportStorageService.storeObject(reportMessage.getDownloadId(), template);
storedFileInformation.add(new StoredFileInformation(reportMessage.getFileIds()
.get(j), storageId, ReportType.WORD_SINGLE_FILE, reportTemplate.getTemplateId()));
}
}
if (reportMessage.getReportTypes().contains(ReportType.WORD_SINGLE_FILE_APPENDIX_A1_TEMPLATE)) {
byte[] wordEFSATemplate = wordReportGenerationService.generateReport(ReportType.WORD_SINGLE_FILE_APPENDIX_A1_TEMPLATE, reportEntries, reportMessage
.getDossierTemplateId(), null, fileStatus, project);
String storageId = reportStorageService.storeObject(reportMessage.getDownloadId(), wordEFSATemplate);
storedFileInformation.add(new StoredFileInformation(reportMessage.getFileIds()
.get(j), storageId, ReportType.WORD_SINGLE_FILE_APPENDIX_A1_TEMPLATE, null));
}
if (reportMessage.getReportTypes().contains(ReportType.WORD_SINGLE_FILE_APPENDIX_A2_TEMPLATE)) {
byte[] wordSyngentaTemplate = wordReportGenerationService.generateReport(ReportType.WORD_SINGLE_FILE_APPENDIX_A2_TEMPLATE, reportEntries, reportMessage
.getDossierTemplateId(), null, fileStatus, project);
String storageId = reportStorageService.storeObject(reportMessage.getDownloadId(), wordSyngentaTemplate);
storedFileInformation.add(new StoredFileInformation(reportMessage.getFileIds()
.get(j), storageId, ReportType.WORD_SINGLE_FILE_APPENDIX_A2_TEMPLATE, null));
}
long end = System.currentTimeMillis();
log.info("Successfully processed {}/{} fileIds for downloadId {}, took {}", i, reportMessage.getFileIds()
@ -152,35 +114,26 @@ public class ReportGenerationService {
i++;
}
if (excelMultiFileWorkbook != null) {
long start = System.currentTimeMillis();
byte[] multifileExcelReport = excelReportService.toByteArray(excelMultiFileWorkbook);
String storageId = reportStorageService.storeObject(reportMessage.getDownloadId(), multifileExcelReport);
storedFileInformation.add(new StoredFileInformation(null, storageId, ReportType.EXCEL_MULTI_FILE, null));
long end = System.currentTimeMillis();
log.info("Successfully stored multiFileExcelReport for downloadId {}, took {}", reportMessage.getDownloadId(), end - start);
}
for (MultiFileWorkbook multiFileWorkbook : multiFileWorkbooks) {
byte[] template = excelTemplateReportGenerationService.toByteArray(multiFileWorkbook.getWorkbook());
String storageId = reportStorageService.storeObject(reportMessage.getDownloadId(), template);
storedFileInformation.add(new StoredFileInformation(null, storageId, ReportType.EXCEL_TEMPLATE_MULTI_FILE, multiFileWorkbook
.getTemplateId()));
storedFileInformation.add(new StoredFileInformation(null, storageId, ReportType.EXCEL_TEMPLATE_MULTI_FILE, multiFileWorkbook.getTemplateId()));
}
return storedFileInformation;
}
private List<ReportRedactionEntry> getReportEntries(String dossierId, String fileId, boolean isExcluded){
if(isExcluded){
return new ArrayList<>();
}
private List<ReportRedactionEntry> getReportEntries(String dossierId, String fileId, boolean isExcluded) {
if (isExcluded) {
return new ArrayList<>();
}
RedactionLog redactionLog;
try {
redactionLog = redactionLogClient.getRedactionLog(dossierId, fileId, true);
} catch (StorageObjectDoesNotExist e){
} catch (StorageObjectDoesNotExist e) {
return new ArrayList<>();
}
List<LegalBasisMapping> legalBasisMappings = redactionLog.getLegalBasis();

View File

@ -72,15 +72,6 @@ public class WordReportGenerationService {
private final DossierAttributesConfigClient dossierAttributesConfigClient;
@PostConstruct
public void init() {
appendixA1Template = ResourceLoader.load("templates/Sanitisation justification Appendix A1.docx");
appendixA2Template = ResourceLoader.load("templates/Sanitisation justification Appendix A2.docx");
}
public byte[] generateReport(ReportType reportType, List<ReportRedactionEntry> reportEntries,
String dossierTemplateId, ReportTemplate reportTemplate, FileStatus fileStatus,
Dossier dossier) {
@ -98,7 +89,7 @@ public class WordReportGenerationService {
if (dossierAttribute.getDossierAttributeId().equals(attributeConfig.getId())) {
if (attributeConfig.getType().equals(DossierAttributeConfig.DossierAttributeType.IMAGE)) {
if(dossierAttribute.getValue() != null) {
if (dossierAttribute.getValue() != null) {
if (dossierAttribute.getValue().startsWith("data:")) {
imagePlaceholders.add(new ImagePlaceholder(attributeConfig.getPlaceholder(), Base64.getDecoder()
.decode(dossierAttribute.getValue().split(",")[1])));
@ -126,15 +117,8 @@ public class WordReportGenerationService {
placeholders.addAll(dossierAttributesPlaceholder.keySet());
byte[] template;
if (reportType.equals(ReportType.WORD_SINGLE_FILE_APPENDIX_A1_TEMPLATE)) {
template = appendixA1Template;
} else if (reportType.equals(ReportType.WORD_SINGLE_FILE_APPENDIX_A2_TEMPLATE)) {
template = appendixA2Template;
} else {
String storageId = reportTemplate.getStorageId();
template = reportStorageService.getReportTemplate(storageId);
}
String storageId = reportTemplate.getStorageId();
template = reportStorageService.getReportTemplate(storageId);
try (ByteArrayInputStream is = new ByteArrayInputStream(template)) {
XWPFDocument doc = new XWPFDocument(is);
@ -298,8 +282,7 @@ public class WordReportGenerationService {
private boolean containsRedactionPlaceholder(String text) {
return text.contains(FILE_NAME_PLACEHOLDER) || text.contains(PAGE_PLACEHOLDER) || text.contains(PARAGRAPH_PLACEHOLDER) || text
.contains(JUSTIFICATION_PLACEHOLDER);
return text.contains(FILE_NAME_PLACEHOLDER) || text.contains(PAGE_PLACEHOLDER) || text.contains(PARAGRAPH_PLACEHOLDER) || text.contains(JUSTIFICATION_PLACEHOLDER);
}

View File

@ -1,24 +1,17 @@
package com.iqser.red.service.redaction.report.v1.server;
import com.amazonaws.services.s3.AmazonS3;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.iqser.red.service.configuration.v1.api.model.*;
import com.iqser.red.service.file.management.v1.api.model.*;
import com.iqser.red.service.redaction.report.v1.api.model.ReportType;
import com.iqser.red.service.redaction.report.v1.server.client.DossierAttributesClient;
import com.iqser.red.service.redaction.report.v1.server.client.DossierAttributesConfigClient;
import com.iqser.red.service.redaction.report.v1.server.client.FileAttributesClient;
import com.iqser.red.service.redaction.report.v1.server.client.ReportTemplateClient;
import com.iqser.red.service.redaction.report.v1.server.configuration.MessagingConfiguration;
import com.iqser.red.service.redaction.report.v1.server.model.ReportRedactionEntry;
import com.iqser.red.service.redaction.report.v1.server.service.ExcelReportGenerationService;
import com.iqser.red.service.redaction.report.v1.server.service.ExcelTemplateReportGenerationService;
import com.iqser.red.service.redaction.report.v1.server.service.RedactionLogConverterService;
import com.iqser.red.service.redaction.report.v1.server.service.WordReportGenerationService;
import com.iqser.red.service.redaction.report.v1.server.storage.ReportStorageService;
import com.iqser.red.service.redaction.v1.model.RedactionLog;
import com.iqser.red.storage.commons.service.StorageService;
import static org.mockito.Mockito.when;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
import java.io.FileOutputStream;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -30,13 +23,33 @@ import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.FileOutputStream;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.*;
import static org.mockito.Mockito.when;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
import com.amazonaws.services.s3.AmazonS3;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.iqser.red.service.configuration.v1.api.model.DossierAttributeConfig;
import com.iqser.red.service.configuration.v1.api.model.DossierAttributesConfig;
import com.iqser.red.service.configuration.v1.api.model.FileAttributeConfig;
import com.iqser.red.service.configuration.v1.api.model.FileAttributesConfig;
import com.iqser.red.service.configuration.v1.api.model.LegalBasisMapping;
import com.iqser.red.service.file.management.v1.api.model.Dossier;
import com.iqser.red.service.file.management.v1.api.model.DossierAttribute;
import com.iqser.red.service.file.management.v1.api.model.DossierAttributes;
import com.iqser.red.service.file.management.v1.api.model.FileAttributes;
import com.iqser.red.service.file.management.v1.api.model.FileStatus;
import com.iqser.red.service.file.management.v1.api.model.ReportTemplate;
import com.iqser.red.service.redaction.report.v1.api.model.ReportType;
import com.iqser.red.service.redaction.report.v1.server.client.DossierAttributesClient;
import com.iqser.red.service.redaction.report.v1.server.client.DossierAttributesConfigClient;
import com.iqser.red.service.redaction.report.v1.server.client.FileAttributesClient;
import com.iqser.red.service.redaction.report.v1.server.client.ReportTemplateClient;
import com.iqser.red.service.redaction.report.v1.server.configuration.MessagingConfiguration;
import com.iqser.red.service.redaction.report.v1.server.model.ReportRedactionEntry;
import com.iqser.red.service.redaction.report.v1.server.service.ExcelTemplateReportGenerationService;
import com.iqser.red.service.redaction.report.v1.server.service.RedactionLogConverterService;
import com.iqser.red.service.redaction.report.v1.server.service.WordReportGenerationService;
import com.iqser.red.service.redaction.report.v1.server.storage.ReportStorageService;
import com.iqser.red.service.redaction.v1.model.RedactionLog;
import com.iqser.red.storage.commons.service.StorageService;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = RANDOM_PORT)
@ -63,9 +76,6 @@ public class RedactionReportIntegrationTest {
@Autowired
private WordReportGenerationService wordReportGenerationService;
@Autowired
private ExcelReportGenerationService excelReportGenerationService;
@MockBean
private MessagingConfiguration messagingConfiguration;
@ -102,8 +112,7 @@ public class RedactionReportIntegrationTest {
DossierAttributesConfig dossierAttributesConfig = new DossierAttributesConfig(Arrays.asList(new DossierAttributeConfig("id", "label", true, DossierAttributeConfig.DossierAttributeType.TEXT, "{{dossier.attribute.name}}"), new DossierAttributeConfig("id2", "label2", false, DossierAttributeConfig.DossierAttributeType.IMAGE, "{{dossier.attribute.image}}")));
when(dossierAttributesConfigClient.getDossierAttributes(dossierTemplateId)).thenReturn(dossierAttributesConfig);
DossierAttributes dossierAttributes = new DossierAttributes(Arrays.asList(new DossierAttribute("id", "Michael"), new DossierAttribute("id2", "data:image/png;base64," + Base64
.getEncoder()
DossierAttributes dossierAttributes = new DossierAttributes(Arrays.asList(new DossierAttribute("id", "Michael"), new DossierAttribute("id2", "data:image/png;base64," + Base64.getEncoder()
.encodeToString(IOUtils.toByteArray(imageResource.getInputStream())))));
when(dossierAttributesClient.getDossierAttributes("dossierId")).thenReturn(dossierAttributes);
@ -128,7 +137,7 @@ public class RedactionReportIntegrationTest {
.storageId(storageId)
.build());
ClassPathResource templateResource = new ClassPathResource("templates/TEST_TEMPLATE.docx");
ClassPathResource templateResource = new ClassPathResource("templates/Justification Appendix A1.docx");
when(reportStorageService.getReportTemplate(storageId)).thenReturn(IOUtils.toByteArray(templateResource.getInputStream()));
ReportTemplate reportTemplate = ReportTemplate.builder()
.dossierTemplateId("dossierTemplateId")
@ -145,28 +154,6 @@ public class RedactionReportIntegrationTest {
}
@Test
public void testExcelReportGeneration() throws IOException {
ClassPathResource redactionLogResource = new ClassPathResource("files/excelReportRedactionLog.json");
RedactionLog redactionLog = objectMapper.readValue(redactionLogResource.getInputStream(), RedactionLog.class);
ClassPathResource legalBasisMappingResource = new ClassPathResource("files/LegalBasisMapping.json");
List<LegalBasisMapping> legalBasisMapping = objectMapper.readValue(legalBasisMappingResource.getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping);
byte[] report = excelReportGenerationService.generateSingleFileReport(reportEntries, "TestFile");
try (FileOutputStream fileOutputStream = new FileOutputStream("/tmp/report.xlsx")) {
fileOutputStream.write(report);
}
}
@Test
public void testExcelTemplateReportGeneration() throws IOException {
@ -181,7 +168,7 @@ public class RedactionReportIntegrationTest {
String storageId = "storageId";
String templateId = "templateId";
ClassPathResource templateResource = new ClassPathResource("templates/Excel_Template.xlsx");
ClassPathResource templateResource = new ClassPathResource("templates/Excel Report.xlsx");
XSSFWorkbook workbook = new XSSFWorkbook(templateResource.getInputStream());
ClassPathResource legalBasisMappingResource = new ClassPathResource("files/legalBasisMapping.json");
@ -193,8 +180,7 @@ public class RedactionReportIntegrationTest {
DossierAttributesConfig dossierAttributesConfig = new DossierAttributesConfig(Arrays.asList(new DossierAttributeConfig("id", "label", true, DossierAttributeConfig.DossierAttributeType.TEXT, "{{dossier.attribute.name}}"), new DossierAttributeConfig("id2", "label2", false, DossierAttributeConfig.DossierAttributeType.IMAGE, "{{dossier.attribute.image}}")));
when(dossierAttributesConfigClient.getDossierAttributes(dossierTemplateId)).thenReturn(dossierAttributesConfig);
DossierAttributes dossierAttributes = new DossierAttributes(Arrays.asList(new DossierAttribute("id", "Michael"), new DossierAttribute("id2", Base64
.getEncoder()
DossierAttributes dossierAttributes = new DossierAttributes(Arrays.asList(new DossierAttribute("id", "Michael"), new DossierAttribute("id2", Base64.getEncoder()
.encodeToString(IOUtils.toByteArray(imageResource.getInputStream())))));
when(dossierAttributesClient.getDossierAttributes("dossierId")).thenReturn(dossierAttributes);
@ -247,8 +233,7 @@ public class RedactionReportIntegrationTest {
DossierAttributesConfig dossierAttributesConfig = new DossierAttributesConfig(Arrays.asList(new DossierAttributeConfig("id", "label", true, DossierAttributeConfig.DossierAttributeType.TEXT, "{{dossier.attribute.name}}"), new DossierAttributeConfig("id2", "label2", false, DossierAttributeConfig.DossierAttributeType.IMAGE, "{{dossier.attribute.image}}")));
when(dossierAttributesConfigClient.getDossierAttributes(dossierTemplateId)).thenReturn(dossierAttributesConfig);
DossierAttributes dossierAttributes = new DossierAttributes(Arrays.asList(new DossierAttribute("id", "Michael"), new DossierAttribute("id2", Base64
.getEncoder()
DossierAttributes dossierAttributes = new DossierAttributes(Arrays.asList(new DossierAttribute("id", "Michael"), new DossierAttribute("id2", Base64.getEncoder()
.encodeToString(IOUtils.toByteArray(imageResource.getInputStream())))));
when(dossierAttributesClient.getDossierAttributes("dossierId")).thenReturn(dossierAttributes);
@ -269,7 +254,7 @@ public class RedactionReportIntegrationTest {
.storageId(storageId)
.build());
ClassPathResource wordTemplateResource = new ClassPathResource("templates/TEST_TEMPLATE.docx");
ClassPathResource wordTemplateResource = new ClassPathResource("templates/Justification Appendix A1.docx");
when(reportStorageService.getReportTemplate(storageId)).thenReturn(IOUtils.toByteArray(wordTemplateResource.getInputStream()));
ReportTemplate reportTemplate = ReportTemplate.builder()
.dossierTemplateId("dossierTemplateId")
@ -294,7 +279,7 @@ public class RedactionReportIntegrationTest {
fileOutputStream.write(wordReport2);
}
ClassPathResource excelTemplateResource = new ClassPathResource("templates/Excel_Template.xlsx");
ClassPathResource excelTemplateResource = new ClassPathResource("templates/Excel Report.xlsx");
XSSFWorkbook workbook = new XSSFWorkbook(excelTemplateResource.getInputStream());
excelTemplateReportGenerationService.generateReport(reportEntries, "dossierTemplateId", workbook, fileStatus, dossier, false);
excelTemplateReportGenerationService.generateReport(reportEntries2, "dossierTemplateId", workbook, fileStatus2, dossier, true);