Commit 417a6d36 authored by Hando Lukats's avatar Hando Lukats
Browse files

TEIS-2422; fixed risk factor sorting for risk assessment pdf generation

parent f7ecb987
theGroup=ee.sm.ti.teis
theVersion=1.6.0-SNAPSHOT
commonsVersion=1.27.0
officeApiGatewayVersion=1.27.0
officeApiGatewayVersion=1.28.0-SNAPSHOT
filesVersion=1.21.0
pluginVersion=1.3.0
......@@ -43,12 +43,13 @@ public class RiskAssessmentPDFComposeService {
.build();
}
public RiskFactorPdfDto composeRiskFactorPdfDto(String name, String description, String explanation) {
public RiskFactorPdfDto composeRiskFactorPdfDto(String name, String description, String explanation, Long seqNo) {
String cleanedDescription = removeMarkdown(description);
String cleanedExplanation = removeMarkdown(explanation);
String cleanedName = removeMarkdown(name);
return RiskFactorPdfDto.builder()
.name(cleanedName)
.seqNo(seqNo)
.description(cleanedDescription)
.explanation(cleanedExplanation)
.build();
......
......@@ -113,9 +113,10 @@ public class RiskAssessmentPDFService {
RiskFactorPdfDto riskFactor;
if (riskFactorAssessment.getRiskFactorId() != null) {
RiskFactorEntity riskFactorEntity = riskFactorDataService.getById(riskFactorAssessment.getRiskFactorId());
riskFactor = pdfComposeService.composeRiskFactorPdfDto(riskFactorEntity.getName(), riskFactorEntity.getImpact(), riskFactorAssessment.getDescription());
riskFactor = pdfComposeService.composeRiskFactorPdfDto(riskFactorEntity.getName(), riskFactorEntity.getImpact(),
riskFactorAssessment.getDescription(), riskFactorEntity.getSeqNo());
} else {
riskFactor = pdfComposeService.composeRiskFactorPdfDto(riskFactorAssessment.getName(), riskFactorAssessment.getDescription(), null);
riskFactor = pdfComposeService.composeRiskFactorPdfDto(riskFactorAssessment.getName(), riskFactorAssessment.getDescription(), null, null);
}
setRiskStatementAssessments(riskAssessmentId, riskFactorAssessment.getId(), riskFactor, requestMetaDTO);
pdfComposeService.addToRiskFactorCategory(categoryList, category, existingCategory, riskFactor);
......@@ -123,6 +124,9 @@ public class RiskAssessmentPDFService {
});
categoryList.sort(Comparator.comparing(RiskFactorPdfCategoryDto::getSeqNo, Comparator.nullsLast(Comparator.naturalOrder()))
.thenComparing(RiskFactorPdfCategoryDto::getName));
categoryList.forEach(category -> {
category.getRiskFactors().sort(Comparator.comparing(RiskFactorPdfDto::getSeqNo, Comparator.nullsLast(Comparator.naturalOrder())).thenComparing(RiskFactorPdfDto::getName));
});
return categoryList;
}
......@@ -209,9 +213,10 @@ public class RiskAssessmentPDFService {
RiskFactorPdfDto riskFactorData;
if (riskFactorAssessment.getRiskFactorId() != null) {
RiskFactorEntity riskFactorEntity = riskFactorDataService.getById(riskFactorAssessment.getRiskFactorId());
riskFactorData = pdfComposeService.composeRiskFactorPdfDto(riskFactorEntity.getName(), riskFactorEntity.getImpact(), riskFactorAssessment.getDescription());
riskFactorData = pdfComposeService.composeRiskFactorPdfDto(riskFactorEntity.getName(), riskFactorEntity.getImpact(),
riskFactorAssessment.getDescription(), riskFactorEntity.getSeqNo());
} else {
riskFactorData = pdfComposeService.composeRiskFactorPdfDto(riskFactorAssessment.getName(), riskFactorAssessment.getDescription(), null);
riskFactorData = pdfComposeService.composeRiskFactorPdfDto(riskFactorAssessment.getName(), riskFactorAssessment.getDescription(), null, null);
}
setRiskStatementAssessments(riskFactorAssessment.getRiskAssessmentId(), riskFactorAssessment.getId(), riskFactorData, requestMetaDTO);
pdfComposeService.addToRiskFactorCategory(categoryList, category, existingCategory, riskFactorData);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment