Merge branch 'RED-7745' into 'master'
RED-7745 - Use EntityLog in redaction-report-service Closes RED-7745 See merge request redactmanager/redaction-report-service!11
This commit is contained in:
commit
f4b5600603
@ -24,7 +24,7 @@
|
||||
|
||||
|
||||
<properties>
|
||||
<persistence-service.version>2.198.0</persistence-service.version>
|
||||
<persistence-service.version>2.217.0</persistence-service.version>
|
||||
<apache-poi.version>5.2.3</apache-poi.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.client;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.internal.resources.RedactionLogResource;
|
||||
|
||||
@FeignClient(name = "RedactionLogResource", url = "${persistence-service.url}")
|
||||
public interface RedactionLogClient extends RedactionLogResource {
|
||||
|
||||
}
|
||||
@ -43,8 +43,7 @@ public class RSSController implements RSSResource {
|
||||
}
|
||||
fileResponses.add(new RSSFileResponse(fileName, result));
|
||||
}
|
||||
RSSResponse rssResponse = new RSSResponse(fileResponses);
|
||||
return rssResponse;
|
||||
return new RSSResponse(fileResponses);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -14,18 +14,20 @@ import java.util.stream.Collectors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AnnotationStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.Dossier;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Change;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.ChangeType;
|
||||
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.analysislog.entitylog.EntityLogEntry;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLogLegalBasis;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntryState;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntryType;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.ManualRedactionType;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Position;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.Type;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.ManualRedactionType;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.Rectangle;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLog;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLogEntry;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLogLegalBasis;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DictionaryClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.RedactionLogClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.ReportRedactionEntry;
|
||||
import com.iqser.red.service.redaction.report.v1.server.storage.ReportStorageService;
|
||||
import com.iqser.red.storage.commons.exception.StorageObjectDoesNotExist;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
@ -33,33 +35,32 @@ import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class RedactionLogConverterService {
|
||||
|
||||
private final RedactionLogClient redactionLogClient;
|
||||
public class EntityLogConverterService {
|
||||
|
||||
private final DossierClient dossierClient;
|
||||
|
||||
private final DictionaryClient dictionaryClient;
|
||||
|
||||
private final ReportStorageService reportStorageService;
|
||||
|
||||
|
||||
@Timed("redactmanager_getReportEntries")
|
||||
public List<ReportRedactionEntry> getReportEntries(String dossierId, String fileId, boolean isExcluded, Dossier dossier) {
|
||||
public List<ReportRedactionEntry> getReportEntries(String dossierId, String fileId, boolean isExcluded) {
|
||||
|
||||
if (isExcluded) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
RedactionLog redactionLog;
|
||||
EntityLog entityLog;
|
||||
Map<String, String> mapOfEntityDisplayName;
|
||||
try {
|
||||
redactionLog = redactionLogClient.getRedactionLog(dossierId, fileId, new ArrayList<>(), true, false);
|
||||
entityLog = reportStorageService.getEntityLog(dossierId, fileId, new ArrayList<>());
|
||||
mapOfEntityDisplayName = fillMapOfTypeAndEntityDisplayName(dossierId);
|
||||
} catch (StorageObjectDoesNotExist e) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
var legalBasisMappings = redactionLog.getLegalBasis();
|
||||
|
||||
return convertAndSort(redactionLog, legalBasisMappings, mapOfEntityDisplayName, dossier);
|
||||
return convertAndSort(entityLog, entityLog.getLegalBasis(), mapOfEntityDisplayName);
|
||||
}
|
||||
|
||||
|
||||
@ -80,20 +81,19 @@ public class RedactionLogConverterService {
|
||||
}
|
||||
|
||||
|
||||
public List<ReportRedactionEntry> convertAndSort(RedactionLog redactionLog,
|
||||
List<RedactionLogLegalBasis> legalBasisMappings,
|
||||
Map<String, String> mapOfEntityDisplayName,
|
||||
Dossier dossier) {
|
||||
public List<ReportRedactionEntry> convertAndSort(EntityLog entityLog,
|
||||
List<EntityLogLegalBasis> legalBasisMappings,
|
||||
Map<String, String> mapOfEntityDisplayName) {
|
||||
|
||||
List<ReportRedactionEntry> reportEntries = new ArrayList<>();
|
||||
|
||||
var allTypes = dictionaryClient.getAllTypesForDossierTemplate(dossier.getDossierTemplateId(), false);
|
||||
entityLog.getEntityLogEntry().forEach(entry -> {
|
||||
var isSkipped = entry.getState() != EntryState.APPLIED
|
||||
&& !(entry.getEntryType().equals(EntryType.HINT) || entry.getState().equals(EntryState.IGNORED));
|
||||
|
||||
redactionLog.getRedactionLogEntry().forEach(entry -> {
|
||||
var isSkipped = !entry.isRedacted() && !entry.isHint() && !isHintType(allTypes, entry.getType());
|
||||
if (entry.isRedacted() || isSkipped) {
|
||||
if (entry.getState() == EntryState.APPLIED || isSkipped) {
|
||||
|
||||
if (entry.lastChangeIsRemoved()) {
|
||||
if (lastChangeIsRemoved(entry.getChanges())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -101,43 +101,42 @@ public class RedactionLogConverterService {
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.isRecommendation()) {
|
||||
if (entry.getEntryType() == EntryType.RECOMMENDATION) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.isFalsePositive()) {
|
||||
if (entry.getEntryType() == EntryType.FALSE_POSITIVE ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.getManualChanges() != null && entry.getManualChanges().size() != 0 && entry.getManualChanges()
|
||||
.get(entry.getManualChanges().size() - 1)
|
||||
.getManualRedactionType()
|
||||
.equals(ManualRedactionType.ADD_LOCALLY) && entry.getManualChanges()
|
||||
.get(entry.getManualChanges().size() - 1)
|
||||
.getAnnotationStatus()
|
||||
.equals(AnnotationStatus.DECLINED)) {
|
||||
if (entry.getManualChanges() != null
|
||||
&& entry.getManualChanges().size() != 0
|
||||
&& entry.getManualChanges()
|
||||
.get(entry.getManualChanges().size() - 1)
|
||||
.getManualRedactionType()
|
||||
.equals(ManualRedactionType.ADD_LOCALLY)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<Integer> pages = new HashSet<>();
|
||||
for (Rectangle position : entry.getPositions()) {
|
||||
for (Position position : entry.getPositions()) {
|
||||
|
||||
if (pages.isEmpty() || !pages.contains(position.getPage())) {
|
||||
pages.add(position.getPage());
|
||||
reportEntries.add(new ReportRedactionEntry(position.getPage(),
|
||||
position.getTopLeft().getX(),
|
||||
position.getTopLeft().getY(),
|
||||
if (pages.isEmpty() || !pages.contains(position.getPageNumber())) {
|
||||
pages.add(position.getPageNumber());
|
||||
reportEntries.add(new ReportRedactionEntry(position.getPageNumber(),
|
||||
position.x(),
|
||||
position.y(),
|
||||
getSection(entry, position),
|
||||
checkTextForNull(entry.getLegalBasis()) + " " + legalBasisMappings.stream()
|
||||
.filter(lbm -> lbm.getReason().equalsIgnoreCase(entry.getLegalBasis()))
|
||||
.findAny()
|
||||
.map(RedactionLogLegalBasis::getDescription)
|
||||
.map(EntityLogLegalBasis::getDescription)
|
||||
.orElse(""),
|
||||
entry.getLegalBasis(),
|
||||
legalBasisMappings.stream()
|
||||
.filter(lbm -> lbm.getReason().equalsIgnoreCase(entry.getLegalBasis()))
|
||||
.findAny()
|
||||
.map(RedactionLogLegalBasis::getDescription)
|
||||
.map(EntityLogLegalBasis::getDescription)
|
||||
.orElse(""),
|
||||
checkTextForNull(entry.getTextBefore()) + entry.getValue() + checkTextForNull(entry.getTextAfter()),
|
||||
entry.getValue(),
|
||||
@ -174,13 +173,13 @@ public class RedactionLogConverterService {
|
||||
}
|
||||
|
||||
|
||||
private String getSection(RedactionLogEntry entry, Rectangle position) {
|
||||
private String getSection(EntityLogEntry entry, Position position) {
|
||||
|
||||
if (StringUtils.isNotBlank(entry.getSection())) {
|
||||
return entry.getSection();
|
||||
}
|
||||
|
||||
if (entry.isImage()) {
|
||||
if (entry.getEntryType() == EntryType.IMAGE) {
|
||||
return "Image: " + humanize(entry.getType());
|
||||
}
|
||||
|
||||
@ -188,7 +187,7 @@ public class RedactionLogConverterService {
|
||||
return "Non-readable content";
|
||||
}
|
||||
|
||||
return "Text on page " + position.getPage();
|
||||
return "Text on page " + position.getPageNumber();
|
||||
}
|
||||
|
||||
|
||||
@ -224,4 +223,13 @@ public class RedactionLogConverterService {
|
||||
|
||||
}
|
||||
|
||||
private boolean lastChangeIsRemoved(List<Change> changes) {
|
||||
|
||||
return last(changes).map(c -> c.getType() == ChangeType.REMOVED).orElse(false);
|
||||
}
|
||||
|
||||
private <T> Optional<T> last(List<T> list) {
|
||||
|
||||
return list == null || list.isEmpty() ? Optional.empty() : Optional.of(list.get(list.size() - 1));
|
||||
}
|
||||
}
|
||||
@ -157,7 +157,7 @@ public class ExcelReportGenerationService {
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Report Generation took: {} for file with id {}, pageCount: {}, redactionLogEntryCount: {}, reportName: {}, className: {}",
|
||||
log.info("Report Generation took: {} for file with id {}, pageCount: {}, entityLogEntryCount: {}, reportName: {}, className: {}",
|
||||
System.currentTimeMillis() - start,
|
||||
fileModel.getId(),
|
||||
fileModel.getNumberOfPages(),
|
||||
|
||||
@ -2,27 +2,36 @@ package com.iqser.red.service.redaction.report.v1.server.service;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.ChangeType;
|
||||
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.analysislog.entitylog.EntityLogEntry;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntryState;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Position;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.component.ComponentsOverrides;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileAttributeConfig;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileModel;
|
||||
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.model.redactionlog.ChangeType;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.Rectangle;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLog;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLogEntry;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.rss.DetailedRSSFileResponse;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.rss.DetailedRSSResponse;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.rss.SCMComponent;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.rss.ScmAnnotation;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.FileAttributesConfigClient;
|
||||
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.storage.ReportStorageService;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
@ -74,7 +83,6 @@ public class RSSPoc2Service {
|
||||
public static final String WHAT_WAS_THE_APPROACH_USED = "What_was_the_approach_used";
|
||||
public static final String DOSES_MG_PER_KG_BW = "Doses_mg_per_kg_bw";
|
||||
|
||||
private final RedactionLogClient redactionLogClient;
|
||||
private final FileStatusClient statusClient;
|
||||
private final ReportStorageService reportStorageService;
|
||||
private final ObjectMapper objectMapper;
|
||||
@ -143,116 +151,116 @@ public class RSSPoc2Service {
|
||||
String oecd = getOecdNumber(file);
|
||||
|
||||
Map<String, SCMComponent> resultMap = new LinkedHashMap<>();
|
||||
var redactionLog = redactionLogClient.getRedactionLog(dossierId, file.getId(), new ArrayList<>(), true, false);
|
||||
var entityLog = reportStorageService.getEntityLog(dossierId, file.getId(), new ArrayList<>());
|
||||
|
||||
sortRedactionLog(redactionLog);
|
||||
sortEntityLog(entityLog);
|
||||
|
||||
redactionLog.getRedactionLogEntry().removeIf(r -> !r.isRedacted() || r.getChanges().get(r.getChanges().size() - 1).getType().equals(ChangeType.REMOVED));
|
||||
entityLog.getEntityLogEntry().removeIf(r -> r.getState() != EntryState.APPLIED || r.getChanges().get(r.getChanges().size() - 1).getType().equals(ChangeType.REMOVED));
|
||||
|
||||
if(oecd == null){
|
||||
resultMap.putAll(getAllEntities(redactionLog));
|
||||
resultMap.putAll(getAllEntities(entityLog));
|
||||
setOverrideValues(dossierId, fileId, resultMap);
|
||||
rssFileResponses.add(new DetailedRSSFileResponse(file.getFilename(), resultMap));
|
||||
continue;
|
||||
}
|
||||
|
||||
resultMap.put(STUDY_TITLE, getFirstEntryOrElse(redactionLog, "title", ""));
|
||||
resultMap.put(REPORT_NUMBER, getFirstEntryOrElse(redactionLog, "report_number", ""));
|
||||
resultMap.put(PERFORMING_LABORATORY, getPerformingLaboratory(redactionLog));
|
||||
resultMap.put(EXPERIMENTAL_STARTING_DATE, getConvertedDates(redactionLog, "experimental_start_date"));
|
||||
resultMap.put(EXPERIMENTAL_COMPLETION_DATE, getConvertedDates(redactionLog, "experimental_end_date"));
|
||||
resultMap.put(GLP_STUDY, ifPresentAddOrElse(redactionLog, "glp_study", "Yes", "No"));
|
||||
resultMap.put(CERTIFICATE_OF_ANALYSIS_BATCH_IDENTIFICATION, getJoinedUniqueValues(redactionLog, "batch_number", ", "));
|
||||
resultMap.put(TEST_GUIDELINE_1, getTestGuideline1(redactionLog));
|
||||
resultMap.put(TEST_GUIDELINE_2, getTestGuideline2(redactionLog));
|
||||
resultMap.put(STUDY_TITLE, getFirstEntryOrElse(entityLog, "title"));
|
||||
resultMap.put(REPORT_NUMBER, getFirstEntryOrElse(entityLog, "report_number"));
|
||||
resultMap.put(PERFORMING_LABORATORY, getPerformingLaboratory(entityLog));
|
||||
resultMap.put(EXPERIMENTAL_STARTING_DATE, getConvertedDates(entityLog, "experimental_start_date"));
|
||||
resultMap.put(EXPERIMENTAL_COMPLETION_DATE, getConvertedDates(entityLog, "experimental_end_date"));
|
||||
resultMap.put(GLP_STUDY, ifPresentAddOrElse(entityLog, "glp_study", "Yes", "No"));
|
||||
resultMap.put(CERTIFICATE_OF_ANALYSIS_BATCH_IDENTIFICATION, getJoinedUniqueValues(entityLog, "batch_number"));
|
||||
resultMap.put(TEST_GUIDELINE_1, getTestGuideline1(entityLog));
|
||||
resultMap.put(TEST_GUIDELINE_2, getTestGuideline2(entityLog));
|
||||
|
||||
if (oecdIn(oecd, Set.of("402", "403", "404", "405", "425", "429", "436", "471"))) {
|
||||
|
||||
resultMap.put(STUDY_CONCLUSION, combineValuesOfFirstFoundSection(redactionLog, "study_conclusion", " ", ""));
|
||||
resultMap.put(STUDY_CONCLUSION, combineValuesOfFirstFoundSection(entityLog));
|
||||
|
||||
resultMap.putAll(getAsBlockPerAnnotation(redactionLog, "guideline_deviation", DEVIATION_FROM_THE_GUIDELINE));
|
||||
resultMap.putAll(getAsBlockPerAnnotation(entityLog, "guideline_deviation", DEVIATION_FROM_THE_GUIDELINE));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("402", "403", "404", "405", "425", "429", "436", "471"))) {
|
||||
|
||||
resultMap.put(SPECIES, getFirstEntryOrElse(redactionLog, "species", ""));
|
||||
resultMap.put(STRAIN, getFirstEntryOrElse(redactionLog, "strain", ""));
|
||||
resultMap.put(SPECIES, getFirstEntryOrElse(entityLog, "species"));
|
||||
resultMap.put(STRAIN, getFirstEntryOrElse(entityLog, "strain"));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("402", "403", "425", "436"))) {
|
||||
resultMap.put(CONCLUSION_LD_50_MG_PER_MG, getJoinedUniqueValues(redactionLog, "ld50_value", ", "));
|
||||
resultMap.put(CONCLUSION_LD_50_GREATER_THAN, ifPresentAddOrElse(redactionLog, "ld50_greater", "Greater than", ""));
|
||||
resultMap.put(CONCLUSION_MINIMUM_CONFIDENCE, getJoinedUniqueValues(redactionLog, "confidence_minimal", ", "));
|
||||
resultMap.put(CONCLUSION_MAXIMUM_CONFIDENCE, getJoinedUniqueValues(redactionLog, "confidence_maximal", ", "));
|
||||
resultMap.put(CONCLUSION_LD_50_MG_PER_MG, getJoinedUniqueValues(entityLog, "ld50_value"));
|
||||
resultMap.put(CONCLUSION_LD_50_GREATER_THAN, ifPresentAddOrElse(entityLog, "ld50_greater", "Greater than", ""));
|
||||
resultMap.put(CONCLUSION_MINIMUM_CONFIDENCE, getJoinedUniqueValues(entityLog, "confidence_minimal"));
|
||||
resultMap.put(CONCLUSION_MAXIMUM_CONFIDENCE, getJoinedUniqueValues(entityLog, "confidence_maximal"));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("402"))) {
|
||||
resultMap.put(NECROPSY_FINDINGS, getLongestCombinedSectionBlockOrElse(redactionLog, "necropsy_findings", ""));
|
||||
resultMap.put(DOSES_MG_PER_KG_BW, getAsOneBlock(redactionLog, "doses_(mg_kg_bw)"));
|
||||
resultMap.put(NECROPSY_FINDINGS, getLongestCombinedSectionBlockOrElse(entityLog));
|
||||
resultMap.put(DOSES_MG_PER_KG_BW, getAsOneBlock(entityLog, "doses_(mg_kg_bw)"));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("403", "436"))) {
|
||||
|
||||
resultMap.putAll(getAsBlockPerAnnotation(redactionLog, "necropsy_findings", NECROPSY_FINDINGS));
|
||||
resultMap.putAll(getAsBlockPerAnnotation(entityLog, "necropsy_findings", NECROPSY_FINDINGS));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("403", "436"))) {
|
||||
|
||||
resultMap.put(CONDUCTED_WITHIN_4_HOURS_OF_EXPOSURE, getAsOneBlock(redactionLog, "4h_exposure"));
|
||||
resultMap.put(CONDUCTED_WITHIN_4_HOURS_OF_EXPOSURE, getAsOneBlock(entityLog, "4h_exposure"));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("404", "405", "429", "406", "428", "438", "439", "474", "487"))) {
|
||||
|
||||
resultMap.put(STUDY_DESIGN, getAsOneBlock(redactionLog, "study_design"));
|
||||
resultMap.put(STUDY_DESIGN, getAsOneBlock(entityLog, "study_design"));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("406", "428", "438", "439", "474", "487"))) {
|
||||
|
||||
resultMap.put(RESULTS_AND_CONCLUSIONS, getJoinedValues(redactionLog, "results_and_conclusion", " "));
|
||||
resultMap.put(RESULTS_AND_CONCLUSIONS, getJoinedValues(entityLog, "results_and_conclusion"));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("402"))) {
|
||||
|
||||
resultMap.putAll(getAsBlockPerAnnotation(redactionLog, "weight_behavior_changes", WEIGHT_BEHAVIOR_CHANGES));
|
||||
resultMap.putAll(getAsBlockPerAnnotation(entityLog, "weight_behavior_changes", WEIGHT_BEHAVIOR_CHANGES));
|
||||
|
||||
resultMap.put(MORTALITY_STATEMENT, getAsOneBlock(redactionLog, "mortality_statement"));
|
||||
resultMap.put(MORTALITY_STATEMENT, getAsOneBlock(entityLog, "mortality_statement"));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("403"))) {
|
||||
|
||||
resultMap.putAll(getAsBlockPerAnnotation(redactionLog, "clinical_observations", CLINICAL_OBSERVATIONS));
|
||||
resultMap.putAll(getAsBlockPerAnnotation(redactionLog, "bodyweight_changes", BODY_WEIGHT_CHANGES));
|
||||
resultMap.putAll(getAsBlockPerAnnotation(entityLog, "clinical_observations", CLINICAL_OBSERVATIONS));
|
||||
resultMap.putAll(getAsBlockPerAnnotation(entityLog, "bodyweight_changes", BODY_WEIGHT_CHANGES));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("404", "405"))) {
|
||||
|
||||
resultMap.put(DETAILING_OF_REPORTED_CHANGES, getAsOneBlock(redactionLog, "detailing"));
|
||||
resultMap.put(DETAILING_OF_REPORTED_CHANGES, getAsOneBlock(entityLog, "detailing"));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("405", "429"))) {
|
||||
|
||||
resultMap.put(SEX, getSex(redactionLog));
|
||||
resultMap.put(NUMBER_OF_ANIMALS, getNumberOfAnimals(redactionLog));
|
||||
resultMap.put(SEX, getSex(entityLog));
|
||||
resultMap.put(NUMBER_OF_ANIMALS, getNumberOfAnimals(entityLog));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("425"))) {
|
||||
|
||||
resultMap.putAll(getAsBlockPerAnnotation(redactionLog, "clinical_signs", CLINCAL_SIGNS));
|
||||
resultMap.putAll(getDoseMortality(redactionLog, DOSE_MORTALITY));
|
||||
resultMap.putAll(getAsBlockPerAnnotation(entityLog, "clinical_signs", CLINCAL_SIGNS));
|
||||
resultMap.putAll(getDoseMortality(entityLog));
|
||||
|
||||
resultMap.put(MORTALITY, getAsOneBlock(redactionLog, "mortality"));
|
||||
resultMap.put(DOSAGES, getFirstEntryOrElse(redactionLog, "dosages", ""));
|
||||
resultMap.put(MORTALITY, getAsOneBlock(entityLog, "mortality"));
|
||||
resultMap.put(DOSAGES, getFirstEntryOrElse(entityLog, "dosages"));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("429"))) {
|
||||
|
||||
resultMap.putAll(getAsBlockPerAnnotation(redactionLog, "preliminary_test_results", PRELIMINARY_TEST_RESULTS));
|
||||
resultMap.putAll(getAsBlockPerAnnotation(entityLog, "preliminary_test_results", PRELIMINARY_TEST_RESULTS));
|
||||
|
||||
resultMap.put(TEST_RESULTS, getAsOneBlock(redactionLog, "test_results"));
|
||||
resultMap.put(WAS_THE_DEFINITIVE_STUDY_CONDUCTED_WITH_POSITIVE_CONTROL, getAsOneBlock(redactionLog, "positive_control"));
|
||||
resultMap.put(TEST_RESULTS, getAsOneBlock(entityLog, "test_results"));
|
||||
resultMap.put(WAS_THE_DEFINITIVE_STUDY_CONDUCTED_WITH_POSITIVE_CONTROL, getAsOneBlock(entityLog, "positive_control"));
|
||||
|
||||
resultMap.put(RESULTS_MAIN_STUDY, getAsOneBlock(redactionLog, "results_(main_study)"));
|
||||
resultMap.put(WHAT_WAS_THE_APPROACH_USED, ifPresentAddOrElse(redactionLog, "approach_used", "Group", "Individual"));
|
||||
resultMap.put(RESULTS_MAIN_STUDY, getAsOneBlock(entityLog, "results_(main_study)"));
|
||||
resultMap.put(WHAT_WAS_THE_APPROACH_USED, ifPresentAddOrElse(entityLog, "approach_used", "Group", "Individual"));
|
||||
|
||||
}
|
||||
|
||||
@ -296,13 +304,13 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private Map<String, SCMComponent> getAllEntities(RedactionLog redactionLog){
|
||||
private Map<String, SCMComponent> getAllEntities(EntityLog entityLog){
|
||||
Map<String, SCMComponent> resultMap = new HashMap<>();
|
||||
|
||||
Set<String> existingTypes = redactionLog.getRedactionLogEntry().stream().map(RedactionLogEntry::getType).collect(Collectors.toSet());
|
||||
Set<String> existingTypes = entityLog.getEntityLogEntry().stream().map(EntityLogEntry::getType).collect(Collectors.toSet());
|
||||
|
||||
existingTypes.forEach(type -> {
|
||||
resultMap.put(type, getJoinedValues(redactionLog, type, " "));
|
||||
resultMap.put(type, getJoinedValues(entityLog, type));
|
||||
});
|
||||
|
||||
return resultMap;
|
||||
@ -314,43 +322,40 @@ public class RSSPoc2Service {
|
||||
public String getOecdNumber(FileModel file) {
|
||||
|
||||
var fileAttributesConfig = fileAttributesClient.getFileAttributeConfigs(file.getDossierTemplateId());
|
||||
var oecdFileAttributeConf = fileAttributesConfig.stream().filter(f -> f.getLabel().equals("OECD Number")).map(f -> f.getId()).findFirst();
|
||||
if (oecdFileAttributeConf.isPresent()) {
|
||||
return file.getFileAttributes().get(oecdFileAttributeConf.get());
|
||||
}
|
||||
return null;
|
||||
var oecdFileAttributeConf = fileAttributesConfig.stream().filter(f -> f.getLabel().equals("OECD Number")).map(FileAttributeConfig::getId).findFirst();
|
||||
return oecdFileAttributeConf.map(s -> file.getFileAttributes().get(s)).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
private void sortRedactionLog(RedactionLog redactionLog) {
|
||||
private void sortEntityLog(EntityLog entityLog) {
|
||||
|
||||
redactionLog.getRedactionLogEntry().sort((entry1, entry2) -> {
|
||||
if (entry1.getPositions().get(0).getPage() == entry2.getPositions().get(0).getPage()) {
|
||||
if (entry1.getPositions().get(0).getTopLeft().getY() == entry2.getPositions().get(0).getTopLeft().getY()) {
|
||||
return entry1.getPositions().get(0).getTopLeft().getX() <= entry2.getPositions().get(0).getTopLeft().getX() ? -1 : 1;
|
||||
entityLog.getEntityLogEntry().sort((entry1, entry2) -> {
|
||||
if (entry1.getPositions().get(0).getPageNumber() == entry2.getPositions().get(0).getPageNumber()) {
|
||||
if (entry1.getPositions().get(0).y() == entry2.getPositions().get(0).y()) {
|
||||
return entry1.getPositions().get(0).x() <= entry2.getPositions().get(0).x() ? -1 : 1;
|
||||
} else {
|
||||
return entry1.getPositions().get(0).getTopLeft().getY() <= entry2.getPositions().get(0).getTopLeft().getY() ? 1 : -1;
|
||||
return entry1.getPositions().get(0).y() <= entry2.getPositions().get(0).y() ? 1 : -1;
|
||||
}
|
||||
}
|
||||
return entry1.getPositions().get(0).getPage() < entry2.getPositions().get(0).getPage() ? -1 : 1;
|
||||
return entry1.getPositions().get(0).getPageNumber() < entry2.getPositions().get(0).getPageNumber() ? -1 : 1;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
private SCMComponent combineValuesOfFirstFoundSection(RedactionLog redactionLog, String type, String seperator, String elseValue) {
|
||||
private SCMComponent combineValuesOfFirstFoundSection(EntityLog entityLog) {
|
||||
|
||||
String transformation = String.format("Combine paragraphs of '%s' with seperator '%s' in first Section found", type, seperator);
|
||||
String transformation = String.format("Combine paragraphs of '%s' with separator '%s' in first Section found", "study_conclusion", " ");
|
||||
|
||||
var entries = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals(type)).toList();
|
||||
var entries = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals("study_conclusion")).toList();
|
||||
|
||||
if (entries.isEmpty()) {
|
||||
return SCMComponent.builder().originalValue(elseValue).transformation(transformation).build();
|
||||
return SCMComponent.builder().originalValue("").transformation(transformation).build();
|
||||
}
|
||||
|
||||
int firstSectionNr = entries.get(0).getSectionNumber();
|
||||
int firstSectionNr = entries.get(0).getContainingNodeId().get(0);
|
||||
|
||||
String value = entries.stream().filter(e -> e.getSectionNumber() == firstSectionNr).map(RedactionLogEntry::getValue).collect(Collectors.joining(seperator)).trim();
|
||||
String value = entries.stream().filter(e -> e.getContainingNodeId().get(0) == firstSectionNr).map(EntityLogEntry::getValue).collect(Collectors.joining(" ")).trim();
|
||||
|
||||
return SCMComponent.builder()
|
||||
.originalValue(value)
|
||||
@ -360,11 +365,11 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private SCMComponent getFirstEntryOrElse(RedactionLog redactionLog, String type, String elseValue) {
|
||||
private SCMComponent getFirstEntryOrElse(EntityLog entityLog, String type) {
|
||||
|
||||
String transformation = String.format("First found value of type '%s' or else '%s'", type, elseValue);
|
||||
String transformation = String.format("First found value of type '%s' or else '%s'", type, "");
|
||||
|
||||
var firstEntryOptional = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals(type)).findFirst();
|
||||
var firstEntryOptional = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals(type)).findFirst();
|
||||
|
||||
if (firstEntryOptional.isPresent()) {
|
||||
|
||||
@ -372,37 +377,35 @@ public class RSSPoc2Service {
|
||||
return SCMComponent.builder().originalValue(firstEntry.getValue()).scmAnnotations(List.of(toScmAnnotations(firstEntry))).transformation(transformation).build();
|
||||
}
|
||||
|
||||
return SCMComponent.builder().originalValue(elseValue).transformation(transformation).build();
|
||||
return SCMComponent.builder().originalValue("").transformation(transformation).build();
|
||||
}
|
||||
|
||||
|
||||
private SCMComponent getPerformingLaboratory(RedactionLog redactionLog) {
|
||||
private SCMComponent getPerformingLaboratory(EntityLog entityLog) {
|
||||
|
||||
String transformation = "Value of laboratory_name, combined with laboratory_country if distance is small";
|
||||
|
||||
var laboratoryEntry = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("laboratory_name")).findFirst();
|
||||
if (!laboratoryEntry.isPresent()) {
|
||||
var laboratoryEntry = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals("laboratory_name")).findFirst();
|
||||
if (laboratoryEntry.isEmpty()) {
|
||||
return getEmptyComponent(transformation);
|
||||
}
|
||||
|
||||
var laboratoryCountry = redactionLog.getRedactionLogEntry()
|
||||
var laboratoryCountry = entityLog.getEntityLogEntry()
|
||||
.stream()
|
||||
.filter(r -> r.getType().equals("laboratory_country") && Math.abs(laboratoryEntry.get().getPositions().get(0).getTopLeft().getY() - r.getPositions()
|
||||
.filter(r -> r.getType().equals("laboratory_country") && Math.abs(laboratoryEntry.get().getPositions().get(0).y() - r.getPositions()
|
||||
.get(0)
|
||||
.getTopLeft()
|
||||
.getY()) < 80)
|
||||
.collect(Collectors.toList());
|
||||
.y()) < 80)
|
||||
.toList();
|
||||
|
||||
RedactionLogEntry countryWithSmallestDistance = null;
|
||||
EntityLogEntry countryWithSmallestDistance = null;
|
||||
for (var entry : laboratoryCountry) {
|
||||
|
||||
if (countryWithSmallestDistance == null) {
|
||||
countryWithSmallestDistance = entry;
|
||||
} else if (Math.abs(laboratoryEntry.get().getPositions().get(0).getTopLeft().getY() - entry.getPositions().get(0).getTopLeft().getY()) < Math.abs(laboratoryEntry.get()
|
||||
} else if (Math.abs(laboratoryEntry.get().getPositions().get(0).y() - entry.getPositions().get(0).y()) < Math.abs(laboratoryEntry.get()
|
||||
.getPositions()
|
||||
.get(0)
|
||||
.getTopLeft()
|
||||
.getY() - countryWithSmallestDistance.getPositions().get(0).getTopLeft().getY())) {
|
||||
.y() - countryWithSmallestDistance.getPositions().get(0).y())) {
|
||||
countryWithSmallestDistance = entry;
|
||||
}
|
||||
|
||||
@ -412,9 +415,7 @@ public class RSSPoc2Service {
|
||||
scmAnnotations.add(toScmAnnotations(laboratoryEntry.get()));
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (laboratoryEntry.isPresent()) {
|
||||
sb.append(laboratoryEntry.get().getValue());
|
||||
}
|
||||
laboratoryEntry.ifPresent(entityLogEntry -> sb.append(entityLogEntry.getValue()));
|
||||
if (countryWithSmallestDistance != null) {
|
||||
sb.append(", ").append(countryWithSmallestDistance.getValue());
|
||||
scmAnnotations.add(toScmAnnotations(countryWithSmallestDistance));
|
||||
@ -424,25 +425,25 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private SCMComponent getConvertedDates(RedactionLog redactionLog, String type) {
|
||||
private SCMComponent getConvertedDates(EntityLog entityLog, String type) {
|
||||
|
||||
List<RedactionLogEntry> redactionLogEntries = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals(type)).collect(Collectors.toList());
|
||||
List<EntityLogEntry> entityLogEntries = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals(type)).toList();
|
||||
|
||||
String value = redactionLogEntries.stream().map(RedactionLogEntry::getValue).map(this::convertDate).collect(Collectors.joining(", "));
|
||||
String value = entityLogEntries.stream().map(EntityLogEntry::getValue).map(this::convertDate).collect(Collectors.joining(", "));
|
||||
|
||||
return SCMComponent.builder()
|
||||
.originalValue(value)
|
||||
.scmAnnotations(redactionLogEntries.stream().map(this::toScmAnnotations).collect(Collectors.toList()))
|
||||
.scmAnnotations(entityLogEntries.stream().map(this::toScmAnnotations).collect(Collectors.toList()))
|
||||
.transformation(String.format("Convert values of type '%s' to dd/MM/yyyy joined with ', '", type))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
private SCMComponent ifPresentAddOrElse(RedactionLog redactionLog, String type, String presentValue, String elseValue) {
|
||||
private SCMComponent ifPresentAddOrElse(EntityLog entityLog, String type, String presentValue, String elseValue) {
|
||||
|
||||
String transformation = String.format("If type %s is present than '%s' else '%s'", type, presentValue, elseValue);
|
||||
|
||||
var firstEntryOptional = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals(type)).findFirst();
|
||||
var firstEntryOptional = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals(type)).findFirst();
|
||||
|
||||
if (firstEntryOptional.isPresent()) {
|
||||
|
||||
@ -454,13 +455,13 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private SCMComponent getJoinedUniqueValues(RedactionLog redactionLog, String type, String seperator) {
|
||||
private SCMComponent getJoinedUniqueValues(EntityLog entityLog, String type) {
|
||||
|
||||
String transformation = String.format("Combine unique values of '%s' with seperator '%s'", type, seperator);
|
||||
String transformation = String.format("Combine unique values of '%s' with seperator '%s'", type, ", ");
|
||||
|
||||
var uniqueEntries = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals(type)).collect(Collectors.toSet());
|
||||
var uniqueEntries = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals(type)).collect(Collectors.toSet());
|
||||
|
||||
String value = uniqueEntries.stream().map(RedactionLogEntry::getValue).collect(Collectors.toSet()).stream().collect(Collectors.joining(seperator)).trim();
|
||||
String value = String.join(", ", uniqueEntries.stream().map(EntityLogEntry::getValue).collect(Collectors.toSet())).trim();
|
||||
|
||||
return SCMComponent.builder()
|
||||
.originalValue(value)
|
||||
@ -470,12 +471,12 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private SCMComponent getTestGuideline1(RedactionLog redactionLog) {
|
||||
private SCMComponent getTestGuideline1(EntityLog entityLog) {
|
||||
|
||||
String transformation = "If 'oecd_guideline_number' and 'oecd_guideline_year' are present than mapped by provided mapping table else value of 'oecd_guideline' if present or else ''";
|
||||
|
||||
var guidelineNumber = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("oecd_guideline_number")).findFirst();
|
||||
var guidelineYear = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("oecd_guideline_year")).findFirst();
|
||||
var guidelineNumber = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals("oecd_guideline_number")).findFirst();
|
||||
var guidelineYear = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals("oecd_guideline_year")).findFirst();
|
||||
|
||||
if (guidelineNumber.isPresent() && guidelineYear.isPresent()) {
|
||||
var guidelinePair = Pair.of(guidelineNumber.get().getValue(), guidelineYear.get().getValue());
|
||||
@ -489,7 +490,7 @@ public class RSSPoc2Service {
|
||||
}
|
||||
}
|
||||
|
||||
var guideline = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("oecd_guideline")).findFirst();
|
||||
var guideline = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals("oecd_guideline")).findFirst();
|
||||
|
||||
if (guideline.isPresent()) {
|
||||
return SCMComponent.builder()
|
||||
@ -503,15 +504,15 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private SCMComponent getTestGuideline2(RedactionLog redactionLog) {
|
||||
private SCMComponent getTestGuideline2(EntityLog entityLog) {
|
||||
|
||||
String transformation = "Combine values of 'epa_guideline' and 'ec_guideline' with seperator ', '";
|
||||
|
||||
List<RedactionLogEntry> guidelines = new ArrayList<>();
|
||||
guidelines.addAll(redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("epa_guideline")).collect(Collectors.toList()));
|
||||
guidelines.addAll(redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("ec_guideline")).collect(Collectors.toList()));
|
||||
List<EntityLogEntry> guidelines = new ArrayList<>();
|
||||
guidelines.addAll(entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals("epa_guideline")).toList());
|
||||
guidelines.addAll(entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals("ec_guideline")).toList());
|
||||
|
||||
String value = guidelines.stream().map(RedactionLogEntry::getValue).collect(Collectors.joining(", "));
|
||||
String value = guidelines.stream().map(EntityLogEntry::getValue).collect(Collectors.joining(", "));
|
||||
|
||||
if (!value.isEmpty()) {
|
||||
return SCMComponent.builder()
|
||||
@ -531,14 +532,14 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private Map<String, SCMComponent> getAsBlockPerAnnotation(RedactionLog redactionLog, String type, String componentKey) {
|
||||
private Map<String, SCMComponent> getAsBlockPerAnnotation(EntityLog entityLog, String type, String componentKey) {
|
||||
|
||||
String transformation = String.format("Values of type '%s'", type);
|
||||
|
||||
List<SCMComponent> scmComponents = new ArrayList<>();
|
||||
var typeStringsEntries = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals(type)).collect(Collectors.toList());
|
||||
var typeStringsEntries = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals(type)).toList();
|
||||
|
||||
for (RedactionLogEntry typeStringEntry : typeStringsEntries) {
|
||||
for (EntityLogEntry typeStringEntry : typeStringsEntries) {
|
||||
|
||||
scmComponents.add(SCMComponent.builder()
|
||||
.originalValue(typeStringEntry.getValue().replaceAll("\\n", "").trim())
|
||||
@ -551,24 +552,24 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private SCMComponent getLongestCombinedSectionBlockOrElse(RedactionLog redactionLog, String type, String elseValue) {
|
||||
private SCMComponent getLongestCombinedSectionBlockOrElse(EntityLog entityLog) {
|
||||
|
||||
String transformation = String.format("Longest combined section value of type '%s' if present or else '%s'", type, elseValue);
|
||||
String transformation = String.format("Longest combined section value of type '%s' if present or else '%s'", "necropsy_findings", "");
|
||||
|
||||
Map<Integer, List<RedactionLogEntry>> entriesPerSection = new HashMap<>();
|
||||
redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals(type)).forEach(e -> {
|
||||
entriesPerSection.computeIfAbsent(e.getSectionNumber(), (x) -> new ArrayList<>()).add(e);
|
||||
Map<Integer, List<EntityLogEntry>> entriesPerSection = new HashMap<>();
|
||||
entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals("necropsy_findings")).forEach(e -> {
|
||||
entriesPerSection.computeIfAbsent(e.getContainingNodeId().get(0), (x) -> new ArrayList<>()).add(e);
|
||||
});
|
||||
|
||||
if (entriesPerSection.isEmpty()) {
|
||||
return SCMComponent.builder().originalValue(elseValue).transformation(transformation).build();
|
||||
return SCMComponent.builder().originalValue("").transformation(transformation).build();
|
||||
}
|
||||
|
||||
int sectionNrOfLongestValue = 0;
|
||||
String longestValue = "";
|
||||
for (Map.Entry<Integer, List<RedactionLogEntry>> sectionEntry : entriesPerSection.entrySet()) {
|
||||
for (Map.Entry<Integer, List<EntityLogEntry>> sectionEntry : entriesPerSection.entrySet()) {
|
||||
|
||||
String value = sectionEntry.getValue().stream().map(RedactionLogEntry::getValue).collect(Collectors.joining(" ")).trim();
|
||||
String value = sectionEntry.getValue().stream().map(EntityLogEntry::getValue).collect(Collectors.joining(" ")).trim();
|
||||
if (value.length() > longestValue.length()) {
|
||||
longestValue = value;
|
||||
sectionNrOfLongestValue = sectionEntry.getKey();
|
||||
@ -583,13 +584,13 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private SCMComponent getAsOneBlock(RedactionLog redactionLog, String type) {
|
||||
private SCMComponent getAsOneBlock(EntityLog entityLog, String type) {
|
||||
|
||||
String transformation = String.format("Combine value of '%s' to one block", type);
|
||||
|
||||
var entries = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals(type)).collect(Collectors.toList());
|
||||
var entries = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals(type)).toList();
|
||||
|
||||
String value = entries.stream().map(RedactionLogEntry::getValue).collect(Collectors.joining(" "));
|
||||
String value = entries.stream().map(EntityLogEntry::getValue).collect(Collectors.joining(" "));
|
||||
|
||||
return SCMComponent.builder()
|
||||
.originalValue(value)
|
||||
@ -599,13 +600,13 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private SCMComponent getJoinedValues(RedactionLog redactionLog, String type, String seperator) {
|
||||
private SCMComponent getJoinedValues(EntityLog entityLog, String type) {
|
||||
|
||||
String transformation = String.format("Combine values of '%s' with seperator '%s'", type, seperator);
|
||||
String transformation = String.format("Combine values of '%s' with separator '%s'", type, " ");
|
||||
|
||||
var entries = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals(type)).collect(Collectors.toList());
|
||||
var entries = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals(type)).toList();
|
||||
|
||||
String value = entries.stream().map(RedactionLogEntry::getValue).collect(Collectors.joining(seperator)).trim();
|
||||
String value = entries.stream().map(EntityLogEntry::getValue).collect(Collectors.joining(" ")).trim();
|
||||
|
||||
return SCMComponent.builder()
|
||||
.originalValue(value)
|
||||
@ -615,20 +616,20 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private SCMComponent getSex(RedactionLog redactionLog) {
|
||||
private SCMComponent getSex(EntityLog entityLog) {
|
||||
|
||||
String transformation = "Combine unique values of 'sex', map plural values to singular";
|
||||
|
||||
var entries = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("sex")).collect(Collectors.toSet());
|
||||
var entries = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals("sex")).collect(Collectors.toSet());
|
||||
|
||||
var value = entries.stream().map(RedactionLogEntry::getValue).map(String::toLowerCase).map(s -> {
|
||||
var value = String.join(", ", entries.stream().map(EntityLogEntry::getValue).map(String::toLowerCase).map(s -> {
|
||||
if (s.equals("females")) {
|
||||
return "female";
|
||||
} else if (s.equals("males")) {
|
||||
return "male";
|
||||
}
|
||||
return s;
|
||||
}).collect(Collectors.toSet()).stream().collect(Collectors.joining(", ")).trim();
|
||||
}).collect(Collectors.toSet())).trim();
|
||||
|
||||
return SCMComponent.builder()
|
||||
.originalValue(value)
|
||||
@ -638,11 +639,11 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private SCMComponent getNumberOfAnimals(RedactionLog redactionLog) {
|
||||
private SCMComponent getNumberOfAnimals(EntityLog entityLog) {
|
||||
|
||||
String transformation = "Return value of 'number_of_animals' if present else return sum of unique 'animal_number' or else '' ";
|
||||
|
||||
var numberOfAnimals = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("number_of_animals")).findFirst();
|
||||
var numberOfAnimals = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals("number_of_animals")).findFirst();
|
||||
|
||||
if (numberOfAnimals.isPresent()) {
|
||||
return SCMComponent.builder()
|
||||
@ -652,13 +653,13 @@ public class RSSPoc2Service {
|
||||
.build();
|
||||
}
|
||||
|
||||
var uniqueAnimalNumbers = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("animal_number")).collect(Collectors.toSet());
|
||||
var uniqueAnimalNumbers = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals("animal_number")).collect(Collectors.toSet());
|
||||
|
||||
if (uniqueAnimalNumbers.isEmpty()) {
|
||||
return getEmptyComponent(transformation);
|
||||
}
|
||||
|
||||
int size = uniqueAnimalNumbers.stream().map(a -> a.getValue()).collect(Collectors.toSet()).size();
|
||||
int size = uniqueAnimalNumbers.stream().map(EntityLogEntry::getValue).collect(Collectors.toSet()).size();
|
||||
|
||||
return SCMComponent.builder()
|
||||
.originalValue(String.valueOf(size))
|
||||
@ -668,31 +669,29 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private Map<String, SCMComponent> getDoseMortality(RedactionLog redactionLog, String componentKey) {
|
||||
private Map<String, SCMComponent> getDoseMortality(EntityLog entityLog) {
|
||||
|
||||
String transformation = "Combine values of 'dose_mortality' and 'dose_mortality_dose' of same row with ', ' ";
|
||||
|
||||
var doseMortalityEntries = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("dose_mortality")).collect(Collectors.toList());
|
||||
var doseMortalityDoseEntries = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("dose_mortality_dose")).collect(Collectors.toList());
|
||||
var doseMortalityEntries = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals("dose_mortality")).toList();
|
||||
var doseMortalityDoseEntries = entityLog.getEntityLogEntry().stream().filter(r -> r.getType().equals("dose_mortality_dose")).toList();
|
||||
|
||||
List<SCMComponent> result = new ArrayList<>();
|
||||
for (var mortality : doseMortalityEntries) {
|
||||
|
||||
RedactionLogEntry doseWithSmallestDistance = null;
|
||||
EntityLogEntry doseWithSmallestDistance = null;
|
||||
for (var dose : doseMortalityDoseEntries) {
|
||||
if (Math.round(mortality.getPositions().get(0).getTopLeft().getY()) == Math.round(dose.getPositions().get(0).getTopLeft().getY())) {
|
||||
if (Math.round(mortality.getPositions().get(0).y()) == Math.round(dose.getPositions().get(0).y())) {
|
||||
doseWithSmallestDistance = dose;
|
||||
break;
|
||||
}
|
||||
if (doseWithSmallestDistance == null) {
|
||||
doseWithSmallestDistance = dose;
|
||||
} else if (Math.abs(Math.round(mortality.getPositions().get(0).getTopLeft().getY()) - Math.round(dose.getPositions()
|
||||
} else if (Math.abs(Math.round(mortality.getPositions().get(0).y()) - Math.round(dose.getPositions()
|
||||
.get(0)
|
||||
.getTopLeft()
|
||||
.getY())) < Math.abs(Math.round(mortality.getPositions().get(0).getTopLeft().getY()) - Math.round(doseWithSmallestDistance.getPositions()
|
||||
.y())) < Math.abs(Math.round(mortality.getPositions().get(0).y()) - Math.round(doseWithSmallestDistance.getPositions()
|
||||
.get(0)
|
||||
.getTopLeft()
|
||||
.getY()))) {
|
||||
.y()))) {
|
||||
doseWithSmallestDistance = dose;
|
||||
}
|
||||
}
|
||||
@ -712,7 +711,7 @@ public class RSSPoc2Service {
|
||||
|
||||
}
|
||||
|
||||
return componentListToMap(result, componentKey, transformation);
|
||||
return componentListToMap(result, RSSPoc2Service.DOSE_MORTALITY, transformation);
|
||||
}
|
||||
|
||||
|
||||
@ -735,17 +734,11 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
switch (oecd) {
|
||||
|
||||
case "439":
|
||||
case "406":
|
||||
case "428":
|
||||
case "438":
|
||||
case "474":
|
||||
case "487":
|
||||
case "439", "406", "428", "438", "474", "487" -> {
|
||||
resultMap.put(STUDY_DESIGN, components.get(STUDY_DESIGN));
|
||||
resultMap.put(RESULTS_AND_CONCLUSIONS, components.get(RESULTS_AND_CONCLUSIONS));
|
||||
break;
|
||||
case "425":
|
||||
}
|
||||
case "425" -> {
|
||||
resultMap.put(SPECIES, components.get(SPECIES));
|
||||
resultMap.put(STRAIN, components.get(STRAIN));
|
||||
resultMap.put(DOSAGES, components.get(DOSAGES));
|
||||
@ -758,8 +751,8 @@ public class RSSPoc2Service {
|
||||
resultMap.put(CONCLUSION_MINIMUM_CONFIDENCE, components.get(CONCLUSION_MINIMUM_CONFIDENCE));
|
||||
resultMap.put(CONCLUSION_MAXIMUM_CONFIDENCE, components.get(CONCLUSION_MAXIMUM_CONFIDENCE));
|
||||
resultMap.put(STUDY_CONCLUSION, components.get(STUDY_CONCLUSION));
|
||||
break;
|
||||
case "402":
|
||||
}
|
||||
case "402" -> {
|
||||
resultMap.put(SPECIES, components.get(SPECIES));
|
||||
resultMap.put(STRAIN, components.get(STRAIN));
|
||||
resultMap.put(DOSES_MG_PER_KG_BW, components.get(DOSES_MG_PER_KG_BW));
|
||||
@ -772,9 +765,8 @@ public class RSSPoc2Service {
|
||||
resultMap.put(CONCLUSION_MINIMUM_CONFIDENCE, components.get(CONCLUSION_MINIMUM_CONFIDENCE));
|
||||
resultMap.put(CONCLUSION_MAXIMUM_CONFIDENCE, components.get(CONCLUSION_MAXIMUM_CONFIDENCE));
|
||||
resultMap.put(STUDY_CONCLUSION, components.get(STUDY_CONCLUSION));
|
||||
break;
|
||||
case "403":
|
||||
case "436":
|
||||
}
|
||||
case "403", "436" -> {
|
||||
resultMap.put(SPECIES, components.get(SPECIES));
|
||||
resultMap.put(STRAIN, components.get(STRAIN));
|
||||
resultMap.put(CONDUCTED_WITHIN_4_HOURS_OF_EXPOSURE, components.get(CONDUCTED_WITHIN_4_HOURS_OF_EXPOSURE));
|
||||
@ -787,8 +779,8 @@ public class RSSPoc2Service {
|
||||
resultMap.put(CONCLUSION_MINIMUM_CONFIDENCE, components.get(CONCLUSION_MINIMUM_CONFIDENCE));
|
||||
resultMap.put(CONCLUSION_MAXIMUM_CONFIDENCE, components.get(CONCLUSION_MAXIMUM_CONFIDENCE));
|
||||
resultMap.put(STUDY_CONCLUSION, components.get(STUDY_CONCLUSION));
|
||||
break;
|
||||
case "405":
|
||||
}
|
||||
case "405" -> {
|
||||
resultMap.put(SPECIES, components.get(SPECIES));
|
||||
resultMap.put(STRAIN, components.get(STRAIN));
|
||||
resultMap.put(SEX, components.get(SEX));
|
||||
@ -797,8 +789,8 @@ public class RSSPoc2Service {
|
||||
resultMap.put(DETAILING_OF_REPORTED_CHANGES, components.get(DETAILING_OF_REPORTED_CHANGES));
|
||||
resultMap.putAll(getKeyContains(components, DEVIATION_FROM_THE_GUIDELINE));
|
||||
resultMap.put(STUDY_CONCLUSION, components.get(STUDY_CONCLUSION));
|
||||
break;
|
||||
case "429":
|
||||
}
|
||||
case "429" -> {
|
||||
resultMap.put(SPECIES, components.get(SPECIES));
|
||||
resultMap.put(STRAIN, components.get(STRAIN));
|
||||
resultMap.put(WAS_THE_DEFINITIVE_STUDY_CONDUCTED_WITH_POSITIVE_CONTROL, components.get(WAS_THE_DEFINITIVE_STUDY_CONDUCTED_WITH_POSITIVE_CONTROL));
|
||||
@ -811,20 +803,20 @@ public class RSSPoc2Service {
|
||||
resultMap.put(TEST_RESULTS, components.get(TEST_RESULTS));
|
||||
resultMap.putAll(getKeyContains(components, DEVIATION_FROM_THE_GUIDELINE));
|
||||
resultMap.put(STUDY_CONCLUSION, components.get(STUDY_CONCLUSION));
|
||||
break;
|
||||
case "404":
|
||||
}
|
||||
case "404" -> {
|
||||
resultMap.put(SPECIES, components.get(SPECIES));
|
||||
resultMap.put(STRAIN, components.get(STRAIN));
|
||||
resultMap.put(STUDY_DESIGN, components.get(STUDY_DESIGN));
|
||||
resultMap.put(DETAILING_OF_REPORTED_CHANGES, components.get(DETAILING_OF_REPORTED_CHANGES));
|
||||
resultMap.putAll(getKeyContains(components, DEVIATION_FROM_THE_GUIDELINE));
|
||||
resultMap.put(STUDY_CONCLUSION, components.get(STUDY_CONCLUSION));
|
||||
break;
|
||||
case "471":
|
||||
}
|
||||
case "471" -> {
|
||||
resultMap.put(STRAIN, components.get(STRAIN));
|
||||
resultMap.putAll(getKeyContains(components, DEVIATION_FROM_THE_GUIDELINE));
|
||||
resultMap.put(STUDY_CONCLUSION, components.get(STUDY_CONCLUSION));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
@ -850,9 +842,9 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private ScmAnnotation toScmAnnotations(RedactionLogEntry entry) {
|
||||
private ScmAnnotation toScmAnnotations(EntityLogEntry entry) {
|
||||
|
||||
Set<Integer> pages = entry.getPositions().stream().map(Rectangle::getPage).collect(Collectors.toSet());
|
||||
Set<Integer> pages = entry.getPositions().stream().map(Position::getPageNumber).collect(Collectors.toSet());
|
||||
return ScmAnnotation.builder().type(entry.getType()).reason(entry.getReason()).pages(pages).ruleIdentifier(entry.getMatchedRule()).build();
|
||||
}
|
||||
|
||||
@ -879,12 +871,12 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private Map<String, SCMComponent> getKeyContains(Map<String, SCMComponent> components, String compontentName) {
|
||||
private Map<String, SCMComponent> getKeyContains(Map<String, SCMComponent> components, String componentName) {
|
||||
|
||||
Map<String, SCMComponent> resultMap = new LinkedHashMap<>();
|
||||
|
||||
for (Map.Entry<String, SCMComponent> entry : components.entrySet()) {
|
||||
if (entry.getKey().contains(compontentName)) {
|
||||
if (entry.getKey().contains(componentName)) {
|
||||
resultMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ public class ReportGenerationService {
|
||||
|
||||
private final ReportStorageService reportStorageService;
|
||||
private final WordReportGenerationService wordReportGenerationService;
|
||||
private final RedactionLogConverterService redactionLogConverterService;
|
||||
private final EntityLogConverterService entityLogConverterService;
|
||||
private final FileStatusClient fileStatusClient;
|
||||
private final DossierClient dossierClient;
|
||||
private final ReportTemplateClient reportTemplateClient;
|
||||
@ -78,7 +78,7 @@ public class ReportGenerationService {
|
||||
var fileStatus = fileStatusClient.getFileStatus(dossierId, fileId);
|
||||
generatePlaceholderService.resolveFileAttributeValues(fileStatus, placeholderModel);
|
||||
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.getReportEntries(dossierId, fileId, fileStatus.isExcluded(), dossier);
|
||||
List<ReportRedactionEntry> reportEntries = entityLogConverterService.getReportEntries(dossierId, fileId, fileStatus.isExcluded());
|
||||
|
||||
generateMultiFileExcelReports(reportTemplates.multiFileWorkbookReportTemplates, placeholderModel, fileStatus, isLastFile, dossierName, reportEntries);
|
||||
|
||||
|
||||
@ -115,7 +115,7 @@ public class WordReportGenerationService {
|
||||
removePlaceholdersRow(table);
|
||||
}
|
||||
|
||||
log.info("Report Generation took: {} for file with id {}, pageCount: {}, redactionLogEntryCount: {}, reportName: {}, className: {}",
|
||||
log.info("Report Generation took: {} for file with id {}, pageCount: {}, entityLogEntryCount: {}, reportName: {}, className: {}",
|
||||
System.currentTimeMillis() - start,
|
||||
fileModel.getId(),
|
||||
fileModel.getNumberOfPages(),
|
||||
@ -243,7 +243,7 @@ public class WordReportGenerationService {
|
||||
replacePlaceholderInParagraphAndSplit(doc.getParagraphs(), placeHolderValueMap, doc);
|
||||
for (XWPFTable tbl : doc.getTables()) {
|
||||
if (tableToSkip == tbl) {
|
||||
// already processed for redactionLog Entries
|
||||
// already processed for entityLog Entries
|
||||
continue;
|
||||
}
|
||||
for (XWPFTableRow row : tbl.getRows()) {
|
||||
@ -487,7 +487,7 @@ public class WordReportGenerationService {
|
||||
}
|
||||
if (placeholder.equals(REDACTION_VALUE_PLACEHOLDER)) {
|
||||
foundPlaceholders.add(REDACTION_VALUE_PLACEHOLDER);
|
||||
return input -> input.getEntry().getValue() != null ? input.getEntry().getValue().replaceAll("\n", " ").replaceAll(" ", " ") : input.getEntry().getEntityDisplayName();
|
||||
return input -> input.getEntry().getValue() != null ? input.getEntry().getValue().replaceAll("\n", " ").replaceAll(" {2}", " ") : input.getEntry().getEntityDisplayName();
|
||||
}
|
||||
if (placeholder.equals(REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER)) {
|
||||
foundPlaceholders.add(REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER);
|
||||
|
||||
@ -8,12 +8,14 @@ import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
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.redaction.report.v1.api.model.StoredFileInformation;
|
||||
import com.iqser.red.storage.commons.service.StorageService;
|
||||
@ -82,4 +84,14 @@ public class ReportStorageService {
|
||||
return Files.newInputStream(Paths.get(destFile.getPath()), StandardOpenOption.DELETE_ON_CLOSE);
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
return entityLog;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -31,7 +31,6 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mockito;
|
||||
@ -49,11 +48,11 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
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.analysislog.entitylog.EntityLogLegalBasis;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.Dossier;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileModel;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.Type;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLog;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLogLegalBasis;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DictionaryClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierAttributesClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierAttributesConfigClient;
|
||||
@ -64,9 +63,9 @@ import com.iqser.red.service.redaction.report.v1.server.configuration.MessagingC
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.ImagePlaceholder;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.PlaceholderModel;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.ReportRedactionEntry;
|
||||
import com.iqser.red.service.redaction.report.v1.server.service.EntityLogConverterService;
|
||||
import com.iqser.red.service.redaction.report.v1.server.service.ExcelReportGenerationService;
|
||||
import com.iqser.red.service.redaction.report.v1.server.service.GeneratePlaceholderService;
|
||||
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.storage.commons.StorageAutoConfiguration;
|
||||
@ -112,7 +111,7 @@ public class RedactionReportIntegrationTest {
|
||||
private MessagingConfiguration messagingConfiguration;
|
||||
|
||||
@Autowired
|
||||
private RedactionLogConverterService redactionLogConverterService;
|
||||
private EntityLogConverterService entityLogConverterService;
|
||||
|
||||
@MockBean
|
||||
private DossierAttributesConfigClient dossierAttributesConfigClient;
|
||||
@ -153,10 +152,10 @@ public class RedactionReportIntegrationTest {
|
||||
Dossier dossier = prepareDossier();
|
||||
FileModel fileModel = FileModel.builder().filename("filename").build();
|
||||
|
||||
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<>() {
|
||||
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
|
||||
List<EntityLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
|
||||
});
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier);
|
||||
List<ReportRedactionEntry> reportEntries = entityLogConverterService.convertAndSort(entityLog, legalBasisMapping, new HashMap<>());
|
||||
|
||||
var wordTemplateResource = new ClassPathResource("templates/Justification Appendix A1.docx");
|
||||
var imageResource = new ClassPathResource("files/exampleImage.jpg");
|
||||
@ -190,10 +189,10 @@ public class RedactionReportIntegrationTest {
|
||||
Dossier dossier = prepareDossier();
|
||||
FileModel fileModel = FileModel.builder().filename("filename").build();
|
||||
|
||||
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<>() {
|
||||
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
|
||||
List<EntityLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
|
||||
});
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier);
|
||||
List<ReportRedactionEntry> reportEntries = entityLogConverterService.convertAndSort(entityLog, legalBasisMapping, new HashMap<>());
|
||||
|
||||
var wordTemplateResource = new ClassPathResource("templates/Justification Appendix A2.docx");
|
||||
var imageResource = new ClassPathResource("files/exampleImage.jpg");
|
||||
@ -228,9 +227,9 @@ public class RedactionReportIntegrationTest {
|
||||
|
||||
List<XWPFParagraph> paragraphs = doc.getParagraphs();
|
||||
|
||||
assertThat(paragraphs.size()).isEqualTo(19);
|
||||
assertThat(paragraphs.size()).isEqualTo(11);
|
||||
|
||||
List<String> expectedContent = getExpectedContent("expected/iuclid.txt");
|
||||
List<String> expectedContent = getExpectedContent();
|
||||
|
||||
List<String> contentOfParagraphs = getContentOfParagraphs(paragraphs);
|
||||
|
||||
@ -242,12 +241,11 @@ public class RedactionReportIntegrationTest {
|
||||
}
|
||||
|
||||
|
||||
private List<String> getExpectedContent(String path) throws IOException {
|
||||
private List<String> getExpectedContent() throws IOException {
|
||||
|
||||
ClassPathResource classPathResource = new ClassPathResource(path);
|
||||
ClassPathResource classPathResource = new ClassPathResource("expected/iuclid.txt");
|
||||
InputStream inputStream = classPathResource.getInputStream();
|
||||
List<String> expectedContent = IOUtils.readLines(inputStream, "UTF-8");
|
||||
return expectedContent;
|
||||
return IOUtils.readLines(inputStream, "UTF-8");
|
||||
}
|
||||
|
||||
|
||||
@ -257,7 +255,7 @@ public class RedactionReportIntegrationTest {
|
||||
|
||||
for (XWPFParagraph paragraph : paragraphs) {
|
||||
for (XWPFRun run : paragraph.getRuns()) {
|
||||
res.add(run.text());
|
||||
res.add(run.text().trim());
|
||||
}
|
||||
}
|
||||
return res;
|
||||
@ -269,10 +267,10 @@ public class RedactionReportIntegrationTest {
|
||||
Dossier dossier = prepareDossier();
|
||||
FileModel fileStatus = FileModel.builder().filename("filename").build();
|
||||
|
||||
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<>() {
|
||||
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
|
||||
List<EntityLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
|
||||
});
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier);
|
||||
List<ReportRedactionEntry> reportEntries = entityLogConverterService.convertAndSort(entityLog, legalBasisMapping, new HashMap<>());
|
||||
|
||||
ClassPathResource templateResource = new ClassPathResource("templates/IUCLID_Template.docx");
|
||||
XWPFDocument doc = new XWPFDocument(templateResource.getInputStream());
|
||||
@ -282,9 +280,8 @@ public class RedactionReportIntegrationTest {
|
||||
wordReportGenerationService.generateWordReport(reportEntries, placeholders, "test", doc, fileStatus, dossier, true);
|
||||
|
||||
byte[] report = wordReportGenerationService.toByteArray(doc);
|
||||
XWPFDocument newDoc = new XWPFDocument(new ByteArrayInputStream(report));
|
||||
|
||||
return newDoc;
|
||||
return new XWPFDocument(new ByteArrayInputStream(report));
|
||||
}
|
||||
|
||||
|
||||
@ -295,10 +292,10 @@ public class RedactionReportIntegrationTest {
|
||||
Dossier dossier = prepareDossier();
|
||||
FileModel fileStatus = FileModel.builder().filename("filename").build();
|
||||
|
||||
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<>() {
|
||||
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
|
||||
List<EntityLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
|
||||
});
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier);
|
||||
List<ReportRedactionEntry> reportEntries = entityLogConverterService.convertAndSort(entityLog, legalBasisMapping, new HashMap<>());
|
||||
|
||||
ClassPathResource templateResource = new ClassPathResource("templates/Seeds - New Justification Form.docx");
|
||||
XWPFDocument doc = new XWPFDocument(templateResource.getInputStream());
|
||||
@ -321,17 +318,16 @@ public class RedactionReportIntegrationTest {
|
||||
Dossier dossier = prepareDossier();
|
||||
|
||||
FileModel fileStatus = FileModel.builder().filename("filename").build();
|
||||
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<>() {
|
||||
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
|
||||
List<EntityLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
|
||||
});
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier);
|
||||
List<ReportRedactionEntry> reportEntries = entityLogConverterService.convertAndSort(entityLog, legalBasisMapping, new HashMap<>());
|
||||
|
||||
FileModel fileModelSecondFile = FileModel.builder().filename("secondFile").build();
|
||||
RedactionLog redactionLogSecondFile = objectMapper.readValue(new ClassPathResource("files/excelReportRedactionLog.json").getInputStream(), RedactionLog.class);
|
||||
List<ReportRedactionEntry> reportEntriesSecondFile = redactionLogConverterService.convertAndSort(redactionLogSecondFile,
|
||||
EntityLog entityLogSecondFile = objectMapper.readValue(new ClassPathResource("files/entityLogWithManualRedactions.json").getInputStream(), EntityLog.class);
|
||||
List<ReportRedactionEntry> reportEntriesSecondFile = entityLogConverterService.convertAndSort(entityLogSecondFile,
|
||||
legalBasisMapping,
|
||||
new HashMap<>(),
|
||||
dossier);
|
||||
new HashMap<>());
|
||||
|
||||
ClassPathResource templateResource = new ClassPathResource("templates/Seeds-NewJustificationForm.docx");
|
||||
XWPFDocument doc = new XWPFDocument(templateResource.getInputStream());
|
||||
@ -355,10 +351,10 @@ public class RedactionReportIntegrationTest {
|
||||
Dossier dossier = prepareDossier();
|
||||
FileModel fileModel = FileModel.builder().filename("filename").build();
|
||||
|
||||
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<>() {
|
||||
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
|
||||
List<EntityLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
|
||||
});
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>(), dossier);
|
||||
List<ReportRedactionEntry> reportEntries = entityLogConverterService.convertAndSort(entityLog, legalBasisMapping, new HashMap<>());
|
||||
|
||||
var wordTemplateResource = new ClassPathResource("templates/6464 appendix_b EFSA dRAR justification.docx");
|
||||
var imageResource = new ClassPathResource("files/exampleImage.jpg");
|
||||
@ -392,11 +388,11 @@ public class RedactionReportIntegrationTest {
|
||||
Dossier dossier = prepareDossier();
|
||||
FileModel fileModel = FileModel.builder().filename("filename").dossierId(dossier.getDossierId()).fileAttributes(Map.of("TestAttribute", "Lorem Ipsum")).build();
|
||||
|
||||
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLogWithManualRedactions.json").getInputStream(), RedactionLog.class);
|
||||
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
|
||||
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLogWithManualRedactions.json").getInputStream(), EntityLog.class);
|
||||
List<EntityLogLegalBasis> 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, dossier);
|
||||
Map<String, String> mapOfEntityDisplayName = createEntityDisplayNames(entityLog);
|
||||
List<ReportRedactionEntry> reportEntries = entityLogConverterService.convertAndSort(entityLog, legalBasisMapping, mapOfEntityDisplayName);
|
||||
|
||||
ClassPathResource templateResource = new ClassPathResource("templates/Excel Report.xlsx");
|
||||
|
||||
@ -421,11 +417,11 @@ public class RedactionReportIntegrationTest {
|
||||
public void testExcelTemplateReportGenerationMultiFile() {
|
||||
|
||||
Dossier dossier = prepareDossier();
|
||||
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<>() {
|
||||
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
|
||||
List<EntityLogLegalBasis> 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, dossier);
|
||||
Map<String, String> mapOfEntityDisplayName = createEntityDisplayNames(entityLog);
|
||||
List<ReportRedactionEntry> reportEntries = entityLogConverterService.convertAndSort(entityLog, legalBasisMapping, mapOfEntityDisplayName);
|
||||
|
||||
FileModel fileModel = FileModel.builder().filename("filename").build();
|
||||
|
||||
@ -439,11 +435,10 @@ public class RedactionReportIntegrationTest {
|
||||
writeWorkbook.createSheet("Sheet1");
|
||||
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,
|
||||
EntityLog entityLogSecondFile = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
|
||||
List<ReportRedactionEntry> reportEntriesSecondFile = entityLogConverterService.convertAndSort(entityLogSecondFile,
|
||||
legalBasisMapping,
|
||||
mapOfEntityDisplayName,
|
||||
dossier);
|
||||
mapOfEntityDisplayName);
|
||||
FileModel fileModelSecondFile = FileModel.builder().filename("secondFile").build();
|
||||
excelTemplateReportGenerationService.generateExcelReport(reportEntriesSecondFile,
|
||||
placeholders,
|
||||
@ -466,11 +461,11 @@ public class RedactionReportIntegrationTest {
|
||||
public void testExcelPlaceholders() {
|
||||
|
||||
Dossier dossier = prepareDossier();
|
||||
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<>() {
|
||||
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
|
||||
List<EntityLogLegalBasis> 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, dossier);
|
||||
Map<String, String> mapOfEntityDisplayName = createEntityDisplayNames(entityLog);
|
||||
List<ReportRedactionEntry> reportEntries = entityLogConverterService.convertAndSort(entityLog, legalBasisMapping, mapOfEntityDisplayName);
|
||||
var imageResource = new ClassPathResource("files/exampleImage.jpg");
|
||||
|
||||
FileModel fileModel = FileModel.builder().filename("filename").build();
|
||||
@ -494,7 +489,7 @@ public class RedactionReportIntegrationTest {
|
||||
}
|
||||
|
||||
|
||||
private Map<String, String> createEntityDisplayNames(RedactionLog redactionLog) {
|
||||
private Map<String, String> createEntityDisplayNames(EntityLog entityLog) {
|
||||
|
||||
Type t1 = new Type();
|
||||
t1.setLabel("Type 1");
|
||||
@ -510,7 +505,7 @@ public class RedactionReportIntegrationTest {
|
||||
Mockito.when(dictionaryClient.getAllTypesForDossierTemplate(Mockito.any(), Mockito.anyBoolean())).thenReturn(ednList);
|
||||
|
||||
Map<String, String> entityDisplayNames = new HashMap<>();
|
||||
for (var entry : redactionLog.getRedactionLogEntry()) {
|
||||
for (var entry : entityLog.getEntityLogEntry()) {
|
||||
if (entry.getType().equals("manual")) {
|
||||
entityDisplayNames.put(entry.getType(), "Manual");
|
||||
} else {
|
||||
|
||||
@ -35,6 +35,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
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.DossierAttributeConfig;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.ReportTemplate;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.Dossier;
|
||||
@ -43,7 +44,7 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemp
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileAttributeConfig;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileAttributeType;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileModel;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLog;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.ReportRequestMessage;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.StoredFileInformation;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DictionaryClient;
|
||||
@ -52,10 +53,11 @@ import com.iqser.red.service.redaction.report.v1.server.client.DossierAttributes
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.FileAttributesConfigClient;
|
||||
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.configuration.MessagingConfiguration;
|
||||
import com.iqser.red.service.redaction.report.v1.server.service.ReportGenerationService;
|
||||
import com.iqser.red.service.redaction.report.v1.server.storage.ReportStorageService;
|
||||
import com.iqser.red.service.redaction.report.v1.server.storage.StorageIdUtils;
|
||||
import com.iqser.red.service.redaction.report.v1.server.utils.FileSystemBackedStorageService;
|
||||
import com.iqser.red.service.redaction.report.v1.server.utils.MetricValidationUtils;
|
||||
import com.iqser.red.storage.commons.StorageAutoConfiguration;
|
||||
@ -107,9 +109,6 @@ public class RedactionReportV2IntegrationTest {
|
||||
@MockBean
|
||||
private FileStatusClient fileStatusClient;
|
||||
|
||||
@MockBean
|
||||
private RedactionLogClient redactionLogClient;
|
||||
|
||||
@Autowired
|
||||
private ReportGenerationService reportGenerationService;
|
||||
|
||||
@ -122,6 +121,9 @@ public class RedactionReportV2IntegrationTest {
|
||||
@Autowired
|
||||
private PrometheusMeterRegistry prometheusMeterRegistry;
|
||||
|
||||
@Autowired
|
||||
private ReportStorageService reportStorageService;
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
private ReportRequestMessage prepareFlow(int numOfFiles, String... templates) {
|
||||
@ -156,11 +158,10 @@ public class RedactionReportV2IntegrationTest {
|
||||
.build());
|
||||
when(fileAttributesConfigClient.getFileAttributeConfigs("dossierTemplateId")).thenReturn(fileAttributeConfig);
|
||||
|
||||
var redactionLog = objectMapper.readValue(new ClassPathResource("files/65-S10redactionLogWithRedaction.json").getInputStream(), RedactionLog.class);
|
||||
var fileModels = createFileModels(numOfFiles);
|
||||
for (int i = 1; i <= numOfFiles; i++) {
|
||||
prepareStorage(i);
|
||||
when(fileStatusClient.getFileStatus("dossierId", "fileId" + i)).thenReturn(fileModels.get(i - 1));
|
||||
when(redactionLogClient.getRedactionLog("dossierId", "fileId" + i, new ArrayList<>(), true, false)).thenReturn(redactionLog);
|
||||
}
|
||||
|
||||
var templateIds = new HashSet<String>();
|
||||
@ -219,6 +220,13 @@ public class RedactionReportV2IntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private void prepareStorage(int id) {
|
||||
|
||||
var entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
|
||||
fileSystemBackedStorageService.storeJSONObject(TenantContext.getTenantId(), StorageIdUtils.getStorageId("dossierId", "fileId" + id, FileType.ENTITY_LOG), entityLog);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
|
||||
@ -0,0 +1,81 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.service;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
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.analysislog.entitylog.EntityLogLegalBasis;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.Dossier;
|
||||
import com.iqser.red.service.redaction.report.v1.server.Application;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DictionaryClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.ReportRedactionEntry;
|
||||
import com.iqser.red.service.redaction.report.v1.server.storage.ReportStorageService;
|
||||
import com.iqser.red.storage.commons.StorageAutoConfiguration;
|
||||
import com.knecon.fforesight.tenantcommons.TenantsClient;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = StorageAutoConfiguration.class)})
|
||||
public class EntityLogConverterServiceTest {
|
||||
|
||||
@MockBean
|
||||
TenantsClient tenantsClient;
|
||||
|
||||
@MockBean
|
||||
private DossierClient dossierClient;
|
||||
|
||||
@MockBean
|
||||
private DictionaryClient dictionaryClient;
|
||||
|
||||
@MockBean
|
||||
private ReportStorageService reportStorageService;
|
||||
|
||||
@InjectMocks
|
||||
private EntityLogConverterService entityLogConverterService;
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
public void testConvertAndSort() {
|
||||
|
||||
EntityLog entityLog = objectMapper.readValue(new ClassPathResource("files/entityLog.json").getInputStream(), EntityLog.class);
|
||||
List<EntityLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
|
||||
});
|
||||
List<ReportRedactionEntry> reportEntries = entityLogConverterService.convertAndSort(entityLog, legalBasisMapping, new HashMap<>());
|
||||
|
||||
assertNotNull(reportEntries);
|
||||
assertFalse(reportEntries.isEmpty());
|
||||
assertEquals(reportEntries.size(), 62);
|
||||
assertEquals(reportEntries.get(0).getPage(), 1);
|
||||
assertEquals(reportEntries.get(0).getSection(), "[1]: Section: Rule 1/2: Redact CBI");
|
||||
assertEquals(reportEntries.get(0).getJustification(), "Article 39(e)(3) of Regulation (EC) No 178/2002 ");
|
||||
assertEquals(reportEntries.get(0).getJustificationParagraph(), "Article 39(e)(3) of Regulation (EC) No 178/2002");
|
||||
assertFalse(reportEntries.get(0).isSkipped());
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user