RED-9148 - Paragraph information placeholder for reports

This commit is contained in:
Andrei Isvoran 2024-05-22 11:35:53 +03:00
parent 855da70b93
commit 0bc6725424
24 changed files with 15830 additions and 73 deletions

View File

@ -11,12 +11,12 @@ plugins {
description = "redaction-service-server-v1"
val tenantCommonVersion = "0.21.0"
val tenantCommonVersion = "0.23.0"
val springCommonsVersion = "2.1.0"
val storageCommonsVersion = "2.45.0"
val poiVersion = "5.2.3"
val metricCommonsVersion = "2.1.0"
val persistenceServiceVersion = "2.380.0"
val persistenceServiceVersion = "2.420.0"
val springBootStarterVersion = "3.2.3"
configurations {
@ -32,6 +32,7 @@ description = "redaction-report-service-server-v1"
dependencies {
implementation(project(":redaction-report-service-api-v1"))
implementation("com.iqser.red.service:persistence-service-internal-api-v1:${persistenceServiceVersion}")
implementation("com.iqser.red.service:persistence-service-shared-mongo-v1:${persistenceServiceVersion}")
implementation("com.knecon.fforesight:tenant-commons:${tenantCommonVersion}")
implementation("com.iqser.red.commons:storage-commons:${storageCommonsVersion}")

View File

@ -4,27 +4,35 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import org.springframework.scheduling.annotation.EnableAsync;
import com.iqser.red.service.persistence.service.v1.api.shared.mongo.SharedMongoAutoConfiguration;
import com.iqser.red.service.redaction.report.v1.server.client.DossierClient;
import com.iqser.red.service.redaction.report.v1.server.configuration.MessagingConfiguration;
import com.iqser.red.service.redaction.report.v1.server.settings.ReportTemplateSettings;
import com.iqser.red.storage.commons.StorageAutoConfiguration;
import com.knecon.fforesight.mongo.database.commons.MongoDatabaseCommonsAutoConfiguration;
import com.knecon.fforesight.tenantcommons.MultiTenancyAutoConfiguration;
import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.MeterRegistry;
@EnableAsync
@ImportAutoConfiguration({MultiTenancyAutoConfiguration.class})
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class})
@Import({MessagingConfiguration.class, StorageAutoConfiguration.class})
@ImportAutoConfiguration({MultiTenancyAutoConfiguration.class, SharedMongoAutoConfiguration.class})
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class, DataSourceAutoConfiguration.class, LiquibaseAutoConfiguration.class, MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
@Import({MessagingConfiguration.class, StorageAutoConfiguration.class, MongoDatabaseCommonsAutoConfiguration.class})
@EnableFeignClients(basePackageClasses = {DossierClient.class})
@EnableMongoRepositories(basePackages = "com.iqser.red.service.persistence")
@EnableConfigurationProperties(ReportTemplateSettings.class)
public class Application {

View File

@ -13,6 +13,7 @@ public class ReportRedactionEntry {
private String section;
private String justification;
private String justificationParagraph;
private int paragraphIdx;
private String justificationReason;
private String excerpt;
private String value;

View File

@ -154,6 +154,7 @@ public class EntityLogConverterService {
.map(EntityLogLegalBasis::getDescription)
.orElse(""),
entry.getLegalBasis(),
entry.getParagraphPageIdx(),
legalBasisMappings.stream()
.filter(lbm -> lbm.getReason().equalsIgnoreCase(entry.getLegalBasis()))
.findAny()

View File

@ -22,6 +22,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.JUSTIFICATION_REASON_PLACEHOLDER;
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.JUSTIFICATION_TEXT_PLACEHOLDER;
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.PAGE_PLACEHOLDER;
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.PARAGRAPH_INDEX_PLACEHOLDER;
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.PARAGRAPH_PLACEHOLDER;
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;
@ -85,23 +86,24 @@ public class ExcelReportGenerationService {
private static final Set<String> prefixRedactionPlaceholders = Set.of(DOSSIER_ATTRIBUTE_PLACEHOLDER_BASE, FILE_ATTRIBUTE_PLACEHOLDER_BASE);
private static final Set<String> redactionPlaceholders = Set.of(FILE_NAME_PLACEHOLDER,
PAGE_PLACEHOLDER,
PARAGRAPH_PLACEHOLDER,
JUSTIFICATION_PLACEHOLDER,
EXCERPT_PLACEHOLDER,
JUSTIFICATION_PARAGRAPH_PLACEHOLDER,
JUSTIFICATION_REASON_PLACEHOLDER,
REDACTION_VALUE_PLACEHOLDER,
JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER,
JUSTIFICATION_TEXT_PLACEHOLDER,
SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER,
SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER,
REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER,
SCM_FUNCTION_PLACEHOLDER,
SKIPPED_PLACEHOLDER,
FILE_ATTRIBUTES_PLACEHOLDER,
INDEX_PLACEHOLDER,
COMPONENT_PLACEHOLDER);
PAGE_PLACEHOLDER,
PARAGRAPH_PLACEHOLDER,
PARAGRAPH_INDEX_PLACEHOLDER,
JUSTIFICATION_PLACEHOLDER,
EXCERPT_PLACEHOLDER,
JUSTIFICATION_PARAGRAPH_PLACEHOLDER,
JUSTIFICATION_REASON_PLACEHOLDER,
REDACTION_VALUE_PLACEHOLDER,
JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER,
JUSTIFICATION_TEXT_PLACEHOLDER,
SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER,
SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER,
REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER,
SCM_FUNCTION_PLACEHOLDER,
SKIPPED_PLACEHOLDER,
FILE_ATTRIBUTES_PLACEHOLDER,
INDEX_PLACEHOLDER,
COMPONENT_PLACEHOLDER);
private final ScmReportService componentReportService;
private final FileAttributesConfigClient fileAttributesConfigClient;
@ -161,7 +163,6 @@ public class ExcelReportGenerationService {
componentRowsReportService.addComponentRows(sheet, fileModel, excelModel);
}
if (isLastFile) {
addRows(workbook,
sheet,
@ -175,12 +176,12 @@ public class ExcelReportGenerationService {
}
log.info("Report Generation took: {} for file with id {}, pageCount: {}, entityLogEntryCount: {}, reportName: {}, className: {}",
System.currentTimeMillis() - start,
fileModel.getId(),
fileModel.getNumberOfPages(),
reportEntries.size(),
reportTemplateName,
getClass().getSimpleName());
System.currentTimeMillis() - start,
fileModel.getId(),
fileModel.getNumberOfPages(),
reportEntries.size(),
reportTemplateName,
getClass().getSimpleName());
} catch (Exception e) {
throw new RuntimeException(e);
@ -244,7 +245,8 @@ public class ExcelReportGenerationService {
excelModel.getWrittenRows().add(rowIndex.get());
for (Map.Entry<Integer, Function<PlaceholderInput, String>> entry1 : placeholderCellPos.entrySet()) {
Cell cell = sheet.getRow(rowIndex.get()).createCell(entry1.getKey());
cell.setCellValue(entry1.getValue().apply(new PlaceholderInput(filename, entry, placeholderModel, null)) == null ? "" : entry1.getValue().apply(new PlaceholderInput(filename, entry, placeholderModel, null)));
cell.setCellValue(entry1.getValue().apply(new PlaceholderInput(filename, entry, placeholderModel, null)) == null ? "" : entry1.getValue()
.apply(new PlaceholderInput(filename, entry, placeholderModel, null)));
}
rowIndex.getAndIncrement();
});
@ -255,9 +257,6 @@ public class ExcelReportGenerationService {
}
private void replacePlaceholders(Cell cell, PlaceholderModel placeholderModel, String dossierName, String filename) {
for (String placeholder : placeholderModel.getPlaceholders()) {
@ -336,15 +335,18 @@ public class ExcelReportGenerationService {
return filename;
}
if (placeholderModel.getFileAttributeValueByPlaceholder().containsKey(placeholder)) {
return placeholderModel.getFileAttributeValueByPlaceholder().get(placeholder);
return placeholderModel.getFileAttributeValueByPlaceholder()
.get(placeholder);
}
if (placeholderModel.getDossierAttributesValueByPlaceholder().containsKey(placeholder)) {
return placeholderModel.getDossierAttributesValueByPlaceholder().get(placeholder);
return placeholderModel.getDossierAttributesValueByPlaceholder()
.get(placeholder);
}
if (placeholderModel.getRssComponentPlaceholder() != null && placeholderModel.getRssComponentPlaceholder().containsKey(placeholder)) {
return placeholderModel.getRssComponentPlaceholder().get(placeholder);
return placeholderModel.getRssComponentPlaceholder()
.get(placeholder);
}
return null;
@ -439,7 +441,7 @@ public class ExcelReportGenerationService {
// If there is more than one file attribute, starting from the 2nd one we won't find a cell in the given index so we have to create it.
if (cell == null) {
cell = sheet.getRow(j).createCell(i);
CellStyle cellStyle = sheet.getRow(j).getCell(i-1).getCellStyle();
CellStyle cellStyle = sheet.getRow(j).getCell(i - 1).getCellStyle();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
cell.setCellStyle(cellStyle);
}
@ -488,40 +490,45 @@ public class ExcelReportGenerationService {
log.debug("Calculate Placeholder Cells took: {}", System.currentTimeMillis() - start);
return new ExcelModel(placeholderCellPos,
placeholderRow,
columnWidths,
cellsToCopyBeforePlaceholderRow,
cellsToCopyAfterPlaceholderRow,
new ArrayList<>(),
false,
hasRssPlaceHolders,
placeholderInFirstRow,
false,
hasSkippedPlaceholder,
fileAttributesPlaceholder,
hasScmFunctionPlaceholder);
placeholderRow,
columnWidths,
cellsToCopyBeforePlaceholderRow,
cellsToCopyAfterPlaceholderRow,
new ArrayList<>(),
false,
hasRssPlaceHolders,
placeholderInFirstRow,
false,
hasSkippedPlaceholder,
fileAttributesPlaceholder,
hasScmFunctionPlaceholder);
}
private boolean isRedactionPlaceholder(String text) {
return prefixRedactionPlaceholders.stream().anyMatch(text::startsWith) || redactionPlaceholders.stream().anyMatch(text::contains);
return prefixRedactionPlaceholders.stream()
.anyMatch(text::startsWith) || redactionPlaceholders.stream()
.anyMatch(text::contains);
}
private Function<PlaceholderInput, String> getFunctionForPlaceHolder(String placeholder) {
if (placeholder.startsWith(FILE_ATTRIBUTE_PLACEHOLDER_BASE)) {
return placeholderInput -> placeholderInput.getPlaceholderModel().getFileAttributeValueByPlaceholder().get(placeholder);
return placeholderInput -> placeholderInput.getPlaceholderModel().getFileAttributeValueByPlaceholder()
.get(placeholder);
}
if (placeholder.startsWith(DOSSIER_ATTRIBUTE_PLACEHOLDER_BASE)) {
return placeholderInput -> placeholderInput.getPlaceholderModel().getDossierAttributesValueByPlaceholder().get(placeholder);
return placeholderInput -> placeholderInput.getPlaceholderModel().getDossierAttributesValueByPlaceholder()
.get(placeholder);
}
return switch (placeholder) {
case FILE_NAME_PLACEHOLDER -> PlaceholderInput::getFilename;
case PAGE_PLACEHOLDER -> input -> String.valueOf(input.getEntry().getPage());
case PARAGRAPH_PLACEHOLDER -> input -> input.getEntry().getSection();
case PARAGRAPH_INDEX_PLACEHOLDER -> input -> String.valueOf(input.getEntry().getParagraphIdx());
case JUSTIFICATION_PLACEHOLDER -> input -> input.getEntry().getJustification();
case JUSTIFICATION_PARAGRAPH_PLACEHOLDER, JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER -> input -> input.getEntry().getJustificationParagraph();
case JUSTIFICATION_REASON_PLACEHOLDER, JUSTIFICATION_TEXT_PLACEHOLDER -> input -> input.getEntry().getJustificationReason();

View File

@ -40,6 +40,7 @@ public class PlaceholderService {
public static final String FILE_NAME_PLACEHOLDER = "{{file.name}}";
public static final String PAGE_PLACEHOLDER = "{{redaction.page}}";
public static final String PARAGRAPH_PLACEHOLDER = "{{redaction.paragraph}}";
public static final String PARAGRAPH_INDEX_PLACEHOLDER = "{{redaction.paragraphIdx}}";
public static final String JUSTIFICATION_PLACEHOLDER = "{{redaction.justification}}";
public static final String JUSTIFICATION_PARAGRAPH_PLACEHOLDER = "{{redaction.justificationParagraph}}";
public static final String JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER = "{{redaction.justificationLegalBasis}}";
@ -77,6 +78,7 @@ public class PlaceholderService {
public static final Set<String> GENERAL_PLACEHOLDERS = Set.of(FILE_NAME_PLACEHOLDER,
PAGE_PLACEHOLDER,
PARAGRAPH_PLACEHOLDER,
PARAGRAPH_INDEX_PLACEHOLDER,
JUSTIFICATION_PLACEHOLDER,
EXCERPT_PLACEHOLDER,
FORMAT_DATE_ISO_PLACEHOLDER,

View File

@ -20,6 +20,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.JUSTIFICATION_REASON_PLACEHOLDER;
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.JUSTIFICATION_TEXT_PLACEHOLDER;
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.PAGE_PLACEHOLDER;
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.PARAGRAPH_INDEX_PLACEHOLDER;
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.PARAGRAPH_PLACEHOLDER;
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;
@ -376,7 +377,7 @@ public class WordReportGenerationService {
for (XWPFTable tbl : doc.getTables()) {
String tblText = tbl.getText();
if (tblText.contains(PAGE_PLACEHOLDER) || tblText.contains(PARAGRAPH_PLACEHOLDER) || tblText.contains(JUSTIFICATION_PLACEHOLDER) || tblText.contains(EXCERPT_PLACEHOLDER) || tblText.contains(
if (tblText.contains(PAGE_PLACEHOLDER) || tblText.contains(PARAGRAPH_PLACEHOLDER) || tblText.contains(PARAGRAPH_INDEX_PLACEHOLDER) || tblText.contains(JUSTIFICATION_PLACEHOLDER) || tblText.contains(EXCERPT_PLACEHOLDER) || tblText.contains(
JUSTIFICATION_PARAGRAPH_PLACEHOLDER) || tblText.contains(JUSTIFICATION_REASON_PLACEHOLDER) || tblText.contains(JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER) || tblText.contains(
JUSTIFICATION_TEXT_PLACEHOLDER) || tblText.contains(SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER) || tblText.contains(
SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER)) {
@ -390,7 +391,7 @@ public class WordReportGenerationService {
private boolean containsRedactionPlaceholder(String text) {
return text.startsWith(DOSSIER_ATTRIBUTE_PLACEHOLDER_BASE) || text.startsWith(FILE_ATTRIBUTE_PLACEHOLDER_BASE) || text.contains(FILE_NAME_PLACEHOLDER) || text.contains(
PAGE_PLACEHOLDER) || text.contains(PARAGRAPH_PLACEHOLDER) || text.contains(JUSTIFICATION_PLACEHOLDER) || text.contains(EXCERPT_PLACEHOLDER) || text.contains(
PAGE_PLACEHOLDER) || text.contains(PARAGRAPH_PLACEHOLDER) || text.contains(PARAGRAPH_INDEX_PLACEHOLDER) || text.contains(JUSTIFICATION_PLACEHOLDER) || text.contains(EXCERPT_PLACEHOLDER) || text.contains(
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(
@ -464,6 +465,10 @@ public class WordReportGenerationService {
foundPlaceholders.add(PAGE_PLACEHOLDER);
return input -> String.valueOf(input.getEntry().getPage());
}
if (placeholder.equals(PARAGRAPH_INDEX_PLACEHOLDER)) {
foundPlaceholders.add(PARAGRAPH_INDEX_PLACEHOLDER);
return input -> String.valueOf(input.getEntry().getParagraphIdx());
}
if (placeholder.equals(PARAGRAPH_PLACEHOLDER)) {
foundPlaceholders.add(PARAGRAPH_PLACEHOLDER);
return input -> input.getEntry().getSection();

View File

@ -8,6 +8,7 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import org.apache.commons.io.IOUtils;
@ -15,6 +16,7 @@ import org.springframework.stereotype.Service;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType;
import com.iqser.red.service.persistence.service.v1.api.shared.mongo.service.EntityLogMongoService;
import com.iqser.red.service.redaction.report.v1.api.model.StoredFileInformation;
import com.iqser.red.storage.commons.service.StorageService;
import com.knecon.fforesight.tenantcommons.TenantContext;
@ -28,6 +30,8 @@ public class ReportStorageService {
private final StorageService storageService;
private final EntityLogMongoService entityLogMongoService;
public String storeObject(String downloadId, byte[] data) {
@ -81,12 +85,14 @@ public class ReportStorageService {
public EntityLog getEntityLog(String dossierId, String fileId, List<String> excludedTypes) {
EntityLog entityLog;
entityLog = storageService.readJSONObject(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, FileType.ENTITY_LOG), EntityLog.class);
if (excludedTypes != null) {
entityLog.getEntityLogEntry().removeIf(entry -> excludedTypes.contains(entry.getType()));
Optional<EntityLog> entityLog = entityLogMongoService.findEntityLogByDossierIdAndFileId(dossierId, fileId);
if (entityLog.isEmpty()) {
throw new RuntimeException(String.format("Can't find entity log for dossierId %s and fileId %s", dossierId, fileId));
}
return entityLog;
if (excludedTypes != null) {
entityLog.get().getEntityLogEntry().removeIf(entry -> excludedTypes.contains(entry.getType()));
}
return entityLog.get();
}
}

View File

@ -35,6 +35,16 @@ spring:
max-attempts: 3
max-interval: 15000
prefetch: 1
data:
mongodb:
auto-index-creation: true
# todo: multi-tenancy
database: redaction
host: ${MONGODB_HOST:localhost}
port: ${MONGODB_PORT:27017}
username: ${MONGODB_USER}
password: ${MONGODB_PASSWORD}
management:
endpoint:

View File

@ -232,11 +232,12 @@ public class PlaceholderTest {
Assertions.assertNotNull(placeholders);
System.out.println(placeholders.size() + " placeholders: " + placeholders);
Assertions.assertFalse(placeholders.isEmpty());
Assertions.assertEquals(12, placeholders.size());
Assertions.assertEquals(13, placeholders.size());
Assertions.assertTrue(placeholders.contains("{{test1}}"));
Assertions.assertTrue(placeholders.contains("{{file.test.1}}"));
Assertions.assertFalse(placeholders.contains("{{test2}}"));
Assertions.assertFalse(placeholders.contains("{{TEST1}}"));
Assertions.assertTrue(placeholders.contains("{{redaction.paragraphIdx}}"));
Assertions.assertFalse(placeholders.contains("{{does.not.exist}}"));
Assertions.assertFalse(placeholders.contains("{{file.test.not.exist}}"));
}
@ -321,11 +322,12 @@ public class PlaceholderTest {
Assertions.assertNotNull(placeholders);
System.out.println(placeholders.size() + " placeholders: " + placeholders);
Assertions.assertFalse(placeholders.isEmpty());
Assertions.assertEquals(6, placeholders.size());
Assertions.assertEquals(7, placeholders.size());
Assertions.assertTrue(placeholders.contains("{{test1}}"));
Assertions.assertTrue(placeholders.contains("{{file.test.1}}"));
Assertions.assertTrue(placeholders.contains("{{file.name}}"));
Assertions.assertTrue(placeholders.contains("{{redaction.paragraph}}"));
Assertions.assertTrue(placeholders.contains("{{redaction.paragraphIdx}}"));
Assertions.assertFalse(placeholders.contains("{{test2}}"));
Assertions.assertFalse(placeholders.contains("{{TEST1}}"));
Assertions.assertFalse(placeholders.contains("{{does.not.exist}}"));

View File

@ -158,7 +158,7 @@ public class RedactionReportIntegrationTest {
Dossier dossier = prepareDossier();
FileModel fileModel = FileModel.builder().filename("filename").build();
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLogWithParagraphIdx.json").getInputStream(), EntityLog.class);
List<EntityLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = entityLogConverterService.convertAndSort(DOSSIER_ID, FILE_ID, entityLog, legalBasisMapping, new HashMap<>());
@ -195,7 +195,7 @@ public class RedactionReportIntegrationTest {
Dossier dossier = prepareDossier();
FileModel fileModel = FileModel.builder().filename("filename").build();
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLogWithParagraphIdx.json").getInputStream(), EntityLog.class);
List<EntityLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = entityLogConverterService.convertAndSort(DOSSIER_ID, FILE_ID, entityLog, legalBasisMapping, new HashMap<>());
@ -241,7 +241,7 @@ public class RedactionReportIntegrationTest {
assertThat(contentOfParagraphs).isEqualTo(expectedContent);
try (FileOutputStream fileOutputStream = new FileOutputStream(getTemporaryDirectory() + "/IUCLID_Template_justification.docx")) {
try (FileOutputStream fileOutputStream = new FileOutputStream("IUCLID_Template_justification.docx")) {
fileOutputStream.write(wordReportGenerationService.toByteArray(doc));
}
}
@ -324,13 +324,13 @@ public class RedactionReportIntegrationTest {
Dossier dossier = prepareDossier();
FileModel fileStatus = FileModel.builder().filename("filename").build();
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLogWithParagraphIdx.json").getInputStream(), EntityLog.class);
List<EntityLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = entityLogConverterService.convertAndSort(DOSSIER_ID, FILE_ID, entityLog, legalBasisMapping, new HashMap<>());
FileModel fileModelSecondFile = FileModel.builder().filename("secondFile").build();
EntityLog entityLogSecondFile = objectMapper.readValue(new ClassPathResource("files/entityLogWithManualRedactions.json").getInputStream(), EntityLog.class);
EntityLog entityLogSecondFile = objectMapper.readValue(new ClassPathResource("files/entityLogWithParagraphIdx.json").getInputStream(), EntityLog.class);
List<ReportRedactionEntry> reportEntriesSecondFile = entityLogConverterService.convertAndSort(DOSSIER_ID, FILE_ID, entityLogSecondFile, legalBasisMapping, new HashMap<>());
ClassPathResource templateResource = new ClassPathResource("templates/Seeds-NewJustificationForm.docx");
@ -355,7 +355,7 @@ public class RedactionReportIntegrationTest {
Dossier dossier = prepareDossier();
FileModel fileModel = FileModel.builder().filename("filename").build();
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLogWithParagraphIdx.json").getInputStream(), EntityLog.class);
List<EntityLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = entityLogConverterService.convertAndSort(DOSSIER_ID, FILE_ID, entityLog, legalBasisMapping, new HashMap<>());
@ -392,7 +392,7 @@ public class RedactionReportIntegrationTest {
Dossier dossier = prepareDossier();
FileModel fileModel = FileModel.builder().filename("filename").dossierId(dossier.getDossierId()).fileAttributes(Map.of("TestAttribute", "Lorem Ipsum")).build();
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLogWithManualRedactions.json").getInputStream(), EntityLog.class);
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLogWithParagraphIdx.json").getInputStream(), EntityLog.class);
List<EntityLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
Map<String, String> mapOfEntityDisplayName = createEntityDisplayNames(entityLog);
@ -421,7 +421,7 @@ public class RedactionReportIntegrationTest {
public void testExcelTemplateReportGenerationMultiFile() {
Dossier dossier = prepareDossier();
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLogWithParagraphIdx.json").getInputStream(), EntityLog.class);
List<EntityLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
Map<String, String> mapOfEntityDisplayName = createEntityDisplayNames(entityLog);
@ -463,7 +463,7 @@ public class RedactionReportIntegrationTest {
public void testExcelPlaceholders() {
Dossier dossier = prepareDossier();
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLogWithParagraphIdx.json").getInputStream(), EntityLog.class);
List<EntityLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
Map<String, String> mapOfEntityDisplayName = createEntityDisplayNames(entityLog);
@ -503,7 +503,7 @@ public class RedactionReportIntegrationTest {
.fileAttributes(Map.of("TestAttribute", "Lorem Ipsum", "1b5ebe26-34f2-4c3b-983d-c0f0a010302c", "402"))
.build();
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/scm/entityLog.json").getInputStream(), EntityLog.class);
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/scm/entityLogWithParagraphIdx.json").getInputStream(), EntityLog.class);
List<EntityLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/scm/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
ComponentLog componentLog = objectMapper.readValue(new ClassPathResource("files/scm/componentLog.json").getInputStream(), ComponentLog.class);

View File

@ -232,7 +232,7 @@ public class RedactionReportV2IntegrationTest {
@SneakyThrows
private void prepareStorage(int id) {
var entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
var entityLog = objectMapper.readValue(new ClassPathResource("files/entityLogWithParagraphIdx.json").getInputStream(), EntityLog.class);
fileSystemBackedStorageService.storeJSONObject(TenantContext.getTenantId(), StorageIdUtils.getStorageId("dossierId", "fileId" + id, FileType.ENTITY_LOG), entityLog);
when(entityLogClient.getEntityLog("dossierId", "fileId" + id, null, true)).thenReturn(entityLog);
}

View File

@ -9,6 +9,14 @@ management:
spring:
main:
allow-circular-references: true
data:
mongodb:
auto-index-creation: true
# todo: multi-tenancy
database: redaction
host: ${MONGODB_HOST:localhost}
port: ${MONGODB_PORT:27017}
username: ${MONGODB_USER}
password: ${MONGODB_PASSWORD}
persistence-service.url: "http://mock.url"