Search in sources :

Example 1 with Operator

use of org.hisp.dhis.expression.Operator in project dhis2-core by dhis2.

the class DataAnalysisController method generateValidationRulesReportGridFromResults.

private Grid generateValidationRulesReportGridFromResults(List<ValidationResult> results, OrganisationUnit orgUnit) {
    Grid grid = new ListGrid();
    if (results != null) {
        I18nFormat format = i18nManager.getI18nFormat();
        I18n i18n = i18nManager.getI18n();
        grid.setTitle(i18n.getString("data_quality_report"));
        if (orgUnit != null) {
            grid.setSubtitle(orgUnit.getName());
        }
        grid.addHeader(new GridHeader(i18n.getString("source"), false, true));
        grid.addHeader(new GridHeader(i18n.getString("period"), false, true));
        grid.addHeader(new GridHeader(i18n.getString("validation_rule"), false, true));
        grid.addHeader(new GridHeader(i18n.getString("importance"), false, true));
        grid.addHeader(new GridHeader(i18n.getString("left_side_description"), false, true));
        grid.addHeader(new GridHeader(i18n.getString("value"), false, false));
        grid.addHeader(new GridHeader(i18n.getString("operator"), false, false));
        grid.addHeader(new GridHeader(i18n.getString("value"), false, false));
        grid.addHeader(new GridHeader(i18n.getString("right_side_description"), false, true));
        for (ValidationResult validationResult : results) {
            OrganisationUnit unit = validationResult.getOrganisationUnit();
            Period period = validationResult.getPeriod();
            Importance importance = validationResult.getValidationRule().getImportance();
            Operator operator = validationResult.getValidationRule().getOperator();
            grid.addRow();
            grid.addValue(unit.getName());
            grid.addValue(format.formatPeriod(period));
            grid.addValue(validationResult.getValidationRule().getName());
            grid.addValue(i18n.getString(importance.toString().toLowerCase()));
            grid.addValue(validationResult.getValidationRule().getLeftSide().getDescription());
            grid.addValue(String.valueOf(validationResult.getLeftsideValue()));
            grid.addValue(i18n.getString(operator.toString()));
            grid.addValue(String.valueOf(validationResult.getRightsideValue()));
            grid.addValue(validationResult.getValidationRule().getRightSide().getDescription());
        }
    }
    return grid;
}
Also used : Importance(org.hisp.dhis.validation.Importance) Operator(org.hisp.dhis.expression.Operator) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) ListGrid(org.hisp.dhis.system.grid.ListGrid) Grid(org.hisp.dhis.common.Grid) Period(org.hisp.dhis.period.Period) I18nFormat(org.hisp.dhis.i18n.I18nFormat) ValidationResult(org.hisp.dhis.validation.ValidationResult) ListGrid(org.hisp.dhis.system.grid.ListGrid) I18n(org.hisp.dhis.i18n.I18n) GridHeader(org.hisp.dhis.common.GridHeader)

Aggregations

Grid (org.hisp.dhis.common.Grid)1 GridHeader (org.hisp.dhis.common.GridHeader)1 Operator (org.hisp.dhis.expression.Operator)1 I18n (org.hisp.dhis.i18n.I18n)1 I18nFormat (org.hisp.dhis.i18n.I18nFormat)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 Period (org.hisp.dhis.period.Period)1 ListGrid (org.hisp.dhis.system.grid.ListGrid)1 Importance (org.hisp.dhis.validation.Importance)1 ValidationResult (org.hisp.dhis.validation.ValidationResult)1