RED-6098: Added methods to get types which are hint and changed check for skipped entries in report accordingly
This commit is contained in:
parent
409437fbd6
commit
7958a7a5ac
@ -5,9 +5,11 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -56,7 +58,7 @@ public class RedactionLogConverterService {
|
||||
}
|
||||
var legalBasisMappings = redactionLog.getLegalBasis();
|
||||
|
||||
return convertAndSort(redactionLog, legalBasisMappings, mapOfEntityDisplayName);
|
||||
return convertAndSort(redactionLog, legalBasisMappings, mapOfEntityDisplayName, dossierId);
|
||||
}
|
||||
|
||||
|
||||
@ -77,12 +79,17 @@ public class RedactionLogConverterService {
|
||||
}
|
||||
|
||||
|
||||
public List<ReportRedactionEntry> convertAndSort(RedactionLog redactionLog, List<RedactionLogLegalBasis> legalBasisMappings, Map<String, String> mapOfEntityDisplayName) {
|
||||
public List<ReportRedactionEntry> convertAndSort(RedactionLog redactionLog,
|
||||
List<RedactionLogLegalBasis> legalBasisMappings,
|
||||
Map<String, String> mapOfEntityDisplayName,
|
||||
String dossierId) {
|
||||
|
||||
List<ReportRedactionEntry> reportEntries = new ArrayList<>();
|
||||
|
||||
var allTypes = dictionaryClient.getAllTypesForDossier(dossierId, false);
|
||||
|
||||
redactionLog.getRedactionLogEntry().forEach(entry -> {
|
||||
var isSkipped = !entry.isRedacted() && !entry.isHint() && !entry.getType().equals("hint_only") && !entry.getType().equals("published_information");
|
||||
var isSkipped = !entry.isRedacted() && !entry.isHint() && !isHintType(allTypes, entry.getType());
|
||||
if (entry.isRedacted() || isSkipped) {
|
||||
|
||||
if (entry.lastChangeIsRemoved()) {
|
||||
@ -199,4 +206,21 @@ public class RedactionLogConverterService {
|
||||
return "Text on page " + position.getPage();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
This method catches types like hint_only or published_information
|
||||
*/
|
||||
private boolean isHintType(List<Type> types, String type) {
|
||||
|
||||
var matchingTypes = getMatchingTypes(types, type);
|
||||
Optional<Type> foundType = matchingTypes.stream().findFirst();
|
||||
return foundType.map(Type::isHint).orElse(false);
|
||||
}
|
||||
|
||||
|
||||
private List<Type> getMatchingTypes(List<Type> types, String type) {
|
||||
|
||||
return types.stream().filter(t -> t.getType().equals(type)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -124,7 +124,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<>());
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), null);
|
||||
|
||||
var wordTemplateResource = new ClassPathResource("templates/Justification Appendix A1.docx");
|
||||
var imageResource = new ClassPathResource("files/exampleImage.jpg");
|
||||
@ -161,7 +161,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<>());
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), null);
|
||||
|
||||
var wordTemplateResource = new ClassPathResource("templates/Justification Appendix A2.docx");
|
||||
var imageResource = new ClassPathResource("files/exampleImage.jpg");
|
||||
@ -198,7 +198,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<>());
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), null);
|
||||
|
||||
FileModel fileStatus = FileModel.builder().filename("filename").build();
|
||||
Dossier dossier = Dossier.builder().dossierName("dossierName").build();
|
||||
@ -224,7 +224,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<>());
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), null);
|
||||
|
||||
FileModel fileStatus = FileModel.builder().filename("filename").build();
|
||||
Dossier dossier = Dossier.builder().dossierName("dossierName").build();
|
||||
@ -250,10 +250,10 @@ 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<>());
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), null);
|
||||
|
||||
RedactionLog redactionLogSecondFile = objectMapper.readValue(new ClassPathResource("files/excelReportRedactionLog.json").getInputStream(), RedactionLog.class);
|
||||
List<ReportRedactionEntry> reportEntriesSecondFile = redactionLogConverterService.convertAndSort(redactionLogSecondFile, legalBasisMapping, new HashMap<>());
|
||||
List<ReportRedactionEntry> reportEntriesSecondFile = redactionLogConverterService.convertAndSort(redactionLogSecondFile, legalBasisMapping, new HashMap<>(), null);
|
||||
FileModel fileModelSecondFile = FileModel.builder().filename("secondFile").build();
|
||||
|
||||
FileModel fileStatus = FileModel.builder().filename("filename").build();
|
||||
@ -281,7 +281,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<>());
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), null);
|
||||
|
||||
var wordTemplateResource = new ClassPathResource("templates/6464 appendix_b EFSA dRAR justification.docx");
|
||||
var imageResource = new ClassPathResource("files/exampleImage.jpg");
|
||||
@ -319,7 +319,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);
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, mapOfEntityDisplayName, null);
|
||||
|
||||
FileModel fileModel = FileModel.builder().filename("filename").fileAttributes(Map.of("TestAttribute", "Lorem Ipsum")).build();
|
||||
|
||||
@ -349,7 +349,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);
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, mapOfEntityDisplayName, null);
|
||||
|
||||
FileModel fileModel = FileModel.builder().filename("filename").build();
|
||||
|
||||
@ -364,7 +364,7 @@ public class RedactionReportIntegrationTest {
|
||||
excelTemplateReportGenerationService.generateExcelReport(reportEntries, placeholders, "test", writeWorkbook, "dossierName", fileModel, excelModel, false);
|
||||
|
||||
RedactionLog redactionLogSecondFile = objectMapper.readValue(new ClassPathResource("files/excelReportRedactionLog.json").getInputStream(), RedactionLog.class);
|
||||
List<ReportRedactionEntry> reportEntriesSecondFile = redactionLogConverterService.convertAndSort(redactionLogSecondFile, legalBasisMapping, mapOfEntityDisplayName);
|
||||
List<ReportRedactionEntry> reportEntriesSecondFile = redactionLogConverterService.convertAndSort(redactionLogSecondFile, legalBasisMapping, mapOfEntityDisplayName, null);
|
||||
FileModel fileModelSecondFile = FileModel.builder().filename("secondFile").build();
|
||||
excelTemplateReportGenerationService.generateExcelReport(reportEntriesSecondFile,
|
||||
placeholders,
|
||||
@ -390,7 +390,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);
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, mapOfEntityDisplayName, null);
|
||||
var imageResource = new ClassPathResource("files/exampleImage.jpg");
|
||||
|
||||
FileModel fileModel = FileModel.builder().filename("filename").build();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user