Search in sources :

Example 1 with TrackedEntityInstancePayload

use of org.hisp.dhis.android.core.trackedentity.TrackedEntityInstancePayload in project dhis2-android-sdk by dhis2.

the class TrackedEntityInstancePostCall method call.

@Override
public Response<WebResponse> call() throws Exception {
    synchronized (this) {
        if (isExecuted) {
            throw new IllegalStateException("Call is already executed");
        }
        isExecuted = true;
    }
    List<TrackedEntityInstance> trackedEntityInstancesToPost = queryDataToSync();
    // if size is 0, then no need to do network request
    if (trackedEntityInstancesToPost.isEmpty()) {
        return null;
    }
    TrackedEntityInstancePayload trackedEntityInstancePayload = new TrackedEntityInstancePayload();
    trackedEntityInstancePayload.trackedEntityInstances = trackedEntityInstancesToPost;
    Response<WebResponse> response = trackedEntityInstanceService.postTrackedEntityInstances(trackedEntityInstancePayload).execute();
    if (response.isSuccessful()) {
        handleWebResponse(response);
    }
    return response;
}
Also used : WebResponse(org.hisp.dhis.android.core.imports.WebResponse) TrackedEntityInstancePayload(org.hisp.dhis.android.core.trackedentity.TrackedEntityInstancePayload) TrackedEntityInstance(org.hisp.dhis.android.core.trackedentity.TrackedEntityInstance)

Aggregations

WebResponse (org.hisp.dhis.android.core.imports.WebResponse)1 TrackedEntityInstance (org.hisp.dhis.android.core.trackedentity.TrackedEntityInstance)1 TrackedEntityInstancePayload (org.hisp.dhis.android.core.trackedentity.TrackedEntityInstancePayload)1