Search in sources :

Example 1 with IndicatorTypeEndpointCall

use of org.hisp.dhis.android.core.indicator.IndicatorTypeEndpointCall in project dhis2-android-sdk by dhis2.

the class DataSetParentCall method callBody.

@Override
public Response callBody() throws Exception {
    DataSetAccessEndpointCall dataSetAccessEndpointCall = dataSetAccessCallFactory.create(data);
    Response<Payload<DataSet>> dataSetAccessResponse = dataSetAccessEndpointCall.call();
    List<DataSet> dataSetsWithAccess = dataSetAccessResponse.body().items();
    Set<String> dataSetUids = DataSetParentUidsHelper.getAssignedDataSetUids(dataSetsWithAccess);
    DataSetEndpointCall dataSetEndpointCall = dataSetCallFactory.create(data, dataSetUids);
    Response<Payload<DataSet>> dataSetResponse = dataSetEndpointCall.call();
    List<DataSet> dataSets = dataSetResponse.body().items();
    DataElementEndpointCall dataElementEndpointCall = dataElementCallFactory.create(data, DataSetParentUidsHelper.getDataElementUids(dataSets));
    Response<Payload<DataElement>> dataElementResponse = dataElementEndpointCall.call();
    IndicatorEndpointCall indicatorEndpointCall = indicatorCallFactory.create(data, DataSetParentUidsHelper.getIndicatorUids(dataSets));
    Response<Payload<Indicator>> indicatorResponse = indicatorEndpointCall.call();
    List<Indicator> indicators = indicatorResponse.body().items();
    IndicatorTypeEndpointCall indicatorTypeEndpointCall = indicatorTypeCallFactory.create(data, DataSetParentUidsHelper.getIndicatorTypeUids(indicators));
    indicatorTypeEndpointCall.call();
    periodHandler.generateAndPersist();
    linkManager.saveDataSetDataElementAndIndicatorLinks(dataSets);
    linkManager.saveDataSetOrganisationUnitLinks(organisationUnits, dataSetUids);
    return dataElementResponse;
}
Also used : IndicatorEndpointCall(org.hisp.dhis.android.core.indicator.IndicatorEndpointCall) IndicatorTypeEndpointCall(org.hisp.dhis.android.core.indicator.IndicatorTypeEndpointCall) Indicator(org.hisp.dhis.android.core.indicator.Indicator) DataElementEndpointCall(org.hisp.dhis.android.core.dataelement.DataElementEndpointCall) Payload(org.hisp.dhis.android.core.common.Payload)

Aggregations

Payload (org.hisp.dhis.android.core.common.Payload)1 DataElementEndpointCall (org.hisp.dhis.android.core.dataelement.DataElementEndpointCall)1 Indicator (org.hisp.dhis.android.core.indicator.Indicator)1 IndicatorEndpointCall (org.hisp.dhis.android.core.indicator.IndicatorEndpointCall)1 IndicatorTypeEndpointCall (org.hisp.dhis.android.core.indicator.IndicatorTypeEndpointCall)1