use of org.eyeseetea.malariacare.domain.exception.ConversionException in project pictureapp by EyeSeeTea.
the class PushController method push.
public void push(final IPushControllerCallback callback) {
if (!ServerAPIController.isNetworkAvailable()) {
Log.d(TAG, "No network");
callback.onError(new NetworkException());
} else {
Log.d(TAG, "Network connected");
List<Survey> surveys = Survey.getAllCompletedSurveysNoReceiptReset();
//Fixme Check if is necessary other conditions
if (surveys == null || surveys.size() == 0) {
Log.d("DpBlank", "Sets of Surveys to push");
callback.onError(new SurveysToPushNotFoundException());
} else {
for (Survey srv : surveys) {
Log.d("DpBlank", "Survey to push " + srv.toString());
for (Value dv : srv.getValuesFromDB()) {
Log.d("DpBlank", "Values to push " + dv.toString());
}
}
mPushDhisSDKDataSource.wipeEvents();
try {
convertToSDK(surveys);
} catch (Exception ex) {
callback.onError(new ConversionException(ex));
}
if (EventExtended.getAllEvents().size() == 0) {
callback.onError(new ConversionException());
} else {
pushData(callback);
}
}
}
}
Aggregations