use of org.hisp.dhis.android.core.event.Event in project dhis2-android-sdk by dhis2.
the class TrackedEntityInstanceCallMockIntegrationShould method createTei.
private TrackedEntityInstance createTei(TrackedEntityInstance downloadedTei, Map<String, List<TrackedEntityAttributeValue>> attValues, List<Enrollment> downloadedEnrollmentsWithoutEvents, List<Event> downloadedEventsWithoutValues, Map<String, List<TrackedEntityDataValue>> downloadedValues) {
Map<String, List<Event>> downloadedEvents = new HashMap<>();
List<Enrollment> downloadedEnrollments = new ArrayList<>();
for (Event event : downloadedEventsWithoutValues) {
event = Event.create(event.uid(), event.enrollmentUid(), event.created(), event.lastUpdated(), event.createdAtClient(), event.lastUpdatedAtClient(), event.program(), event.programStage(), event.organisationUnit(), event.eventDate(), event.status(), event.coordinates(), event.completedDate(), event.dueDate(), event.deleted(), downloadedValues.get(event.uid()), event.attributeCategoryOptions(), event.attributeOptionCombo(), event.trackedEntityInstance());
if (downloadedEvents.get(event.enrollmentUid()) == null) {
downloadedEvents.put(event.enrollmentUid(), new ArrayList<Event>());
}
downloadedEvents.get(event.enrollmentUid()).add(event);
}
for (Enrollment enrollment : downloadedEnrollmentsWithoutEvents) {
enrollment = Enrollment.create(enrollment.uid(), enrollment.created(), enrollment.lastUpdated(), enrollment.createdAtClient(), enrollment.lastUpdatedAtClient(), enrollment.organisationUnit(), enrollment.program(), enrollment.dateOfEnrollment(), enrollment.dateOfIncident(), enrollment.followUp(), enrollment.enrollmentStatus(), downloadedTei.uid(), enrollment.coordinate(), enrollment.deleted(), downloadedEvents.get(enrollment.uid()), enrollment.notes());
downloadedEnrollments.add(enrollment);
}
List<Relationship> relationships = new ArrayList<>();
if (downloadedTei.relationships() != null) {
relationships = downloadedTei.relationships();
}
downloadedTei = TrackedEntityInstance.create(downloadedTei.uid(), downloadedTei.created(), downloadedTei.lastUpdated(), downloadedTei.createdAtClient(), downloadedTei.lastUpdatedAtClient(), downloadedTei.organisationUnit(), downloadedTei.trackedEntity(), downloadedTei.coordinates(), downloadedTei.featureType(), downloadedTei.deleted(), attValues.get(downloadedTei.uid()), relationships, downloadedEnrollments);
return downloadedTei;
}
use of org.hisp.dhis.android.core.event.Event in project dhis2-android-sdk by dhis2.
the class TrackedEntityInstanceCallMockIntegrationShould method removeDeletedData.
@NonNull
private TrackedEntityInstance removeDeletedData(TrackedEntityInstance trackedEntityInstance) {
Map<String, List<Event>> expectedEvents = new HashMap<>();
List<Enrollment> expectedEnrollments = new ArrayList<>();
for (Enrollment enrollment : trackedEntityInstance.enrollments()) {
for (Event event : enrollment.events()) {
if (!event.deleted()) {
if (expectedEvents.get(event.enrollmentUid()) == null) {
expectedEvents.put(event.enrollmentUid(), new ArrayList<Event>());
}
expectedEvents.get(event.enrollmentUid()).add(event);
}
}
if (!enrollment.deleted()) {
enrollment = Enrollment.create(enrollment.uid(), enrollment.created(), enrollment.lastUpdated(), enrollment.createdAtClient(), enrollment.lastUpdatedAtClient(), enrollment.organisationUnit(), enrollment.program(), enrollment.dateOfEnrollment(), enrollment.dateOfIncident(), enrollment.followUp(), enrollment.enrollmentStatus(), trackedEntityInstance.uid(), enrollment.coordinate(), enrollment.deleted(), expectedEvents.get(enrollment.uid()), enrollment.notes());
expectedEnrollments.add(enrollment);
}
}
trackedEntityInstance = TrackedEntityInstance.create(trackedEntityInstance.uid(), trackedEntityInstance.created(), trackedEntityInstance.lastUpdated(), trackedEntityInstance.createdAtClient(), trackedEntityInstance.lastUpdatedAtClient(), trackedEntityInstance.organisationUnit(), trackedEntityInstance.trackedEntity(), trackedEntityInstance.coordinates(), trackedEntityInstance.featureType(), trackedEntityInstance.deleted(), trackedEntityInstance.trackedEntityAttributeValues(), trackedEntityInstance.relationships(), expectedEnrollments);
return trackedEntityInstance;
}
use of org.hisp.dhis.android.core.event.Event in project dhis2-android-sdk by dhis2.
the class TrackedEntityInstancePostCallRealIntegrationShould method getEventsFromDb.
private Event getEventsFromDb(String eventUid) {
EventStoreImpl eventStore = new EventStoreImpl(databaseAdapter());
Event event = null;
List<Event> storedEvents = eventStore.queryAll();
for (Event storedEvent : storedEvents) {
if (storedEvent.uid().equals(eventUid)) {
event = storedEvent;
}
}
return event;
}
Aggregations