Search in sources :

Example 1 with EnrollmentStoreImpl

use of org.hisp.dhis.android.core.enrollment.EnrollmentStoreImpl in project dhis2-android-sdk by dhis2.

the class TrackedEntityInstanceCallMockIntegrationShould method getDownloadedTei.

private TrackedEntityInstance getDownloadedTei(String teiUid) {
    TrackedEntityInstance downloadedTei;
    TrackedEntityAttributeValueStore teiAttributeValuesStore = new TrackedEntityAttributeValueStoreImpl(databaseAdapter());
    Map<String, List<TrackedEntityAttributeValue>> attValues = teiAttributeValuesStore.queryAll();
    TrackedEntityInstanceStoreImpl teiStore = new TrackedEntityInstanceStoreImpl(databaseAdapter());
    downloadedTei = teiStore.queryAll().get(teiUid);
    EnrollmentStoreImpl enrollmentStore = new EnrollmentStoreImpl(databaseAdapter());
    Map<String, List<Enrollment>> downloadedEnrollments = enrollmentStore.queryAll();
    EventStoreImpl eventStore = new EventStoreImpl(databaseAdapter());
    List<Event> downloadedEventsWithoutValues = eventStore.queryAll();
    TrackedEntityDataValueStoreImpl trackedEntityDataValue = new TrackedEntityDataValueStoreImpl(databaseAdapter());
    Map<String, List<TrackedEntityDataValue>> downloadedValues = trackedEntityDataValue.queryTrackedEntityDataValues();
    return createTei(downloadedTei, attValues, downloadedEnrollments.get(teiUid), downloadedEventsWithoutValues, downloadedValues);
}
Also used : EnrollmentStoreImpl(org.hisp.dhis.android.core.enrollment.EnrollmentStoreImpl) EventStoreImpl(org.hisp.dhis.android.core.event.EventStoreImpl) Event(org.hisp.dhis.android.core.event.Event) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with EnrollmentStoreImpl

use of org.hisp.dhis.android.core.enrollment.EnrollmentStoreImpl in project dhis2-android-sdk by dhis2.

the class TrackedEntityInstancePostCallRealIntegrationShould method getEnrollmentsByTrackedEntityInstanceFromDb.

private Enrollment getEnrollmentsByTrackedEntityInstanceFromDb(String trackedEntityInstanceUid) {
    EnrollmentStoreImpl enrollmentStore = new EnrollmentStoreImpl(databaseAdapter());
    Enrollment enrollment = null;
    Map<String, List<Enrollment>> storedEnrollmentsByTrackedEntityInstance = enrollmentStore.queryAll();
    for (Enrollment storedEnrollment : storedEnrollmentsByTrackedEntityInstance.get(trackedEntityInstanceUid)) {
        if (storedEnrollment.uid().equals(enrollmentUid)) {
            enrollment = storedEnrollment;
        }
    }
    return enrollment;
}
Also used : EnrollmentStoreImpl(org.hisp.dhis.android.core.enrollment.EnrollmentStoreImpl) Enrollment(org.hisp.dhis.android.core.enrollment.Enrollment) List(java.util.List)

Example 3 with EnrollmentStoreImpl

use of org.hisp.dhis.android.core.enrollment.EnrollmentStoreImpl in project dhis2-android-sdk by dhis2.

the class TrackedEntityInstancePostCallRealIntegrationShould method setUp.

@Before
@Override
public void setUp() throws IOException {
    super.setUp();
    d2 = D2Factory.create("https://play.dhis2.org/android-current/api/", databaseAdapter());
    trackedEntityInstanceStore = new TrackedEntityInstanceStoreImpl(databaseAdapter());
    enrollmentStore = new EnrollmentStoreImpl(databaseAdapter());
    eventStore = new EventStoreImpl(databaseAdapter());
    trackedEntityAttributeValueStore = new TrackedEntityAttributeValueStoreImpl(databaseAdapter());
    trackedEntityDataValueStore = new TrackedEntityDataValueStoreImpl(databaseAdapter());
    codeGenerator = new CodeGeneratorImpl();
    orgUnitUid = "DiszpKrYNg8";
    programUid = "IpHINAT79UW";
    programStageUid = "A03MvHHogjR";
    dataElementUid = "a3kGcGDCuk6";
    trackedEntityUid = "nEenWmSyUEp";
    trackedEntityAttributeUid = "w75KJ2mc4zz";
    coordinates = "[9,9]";
    featureType = FeatureType.POINT;
    categoryOptionUid = "CW81uF03hvV";
    categoryComboOptionUid = "l5QR5hJ4u44";
    eventUid = codeGenerator.generate();
    enrollmentUid = codeGenerator.generate();
    trackedEntityInstanceUid = codeGenerator.generate();
    event1Uid = codeGenerator.generate();
    enrollment1Uid = codeGenerator.generate();
    trackedEntityInstance1Uid = codeGenerator.generate();
}
Also used : CodeGeneratorImpl(org.hisp.dhis.android.core.utils.CodeGeneratorImpl) EventStoreImpl(org.hisp.dhis.android.core.event.EventStoreImpl) EnrollmentStoreImpl(org.hisp.dhis.android.core.enrollment.EnrollmentStoreImpl) Before(org.junit.Before)

