Search in sources :

Example 56 with ListGrid

use of org.hisp.dhis.system.grid.ListGrid in project dhis2-core by dhis2.

the class DataAnalysisController method generateAnalysisReportGridFromResults.

private Grid generateAnalysisReportGridFromResults(List<DeflatedDataValue> results, OrganisationUnit orgUnit) {
    Grid grid = new ListGrid();
    if (results != null) {
        I18nFormat format = i18nManager.getI18nFormat();
        I18n i18n = i18nManager.getI18n();
        grid.setTitle(i18n.getString("data_analysis_report"));
        if (orgUnit != null) {
            grid.setSubtitle(orgUnit.getName());
        }
        grid.addHeader(new GridHeader(i18n.getString("dataelement"), false, true));
        grid.addHeader(new GridHeader(i18n.getString("source"), false, true));
        grid.addHeader(new GridHeader(i18n.getString("period"), false, true));
        grid.addHeader(new GridHeader(i18n.getString("min"), false, false));
        grid.addHeader(new GridHeader(i18n.getString("value"), false, false));
        grid.addHeader(new GridHeader(i18n.getString("max"), false, false));
        for (DeflatedDataValue dataValue : results) {
            Period period = dataValue.getPeriod();
            grid.addRow();
            grid.addValue(dataValue.getDataElementName());
            grid.addValue(dataValue.getSourceName());
            grid.addValue(format.formatPeriod(period));
            grid.addValue(dataValue.getMin());
            grid.addValue(dataValue.getValue());
            grid.addValue(dataValue.getMax());
        }
    }
    return grid;
}
Also used : DeflatedDataValue(org.hisp.dhis.datavalue.DeflatedDataValue) 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) ListGrid(org.hisp.dhis.system.grid.ListGrid) I18n(org.hisp.dhis.i18n.I18n) GridHeader(org.hisp.dhis.common.GridHeader)

Example 57 with ListGrid

use of org.hisp.dhis.system.grid.ListGrid 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)

Example 58 with ListGrid

use of org.hisp.dhis.system.grid.ListGrid in project dhis2-core by dhis2.

the class AbstractGridView method renderMergedOutputModel.

@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
    Object object = model.get("model");
    List<Grid> grids = new ArrayList<>();
    if (WebMetadata.class.isAssignableFrom(object.getClass())) {
        WebMetadata metadata = (WebMetadata) object;
        Collection<Field> fields = ReflectionUtils.collectFields(WebMetadata.class, PredicateUtils.idObjectCollections);
        for (Field field : fields) {
            List<IdentifiableObject> identifiableObjects = ReflectionUtils.invokeGetterMethod(field.getName(), metadata);
            if (identifiableObjects == null || identifiableObjects.isEmpty()) {
                continue;
            }
            Grid grid = new ListGrid();
            grid.setTitle(HibernateProxyUtils.getRealClass(identifiableObjects.get(0)).getSimpleName() + "s");
            boolean nameable = false;
            grid.addHeader(new GridHeader("UID", false, false));
            grid.addHeader(new GridHeader("Name", false, false));
            if (NameableObject.class.isAssignableFrom(HibernateProxyUtils.getRealClass(HibernateProxyUtils.getRealClass(object)))) {
                grid.addHeader(new GridHeader("ShortName", false, false));
                nameable = true;
            }
            grid.addHeader(new GridHeader("Code", false, false));
            for (IdentifiableObject identifiableObject : identifiableObjects) {
                grid.addRow();
                grid.addValue(identifiableObject.getUid());
                grid.addValue(identifiableObject.getName());
                if (nameable) {
                    grid.addValue(((NameableObject) identifiableObject).getShortName());
                }
                grid.addValue(identifiableObject.getCode());
            }
            grids.add(grid);
        }
    } else {
        IdentifiableObject identifiableObject = (IdentifiableObject) object;
        Grid grid = new ListGrid();
        grid.setTitle(HibernateProxyUtils.getRealClass(identifiableObject).getSimpleName());
        grid.addEmptyHeaders(2);
        grid.addRow().addValue("UID").addValue(identifiableObject.getUid());
        grid.addRow().addValue("Name").addValue(identifiableObject.getName());
        if (NameableObject.class.isAssignableFrom(HibernateProxyUtils.getRealClass(identifiableObject))) {
            grid.addRow().addValue("ShortName").addValue(((NameableObject) identifiableObject).getShortName());
            grid.addRow().addValue("Description").addValue(((NameableObject) identifiableObject).getDescription());
        }
        grid.addRow().addValue("Code").addValue(identifiableObject.getCode());
        grids.add(grid);
    }
    renderGrids(grids, response);
}
Also used : Field(java.lang.reflect.Field) ListGrid(org.hisp.dhis.system.grid.ListGrid) Grid(org.hisp.dhis.common.Grid) ArrayList(java.util.ArrayList) IdentifiableObject(org.hisp.dhis.common.IdentifiableObject) NameableObject(org.hisp.dhis.common.NameableObject) ListGrid(org.hisp.dhis.system.grid.ListGrid) WebMetadata(org.hisp.dhis.webapi.webdomain.WebMetadata) IdentifiableObject(org.hisp.dhis.common.IdentifiableObject) GridHeader(org.hisp.dhis.common.GridHeader)

Aggregations

ListGrid (org.hisp.dhis.system.grid.ListGrid)58 Grid (org.hisp.dhis.common.Grid)41 GridHeader (org.hisp.dhis.common.GridHeader)28 Test (org.junit.jupiter.api.Test)21 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)14 EventQueryParams (org.hisp.dhis.analytics.event.EventQueryParams)11 ArrayList (java.util.ArrayList)10 DimensionalObject (org.hisp.dhis.common.DimensionalObject)10 HashMap (java.util.HashMap)9 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)9 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 DataElement (org.hisp.dhis.dataelement.DataElement)8 List (java.util.List)7 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)7 Test (org.junit.Test)7 ProgramIndicator (org.hisp.dhis.program.ProgramIndicator)6 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)5 DataValueSet (org.hisp.dhis.dxf2.datavalueset.DataValueSet)5 I18nFormat (org.hisp.dhis.i18n.I18nFormat)5