diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/model/ExcelModel.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/model/ExcelModel.java index 5ce6bf4..89e9f2b 100644 --- a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/model/ExcelModel.java +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/model/ExcelModel.java @@ -28,5 +28,6 @@ public class ExcelModel { private boolean hasRssPlaceHolders; private boolean placeholderInFirstRow; private boolean firstRowWritten; + private boolean hasScmFunctionPlaceholder; } diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ExcelReportGenerationService.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ExcelReportGenerationService.java index fcfb4ea..18cf99f 100644 --- a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ExcelReportGenerationService.java +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ExcelReportGenerationService.java @@ -23,6 +23,7 @@ import static com.iqser.red.service.redaction.report.v1.server.service.Placehold import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER; import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.REDACTION_VALUE_PLACEHOLDER; import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.RSS_PLACEHOLDER_BASE; +import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.SCM_FUNCTION_PLACEHOLDER; import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER; import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER; @@ -74,6 +75,9 @@ import lombok.extern.slf4j.Slf4j; @RequiredArgsConstructor public class ExcelReportGenerationService { + private final RSSPoc2Service rSSPoc2Service; + + @Timed("redactmanager_generateExcelReport") public void generateExcelReport(List reportEntries, PlaceholderModel placeholderModel, @@ -110,10 +114,14 @@ public class ExcelReportGenerationService { } } - if (!excelModel.isHasRssPlaceHolders()) { + if (!excelModel.isHasRssPlaceHolders() && !excelModel.isHasScmFunctionPlaceholder()) { addRedactionEntryRows(sheet, reportEntries, fileModel.getFilename(), excelModel, placeholderModel); } + if (excelModel.isHasScmFunctionPlaceholder()) { + addSCMEntryRows(sheet, fileModel, excelModel); + } + if (isLastFile) { addRows(workbook, sheet, @@ -207,6 +215,7 @@ public class ExcelReportGenerationService { Map cellsToCopyAfterPlaceholderRow = new HashMap<>(); Map cellsToCopyInPlaceholderRow = new HashMap<>(); boolean hasRssPlaceHolders = false; + boolean hasScmFunctionPlaceholder = false; int placeholderRow = -1; boolean placeholderInFirstRow = false; for (int j = 0; j < sheet.getLastRowNum() + 1; j++) { @@ -227,6 +236,10 @@ public class ExcelReportGenerationService { hasRssPlaceHolders = true; } + if (cellStringValue.contains(SCM_FUNCTION_PLACEHOLDER)) { + hasScmFunctionPlaceholder = true; + } + if (containsRedactionPlaceholder(cellStringValue)) { placeholderCellPos.put(i, getFunctionForPlaceHolder(cellStringValue)); placeholderRow = j; @@ -259,7 +272,47 @@ public class ExcelReportGenerationService { false, hasRssPlaceHolders, placeholderInFirstRow, - false); + false, + hasScmFunctionPlaceholder); + } + + + + private void addSCMEntryRows(Sheet sheet, FileModel fileModel, ExcelModel excelModel) { + + var scm = rSSPoc2Service.getRSS(fileModel.getDossierId(), fileModel.getId()); + var scmResultMap = scm.getFiles().get(0).getResult(); + + AtomicInteger rowIndex = new AtomicInteger(excelModel.getRedactionPlaceholderRow()); + + var oecd = scmResultMap.get("Study_Type_Number"); + + for (Map.Entry entry : scmResultMap.entrySet()) { + + if(entry.getKey().equals("Study_Type_Number")){ + continue; + } + + sheet.createRow(rowIndex.get()); + excelModel.getWrittenRows().add(rowIndex.get()); + + Cell filenameCell = sheet.getRow(rowIndex.get()).createCell(0); + filenameCell.setCellValue(fileModel.getFilename()); + + Cell keyCell = sheet.getRow(rowIndex.get()).createCell(1); + keyCell.setCellValue(oecd + "-" + entry.getKey()); + + Cell valueCell = sheet.getRow(rowIndex.get()).createCell(2); + valueCell.setCellValue(entry.getValue()); + + rowIndex.getAndIncrement(); + } + + sheet.createRow(rowIndex.get()); + excelModel.getWrittenRows().add(rowIndex.get()); + + excelModel.setRedactionPlaceholderRow(rowIndex.getAndIncrement()); + } @@ -294,7 +347,7 @@ public class ExcelReportGenerationService { JUSTIFICATION_PARAGRAPH_PLACEHOLDER) || text.contains(JUSTIFICATION_REASON_PLACEHOLDER) || text.contains(REDACTION_VALUE_PLACEHOLDER) || text.contains( JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER) || text.contains(JUSTIFICATION_TEXT_PLACEHOLDER) || text.contains( SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER) || text.contains(SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER) || text.contains( - REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER); + REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER) || text.contains(SCM_FUNCTION_PLACEHOLDER); } diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/PlaceholderService.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/PlaceholderService.java index 65374a8..4b6c115 100644 --- a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/PlaceholderService.java +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/PlaceholderService.java @@ -48,6 +48,7 @@ public class PlaceholderService { public static final String EXCERPT_PLACEHOLDER = "{{redaction.excerpt}}"; public static final String REDACTION_VALUE_PLACEHOLDER = "{{redaction.value}}"; public static final String REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER = "{{redaction.entity.displayName}}"; + public static final String SCM_FUNCTION_PLACEHOLDER = "{{function.scm}}"; public static final String FILE_ATTRIBUTE_PLACEHOLDER_BASE = "{{file.attribute."; public static final String DOSSIER_ATTRIBUTE_PLACEHOLDER_BASE = "{{dossier.attribute."; public static final String RSS_PLACEHOLDER_BASE = "{{component.";