use of org.hisp.dhis.android.core.trackedentity.TrackedEntityDataValueStoreImpl in project dhis2-android-sdk by dhis2.
the class EventEndPointCallMockIntegrationShould method verifyNumberOfDownloadedTrackedEntityDataValue.
private void verifyNumberOfDownloadedTrackedEntityDataValue(int num) {
TrackedEntityDataValueStoreImpl eventStore = new TrackedEntityDataValueStoreImpl(d2.databaseAdapter());
int numPersisted = eventStore.countAll();
assertThat(numPersisted, is(num));
}
use of org.hisp.dhis.android.core.trackedentity.TrackedEntityDataValueStoreImpl in project dhis2-android-sdk by dhis2.
the class EventEndPointCallRealIntegrationShould method verifyNumberOfDownloadedTrackedEntityDataValue.
private void verifyNumberOfDownloadedTrackedEntityDataValue(int num) {
TrackedEntityDataValueStoreImpl eventStore = new TrackedEntityDataValueStoreImpl(d2.databaseAdapter());
int numPersisted = eventStore.countAll();
assertThat(numPersisted, is(num));
}
use of org.hisp.dhis.android.core.trackedentity.TrackedEntityDataValueStoreImpl 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.trackedentity.TrackedEntityDataValueStoreImpl in project dhis2-android-sdk by dhis2.
the class HandlerFactory method createTrackedEntityDataValueHandler.
public static TrackedEntityDataValueHandler createTrackedEntityDataValueHandler(DatabaseAdapter databaseAdapter) {
TrackedEntityDataValueStore trackedEntityDataValueStore = new TrackedEntityDataValueStoreImpl(databaseAdapter);
TrackedEntityDataValueHandler trackedEntityDataValueHandler = new TrackedEntityDataValueHandler(trackedEntityDataValueStore);
return trackedEntityDataValueHandler;
}
use of org.hisp.dhis.android.core.trackedentity.TrackedEntityDataValueStoreImpl in project dhis2-android-sdk by dhis2.
the class EventEndPointCallMockIntegrationShould method getDownloadedEvents.
private List<Event> getDownloadedEvents() {
List<Event> downloadedEvents = new ArrayList<>();
EventStoreImpl eventStore = new EventStoreImpl(databaseAdapter());
List<Event> downloadedEventsWithoutValues = eventStore.querySingleEvents();
TrackedEntityDataValueStoreImpl trackedEntityDataValue = new TrackedEntityDataValueStoreImpl(databaseAdapter());
Map<String, List<TrackedEntityDataValue>> downloadedValues = trackedEntityDataValue.queryTrackedEntityDataValues();
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());
downloadedEvents.add(event);
}
return downloadedEvents;
}
Aggregations