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;
}
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;
}
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;
}
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;
}
Aggregations