Commit 1620128c authored by Hando Lukats's avatar Hando Lukats
Browse files

TEIS-2422 updated risk assessment pdf generation

parent 9169b4e3
......@@ -46,6 +46,7 @@ public class RiskAssessmentPDFComposeService {
public RiskFactorPdfDto composeRiskFactorPdfDto(String name, String impact, String explanation) {
impact = removeMarkdown(impact);
explanation = removeMarkdown(explanation);
name = removeMarkdown(name);
return RiskFactorPdfDto.builder()
.name(name)
.description(impact)
......@@ -57,8 +58,7 @@ public class RiskAssessmentPDFComposeService {
if (string == null) {
return null;
}
String pattern = "(.*) (\\[([a-zA-Z]*)]\\?*\\(.*\\))";
return string.replaceAll(pattern, "$1 $3");
return string.replaceAll("\\[([A-Za-z]*)]\\?*\\([A-Za-z]*\\)", "$1");
}
public RiskIndicatorPdfDto composeRiskIndicator(RiskStatementAssessmentPdfDto riskStatementAssessment,
......
......@@ -107,10 +107,16 @@ public class RiskAssessmentPDFService {
riskFactorAssessments.forEach(riskFactorAssessment -> {
if (BooleanUtils.isFalse(riskFactorAssessment.getAdditional()) && riskFactorAssessment.getRiskFactorId() != null) {
setRiskFactorCategoryByClassifier(categoryList, riskFactorAssessment, requestMetaDTO);
} else if (BooleanUtils.isTrue(riskFactorAssessment.getAdditional()) || riskFactorAssessment.getRiskFactorId() != null) {
} else if (BooleanUtils.isTrue(riskFactorAssessment.getAdditional())) {
RiskFactorPdfCategoryDto category = pdfComposeService.composeRiskFactorCategoryDto(ADDITIONAL_RISK_FACTORS, null);
Optional<RiskFactorPdfCategoryDto> existingCategory = getExistingRiskFactorCategory(categoryList, ADDITIONAL_RISK_FACTORS);
RiskFactorPdfDto riskFactor = pdfComposeService.composeRiskFactorPdfDto(riskFactorAssessment.getName(), riskFactorAssessment.getDescription(), null);
RiskFactorPdfDto riskFactor;
if (riskFactorAssessment.getRiskFactorId() != null) {
RiskFactorEntity riskFactorEntity = riskFactorDataService.getById(riskFactorAssessment.getRiskFactorId());
riskFactor = pdfComposeService.composeRiskFactorPdfDto(riskFactorEntity.getName(), riskFactorEntity.getImpact(), riskFactorAssessment.getDescription());
} else {
riskFactor = pdfComposeService.composeRiskFactorPdfDto(riskFactorAssessment.getName(), riskFactorAssessment.getDescription(), null);
}
setRiskStatementAssessments(riskAssessmentId, riskFactorAssessment.getId(), riskFactor, requestMetaDTO);
pdfComposeService.addToRiskFactorCategory(categoryList, category, existingCategory, riskFactor);
}
......@@ -200,7 +206,13 @@ public class RiskAssessmentPDFService {
ClassifierItem categoryClassifier = classifierService.getClassifierItem(riskFactor.getCategory(), requestMetaDTO);
RiskFactorPdfCategoryDto category = pdfComposeService.composeRiskFactorCategoryDto(categoryClassifier.getName(), categoryClassifier.getSeqNo());
Optional<RiskFactorPdfCategoryDto> existingCategory = getExistingRiskFactorCategory(categoryList, categoryClassifier.getName());
RiskFactorPdfDto riskFactorData = pdfComposeService.composeRiskFactorPdfDto(riskFactor.getName(), riskFactor.getImpact(), riskFactorAssessment.getDescription());
RiskFactorPdfDto riskFactorData;
if (riskFactorAssessment.getRiskFactorId() != null) {
RiskFactorEntity riskFactorEntity = riskFactorDataService.getById(riskFactorAssessment.getRiskFactorId());
riskFactorData = pdfComposeService.composeRiskFactorPdfDto(riskFactorEntity.getName(), riskFactorEntity.getImpact(), riskFactorAssessment.getDescription());
} else {
riskFactorData = pdfComposeService.composeRiskFactorPdfDto(riskFactorAssessment.getName(), riskFactorAssessment.getDescription(), 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