Search in sources :

Example 1 with DataSetCompletenessService

use of org.hisp.dhis.completeness.DataSetCompletenessService in project dhis2-core by dhis2.

the class GetDataCompletenessAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    Grid _grid = (Grid) SessionUtils.getSessionVar(KEY_DATA_COMPLETENESS);
    if (_grid != null && type != null && !type.equals(DEFAULT_TYPE)) {
        grid = _grid;
        return type;
    } else {
        OrganisationUnit selectedUnit = selectionTreeManager.getReloadedSelectedOrganisationUnit();
        if (periodId == null || selectedUnit == null || criteria == null) {
            return INPUT;
        } else {
            Period period = periodService.reloadPeriod(PeriodType.getPeriodFromIsoString(periodId));
            Integer _periodId = period.getId();
            DataSet dataSet = null;
            List<DataSetCompletenessResult> mainResults = new ArrayList<>();
            List<DataSetCompletenessResult> footerResults = new ArrayList<>();
            DataSetCompletenessService completenessService = serviceProvider.provide(criteria);
            if (// One ds for one ou
            dataSetId != null && dataSetId != 0) {
                mainResults = new ArrayList<>(completenessService.getDataSetCompleteness(_periodId, getIdentifiers(selectedUnit.getChildren()), dataSetId, groupId));
                footerResults = new ArrayList<>(completenessService.getDataSetCompleteness(_periodId, Arrays.asList(selectedUnit.getId()), dataSetId, groupId));
                dataSet = dataSetService.getDataSet(dataSetId);
            } else // All ds for children of one ou               
            {
                mainResults = new ArrayList<>(completenessService.getDataSetCompleteness(_periodId, selectedUnit.getId(), groupId));
            }
            grid = getGrid(mainResults, footerResults, selectedUnit, dataSet, period);
            SessionUtils.setSessionVar(KEY_DATA_COMPLETENESS, grid);
        }
        return type != null ? type : DEFAULT_TYPE;
    }
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataSetCompletenessResult(org.hisp.dhis.completeness.DataSetCompletenessResult) DataSet(org.hisp.dhis.dataset.DataSet) ListGrid(org.hisp.dhis.system.grid.ListGrid) Grid(org.hisp.dhis.common.Grid) ArrayList(java.util.ArrayList) Period(org.hisp.dhis.period.Period) DataSetCompletenessService(org.hisp.dhis.completeness.DataSetCompletenessService)

Aggregations

ArrayList (java.util.ArrayList)1 Grid (org.hisp.dhis.common.Grid)1 DataSetCompletenessResult (org.hisp.dhis.completeness.DataSetCompletenessResult)1 DataSetCompletenessService (org.hisp.dhis.completeness.DataSetCompletenessService)1 DataSet (org.hisp.dhis.dataset.DataSet)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 Period (org.hisp.dhis.period.Period)1 ListGrid (org.hisp.dhis.system.grid.ListGrid)1