Search in sources :

Example 1 with DataSetList

use of org.hisp.dhis.api.mobile.model.DataSetList in project dhis2-core by dhis2.

the class MobileOrganisationUnitController method checkUpdatedDataSet.

@RequestMapping(method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/updateDataSets")
@ResponseBody
public DataSetList checkUpdatedDataSet(@PathVariable String clientVersion, @PathVariable int id, @RequestBody DataSetList dataSetList, @RequestHeader("accept-language") String locale) {
    DataSetList returnList = facilityReportingService.getUpdatedDataSet(dataSetList, getUnit(id), locale);
    returnList.setClientVersion(clientVersion);
    return returnList;
}
Also used : DataSetList(org.hisp.dhis.api.mobile.model.DataSetList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with DataSetList

use of org.hisp.dhis.api.mobile.model.DataSetList in project dhis2-core by dhis2.

the class MobileOrganisationUnitController method checkUpdatedDataSet2_8.

@RequestMapping(method = RequestMethod.POST, value = "orgUnits/{id}/updateDataSets")
@ResponseBody
public DataSetList checkUpdatedDataSet2_8(@PathVariable int id, @RequestBody DataSetList dataSetList, @RequestHeader("accept-language") String locale) {
    DataSetList returnList = facilityReportingService.getUpdatedDataSet(dataSetList, getUnit(id), locale);
    returnList.setClientVersion(DataStreamSerializable.TWO_POINT_EIGHT);
    return returnList;
}
Also used : DataSetList(org.hisp.dhis.api.mobile.model.DataSetList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with DataSetList

use of org.hisp.dhis.api.mobile.model.DataSetList in project dhis2-core by dhis2.

the class FacilityReportingServiceImpl method getUpdatedDataSet.

@Override
public DataSetList getUpdatedDataSet(DataSetList dataSetList, OrganisationUnit unit, String locale) {
    if (DEBUG)
        log.debug("Checking updated datasets for org unit " + unit.getName());
    DataSetList updatedDataSetList = new DataSetList();
    List<DataSet> dataSets = this.getMobileDataSetsForUnit(unit, locale);
    List<DataSet> currentDataSets = dataSetList.getCurrentDataSets();
    // check added dataset
    for (DataSet dataSet : dataSets) {
        if (!currentDataSets.contains(dataSet)) {
            if (updatedDataSetList.getAddedDataSets() == null)
                updatedDataSetList.setAddedDataSets(new ArrayList<>());
            updatedDataSetList.getAddedDataSets().add(dataSet);
            currentDataSets.add(dataSet);
        }
    }
    // check deleted dataset
    for (DataSet dataSet : currentDataSets) {
        if (!dataSets.contains(dataSet)) {
            if (updatedDataSetList.getDeletedDataSets() == null)
                updatedDataSetList.setDeletedDataSets(new ArrayList<>());
            updatedDataSetList.getDeletedDataSets().add(new DataSet(dataSet));
        }
    }
    if (updatedDataSetList.getDeletedDataSets() != null) {
        for (DataSet dataSet : updatedDataSetList.getDeletedDataSets()) {
            currentDataSets.remove(dataSet);
        }
    }
    // check modified dataset
    Collections.sort(dataSets);
    Collections.sort(currentDataSets);
    for (int i = 0; i < dataSets.size(); i++) {
        if (dataSets.get(i).getVersion() != currentDataSets.get(i).getVersion()) {
            if (updatedDataSetList.getModifiedDataSets() == null)
                updatedDataSetList.setModifiedDataSets(new ArrayList<>());
            updatedDataSetList.getModifiedDataSets().add(dataSets.get(i));
        }
    }
    if (DEBUG)
        log.debug("Returning updated datasets for org unit " + unit.getName());
    return updatedDataSetList;
}
Also used : DataSet(org.hisp.dhis.api.mobile.model.DataSet) ArrayList(java.util.ArrayList) DataSetList(org.hisp.dhis.api.mobile.model.DataSetList)

Example 4 with DataSetList

use of org.hisp.dhis.api.mobile.model.DataSetList in project dhis2-core by dhis2.

the class FacilityReportingServiceImpl method getDataSetsForLocale.

@Override
public DataSetList getDataSetsForLocale(OrganisationUnit unit, String locale) {
    DataSetList dataSetList = new DataSetList();
    List<DataSet> dataSets = getMobileDataSetsForUnit(unit, locale);
    dataSetList.setModifiedDataSets(dataSets);
    return dataSetList;
}
Also used : DataSet(org.hisp.dhis.api.mobile.model.DataSet) DataSetList(org.hisp.dhis.api.mobile.model.DataSetList)

Aggregations

DataSetList (org.hisp.dhis.api.mobile.model.DataSetList)4 DataSet (org.hisp.dhis.api.mobile.model.DataSet)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 ArrayList (java.util.ArrayList)1