use of org.hisp.dhis.webapi.webdomain.ValidationResultView in project dhis2-core by dhis2.
the class DataAnalysisController method validationResultsListToResponse.
private List<ValidationResultView> validationResultsListToResponse(List<ValidationResult> validationResults) {
I18nFormat format = i18nManager.getI18nFormat();
if (validationResults == null) {
return Collections.emptyList();
}
List<ValidationResultView> validationResultViews = new ArrayList<>(validationResults.size());
for (ValidationResult validationResult : validationResults) {
ValidationResultView validationResultView = new ValidationResultView();
ValidationRule validationRule = validationResult.getValidationRule();
if (validationRule != null) {
validationResultView.setValidationRuleId(validationRule.getUid());
validationResultView.setValidationRuleDescription(validationRule.getDescription());
validationResultView.setImportance(validationRule.getImportance().toString());
validationResultView.setOperator(validationRule.getOperator().getMathematicalOperator());
}
OrganisationUnit organisationUnit = validationResult.getOrganisationUnit();
if (organisationUnit != null) {
validationResultView.setOrganisationUnitId(organisationUnit.getUid());
validationResultView.setOrganisationUnitDisplayName(organisationUnit.getDisplayName());
validationResultView.setOrganisationUnitPath(organisationUnit.getPath());
validationResultView.setOrganisationUnitAncestorNames(organisationUnit.getAncestorNames());
}
Period period = validationResult.getPeriod();
if (period != null) {
validationResultView.setPeriodId(period.getIsoDate());
validationResultView.setPeriodDisplayName(format.formatPeriod(period));
}
CategoryOptionCombo attributeOptionCombo = validationResult.getAttributeOptionCombo();
if (attributeOptionCombo != null) {
validationResultView.setAttributeOptionComboId(attributeOptionCombo.getUid());
validationResultView.setAttributeOptionComboDisplayName(attributeOptionCombo.getDisplayName());
}
validationResultView.setLeftSideValue(validationResult.getLeftsideValue());
validationResultView.setRightSideValue(validationResult.getRightsideValue());
validationResultViews.add(validationResultView);
}
return validationResultViews;
}
Aggregations