Example 4 with EnrollmentStoreImpl

use of org.hisp.dhis.android.core.enrollment.EnrollmentStoreImpl in project dhis2-android-sdk by dhis2.

the class HandlerFactory method createEnrollmentHandler.

public static EnrollmentHandler createEnrollmentHandler(DatabaseAdapter databaseAdapter) {
    EnrollmentStore enrollmentStore = new EnrollmentStoreImpl(databaseAdapter);
    EventHandler eventHandler = createEventHandler(databaseAdapter);
    EnrollmentHandler enrollmentHandler = new EnrollmentHandler(databaseAdapter, enrollmentStore, eventHandler);
    return enrollmentHandler;
}
Also used : EnrollmentStore(org.hisp.dhis.android.core.enrollment.EnrollmentStore) EnrollmentStoreImpl(org.hisp.dhis.android.core.enrollment.EnrollmentStoreImpl) EventHandler(org.hisp.dhis.android.core.event.EventHandler) EnrollmentHandler(org.hisp.dhis.android.core.enrollment.EnrollmentHandler)

Example 5 with EnrollmentStoreImpl

use of org.hisp.dhis.android.core.enrollment.EnrollmentStoreImpl in project dhis2-android-sdk by dhis2.

the class TrackerDataCallMockIntegrationShould method setUp.

@Override
@Before
public void setUp() throws IOException {
    super.setUp();
    dhis2MockServer = new Dhis2MockServer(new AssetsFileReader());
    d2 = D2Factory.create(dhis2MockServer.getBaseEndpoint(), databaseAdapter());
    trackedEntityInstanceStore = new TrackedEntityInstanceStoreImpl(databaseAdapter());
    resourceStore = new ResourceStoreImpl(databaseAdapter());
    enrollmentStore = new EnrollmentStoreImpl(databaseAdapter());
}
Also used : Dhis2MockServer(org.hisp.dhis.android.core.data.server.Dhis2MockServer) TrackedEntityInstanceStoreImpl(org.hisp.dhis.android.core.trackedentity.TrackedEntityInstanceStoreImpl) EnrollmentStoreImpl(org.hisp.dhis.android.core.enrollment.EnrollmentStoreImpl) ResourceStoreImpl(org.hisp.dhis.android.core.resource.ResourceStoreImpl) AssetsFileReader(org.hisp.dhis.android.core.data.file.AssetsFileReader) Before(org.junit.Before)

Aggregations

EnrollmentStoreImpl (org.hisp.dhis.android.core.enrollment.EnrollmentStoreImpl)5 List (java.util.List)2 EventStoreImpl (org.hisp.dhis.android.core.event.EventStoreImpl)2 Before (org.junit.Before)2 ArrayList (java.util.ArrayList)1 AssetsFileReader (org.hisp.dhis.android.core.data.file.AssetsFileReader)1 Dhis2MockServer (org.hisp.dhis.android.core.data.server.Dhis2MockServer)1 Enrollment (org.hisp.dhis.android.core.enrollment.Enrollment)1 EnrollmentHandler (org.hisp.dhis.android.core.enrollment.EnrollmentHandler)1 EnrollmentStore (org.hisp.dhis.android.core.enrollment.EnrollmentStore)1 Event (org.hisp.dhis.android.core.event.Event)1 EventHandler (org.hisp.dhis.android.core.event.EventHandler)1 ResourceStoreImpl (org.hisp.dhis.android.core.resource.ResourceStoreImpl)1 TrackedEntityInstanceStoreImpl (org.hisp.dhis.android.core.trackedentity.TrackedEntityInstanceStoreImpl)1 CodeGeneratorImpl (org.hisp.dhis.android.core.utils.CodeGeneratorImpl)1