diff --git a/redaction-report-service-v1/redaction-report-service-api-v1/src/main/java/com/iqser/red/service/redaction/report/v1/api/model/ReportType.java b/redaction-report-service-v1/redaction-report-service-api-v1/src/main/java/com/iqser/red/service/redaction/report/v1/api/model/ReportType.java index de5bf7d..5e676d6 100644 --- a/redaction-report-service-v1/redaction-report-service-api-v1/src/main/java/com/iqser/red/service/redaction/report/v1/api/model/ReportType.java +++ b/redaction-report-service-v1/redaction-report-service-api-v1/src/main/java/com/iqser/red/service/redaction/report/v1/api/model/ReportType.java @@ -1,5 +1,5 @@ package com.iqser.red.service.redaction.report.v1.api.model; public enum ReportType { - WORD_SINGLE_FILE_EFSA_TEMPLATE, WORD_SINGLE_FILE_SYNGENTA_TEMPLATE, EXCEL_MULTI_FILE, EXCEL_SINGLE_FILE + WORD_SINGLE_FILE_APPENDIX_A1_TEMPLATE, WORD_SINGLE_FILE_APPENDIX_A2_TEMPLATE, EXCEL_MULTI_FILE, EXCEL_SINGLE_FILE } 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 e819047..6f136fb 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 @@ -67,18 +67,18 @@ public class ReportGenerationService { storedFileInformation.add(new StoredFileInformation(fileId, redactionLog.getFilename(), storageId, ReportType.EXCEL_SINGLE_FILE)); } - if (reportMessage.getReportTypes().contains(ReportType.WORD_SINGLE_FILE_EFSA_TEMPLATE)) { - byte[] wordEFSATemplate = wordReportGenerationService.generateReport(ReportType.WORD_SINGLE_FILE_EFSA_TEMPLATE, reportEntries, redactionLog + if (reportMessage.getReportTypes().contains(ReportType.WORD_SINGLE_FILE_APPENDIX_A1_TEMPLATE)) { + byte[] wordEFSATemplate = wordReportGenerationService.generateReport(ReportType.WORD_SINGLE_FILE_APPENDIX_A1_TEMPLATE, reportEntries, redactionLog .getFilename()); String storageId = reportStorageService.storeObject(reportMessage.getDownloadId(), wordEFSATemplate); - storedFileInformation.add(new StoredFileInformation(fileId, redactionLog.getFilename(), storageId, ReportType.WORD_SINGLE_FILE_EFSA_TEMPLATE)); + storedFileInformation.add(new StoredFileInformation(fileId, redactionLog.getFilename(), storageId, ReportType.WORD_SINGLE_FILE_APPENDIX_A1_TEMPLATE)); } - if (reportMessage.getReportTypes().contains(ReportType.WORD_SINGLE_FILE_SYNGENTA_TEMPLATE)) { - byte[] wordSyngentaTemplate = wordReportGenerationService.generateReport(ReportType.WORD_SINGLE_FILE_SYNGENTA_TEMPLATE, reportEntries, redactionLog + if (reportMessage.getReportTypes().contains(ReportType.WORD_SINGLE_FILE_APPENDIX_A2_TEMPLATE)) { + byte[] wordSyngentaTemplate = wordReportGenerationService.generateReport(ReportType.WORD_SINGLE_FILE_APPENDIX_A2_TEMPLATE, reportEntries, redactionLog .getFilename()); String storageId = reportStorageService.storeObject(reportMessage.getDownloadId(), wordSyngentaTemplate); - storedFileInformation.add(new StoredFileInformation(fileId, redactionLog.getFilename(), storageId, ReportType.WORD_SINGLE_FILE_SYNGENTA_TEMPLATE)); + storedFileInformation.add(new StoredFileInformation(fileId, redactionLog.getFilename(), storageId, ReportType.WORD_SINGLE_FILE_APPENDIX_A2_TEMPLATE)); } long end = System.currentTimeMillis(); diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/WordReportGenerationService.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/WordReportGenerationService.java index a0b7a34..49264ac 100644 --- a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/WordReportGenerationService.java +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/WordReportGenerationService.java @@ -13,7 +13,6 @@ import org.apache.poi.xwpf.usermodel.XWPFRun; import org.apache.poi.xwpf.usermodel.XWPFTable; import org.apache.poi.xwpf.usermodel.XWPFTableCell; import org.apache.poi.xwpf.usermodel.XWPFTableRow; -import org.apache.xmlbeans.XmlCursor; import org.springframework.stereotype.Service; import com.iqser.red.service.redaction.report.v1.api.model.ReportType; @@ -26,15 +25,15 @@ import lombok.RequiredArgsConstructor; @RequiredArgsConstructor public class WordReportGenerationService { - private byte[] efsaTemplate; - private byte[] syngentaTemplate; + private byte[] appendixA1Template; + private byte[] appendixA2Template; @PostConstruct public void init() { - efsaTemplate = ResourceLoader.load("templates/EFSA Template.docx"); - syngentaTemplate = ResourceLoader.load("templates/Syngenta Template.docx"); + appendixA1Template = ResourceLoader.load("templates/Sanitisation justification Appendix A1.docx"); + appendixA2Template = ResourceLoader.load("templates/Sanitisation justification Appendix A2.docx"); } @@ -42,12 +41,12 @@ public class WordReportGenerationService { byte[] template; - if (reportType.equals(ReportType.WORD_SINGLE_FILE_EFSA_TEMPLATE)) { - template = efsaTemplate; - } else if (reportType.equals(ReportType.WORD_SINGLE_FILE_SYNGENTA_TEMPLATE)) { - template = syngentaTemplate; + 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 { - template = syngentaTemplate; + template = appendixA2Template; } try (ByteArrayInputStream is = new ByteArrayInputStream(template)) { @@ -63,13 +62,13 @@ public class WordReportGenerationService { private void addTableRows(XWPFDocument doc, List reportEntries, String filename) { - XWPFTable table = doc.getTables().get(0); + XWPFTable table = doc.getTables().get(1); - XmlCursor cursor = table.getCTTbl().newCursor(); - XWPFParagraph newParagraph = doc.insertNewParagraph(cursor); - XWPFRun run = newParagraph.createRun(); - run.setText("Applied rules: EFSA 1 (Vertebrate Authors)"); - run.setFontSize(10); +// XmlCursor cursor = table.getCTTbl().newCursor(); +// XWPFParagraph newParagraph = doc.insertNewParagraph(cursor); +// XWPFRun run = newParagraph.createRun(); +// run.setText("Applied rules: EFSA 1 (Vertebrate Authors)"); +// run.setFontSize(10); reportEntries.forEach(entry -> { XWPFTableRow row = table.createRow(); diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/templates/EFSA Template.docx b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/templates/EFSA Template.docx deleted file mode 100644 index 723d370..0000000 Binary files a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/templates/EFSA Template.docx and /dev/null differ diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/templates/Sanitisation justification Appendix A1.docx b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/templates/Sanitisation justification Appendix A1.docx new file mode 100644 index 0000000..9defb47 Binary files /dev/null and b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/templates/Sanitisation justification Appendix A1.docx differ diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/templates/Sanitisation justification Appendix A2.docx b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/templates/Sanitisation justification Appendix A2.docx new file mode 100644 index 0000000..a7d9c20 Binary files /dev/null and b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/templates/Sanitisation justification Appendix A2.docx differ diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/templates/Syngenta Template.docx b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/templates/Syngenta Template.docx deleted file mode 100644 index 35e4c78..0000000 Binary files a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/templates/Syngenta Template.docx and /dev/null differ 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 1d6512f..72b19c9 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 @@ -73,7 +73,7 @@ public class RedactionReportIntegrationTest { List reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping); - byte[] report = wordReportGenerationService.generateReport(ReportType.WORD_SINGLE_FILE_EFSA_TEMPLATE, reportEntries, redactionLog + byte[] report = wordReportGenerationService.generateReport(ReportType.WORD_SINGLE_FILE_APPENDIX_A2_TEMPLATE, reportEntries, redactionLog .getFilename()); try (FileOutputStream fileOutputStream = new FileOutputStream("/tmp/efsa_template.docx")) {