use of org.hisp.dhis.android.core.event.EventStoreImpl 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);
}
use of org.hisp.dhis.android.core.event.EventStoreImpl 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();
}
use of org.hisp.dhis.android.core.event.EventStoreImpl in project dhis2-android-sdk by dhis2.
the class DataBaseMigrationShould method have_database_version_3_after_migration_from_database_with_content.
@Test
public void have_database_version_3_after_migration_from_database_with_content() throws IOException {
// given
final String finalEventScheme = "CREATE TABLE Event (_id INTEGER PRIMARY KEY AUTOINCREMENT,uid TEXT NOT NULL " + "UNIQUE,enrollment TEXT, created TEXT,lastUpdated TEXT,createdAtClient " + "TEXT,lastUpdatedAtClient TEXT,status TEXT,latitude TEXT,longitude " + "TEXT,program TEXT NOT NULL,programStage TEXT NOT NULL,organisationUnit" + " TEXT NOT NULL,eventDate TEXT,completedDate TEXT,dueDate TEXT,state " + "TEXT, attributeCategoryOptions TEXT, attributeOptionCombo TEXT, " + "trackedEntityInstance TEXT, FOREIGN KEY (program) REFERENCES Program " + "(uid) ON DELETE CASCADE, FOREIGN KEY (programStage) REFERENCES " + "ProgramStage (uid) ON DELETE CASCADE,FOREIGN KEY (enrollment) " + "REFERENCES Enrollment (uid) ON DELETE CASCADE DEFERRABLE INITIALLY " + "DEFERRED, FOREIGN KEY (organisationUnit) REFERENCES OrganisationUnit " + "(uid) ON DELETE CASCADE)";
final String finalTrackedEntityDataValueScheme = "CREATE TABLE TrackedEntityDataValue (_id INTEGER PRIMARY KEY AUTOINCREMENT,event" + " TEXT NOT NULL,dataElement TEXT NOT NULL,storedBy TEXT,value TEXT," + "created TEXT,lastUpdated TEXT,providedElsewhere INTEGER, FOREIGN KEY " + "(dataElement) REFERENCES DataElement (uid) ON DELETE CASCADE, FOREIGN" + " KEY (event) REFERENCES Event (uid) ON DELETE CASCADE)";
initCoreDataBase(dbName, 2, realMigrationDir, databaseSqlVersion2_with_data);
EventStore eventStore = new EventStoreImpl(databaseAdapter);
List<Event> eventList = eventStore.queryAll();
TrackedEntityDataValueStore trackedEntityDataValueStore = new TrackedEntityDataValueStoreImpl(databaseAdapter);
Map<String, List<TrackedEntityDataValue>> listOfTrackedEntityDataValues = trackedEntityDataValueStore.queryTrackedEntityDataValues();
// when
initCoreDataBase(dbName, 3, realMigrationDir, "");
eventStore = new EventStoreImpl(databaseAdapter);
trackedEntityDataValueStore = new TrackedEntityDataValueStoreImpl(databaseAdapter);
// then
assertTrue(eventList.equals(eventStore.queryAll()));
assertTrue(eventList.size() == 50);
assertTrue(listOfTrackedEntityDataValues.equals(trackedEntityDataValueStore.queryTrackedEntityDataValues()));
assertTrue(listOfTrackedEntityDataValues.size() == 50);
assertTrue(listOfTrackedEntityDataValues.get(eventList.get(0).uid()).equals(listOfTrackedEntityDataValues.get(eventList.get(0).uid())));
assertTrue(getSqlTableScheme(databaseAdapter, "Event").equals(finalEventScheme));
assertTrue(getSqlTableScheme(databaseAdapter, "TrackedEntityDataValue").equals(finalTrackedEntityDataValueScheme));
}
use of org.hisp.dhis.android.core.event.EventStoreImpl in project dhis2-android-sdk by dhis2.
the class SingleDataCallMockIntegrationShould method download_number_of_events_according_to_limit_by_org_unit.
@Test
public void download_number_of_events_according_to_limit_by_org_unit() throws Exception {
int eventLimitByOrgUnit = 122;
givenAMetadataInDatabase();
dhis2MockServer.enqueueMockResponse("system_info.json");
dhis2MockServer.enqueueMockResponse("events_1.json");
dhis2MockServer.enqueueMockResponse("events_2.json");
dhis2MockServer.enqueueMockResponse("events_3.json");
d2.syncSingleData(eventLimitByOrgUnit).call();
EventStoreImpl eventStore = new EventStoreImpl(databaseAdapter());
List<Event> downloadedEvents = eventStore.querySingleEvents();
assertThat(downloadedEvents.size(), is(eventLimitByOrgUnit));
}
use of org.hisp.dhis.android.core.event.EventStoreImpl in project dhis2-android-sdk by dhis2.
the class HandlerFactory method createEventHandler.
public static EventHandler createEventHandler(DatabaseAdapter databaseAdapter) {
TrackedEntityDataValueHandler trackedEntityDataValueHandler = createTrackedEntityDataValueHandler(databaseAdapter);
EventStore eventStore = new EventStoreImpl(databaseAdapter);
EventHandler eventHandler = new EventHandler(eventStore, trackedEntityDataValueHandler);
return eventHandler;
}
Aggregations