PersistenceService class
The PersistenceService class is a singleton which handles persistence of study runtime information to a SQLite database on the phone. Used to store information across app re-start on:
- Running studies on the phone as managed by the SmartphoneClientRepository
- User tasks on the task queue as managed by the AppTaskController
Studies are stored in the studies table and user tasks are stored
in the task_queue table.
The path and filename format for the database is
~/carp.db
where ~ is the folder where SQLite places it database files.
On iOS, this is the NSDocumentsDirectory and the files can be accessed via
the MacOS Finder.
On Android, Flutter files are stored in the databases directory, which is
located in the data/data/<package_name>/databases/ folder.
Files can be accessed via AndroidStudio.
Constructors
- PersistenceService()
-
Get the singleton persistence layer.
factory
Properties
- databaseName → String
-
Full path and name of the database.
no setter
- databasePath → String
-
Path of the database.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) → Future< void> - Close the persistence layer. After close is called, no deployment can be accessed or saved.
-
getAllStudies(
) → Future< List< SmartphoneStudy> > - Get the list of all studies previously stored on this phone.
-
getStudy(
String studyDeploymentId, String deviceRoleName) → Future< SmartphoneStudy?> -
Return the SmartphoneStudy with
studyDeploymentIdanddeviceRoleName, or null when no such study is found. -
getUserTasks(
[SmartphoneStudy? study]) → Future< List< UserTaskSnapshot> > -
Get the list of UserTaskSnapshot for
study. Ifstudyis null, all user tasks are returned. -
init(
) → Future< void> - Initialize the persistence layer and the database.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeStudy(
Study< PrimaryDeviceDeployment> study) → Future<void> -
Remove the
studyfrom local cache. -
removeUserTasks(
[Study< PrimaryDeviceDeployment> ? study]) → Future<void> -
Remove the list of user tasks for
study. Ifstudyis null, all user tasks are removed. -
saveStudy(
SmartphoneStudy study) → Future< bool> -
Save the
studypersistently to a local cache. Returns true if successful. -
saveUserTask(
UserTask task) → Future< void> - Update or delete a task queue entry.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateStudy(
SmartphoneStudy study) → Future< bool> -
Update the
studypersistently to a local cache. Returns true if successful.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- CREATED_ON_COLUMN → const String
- DATABASE_NAME → const String
- DEPLOYED_ON_COLUMN → const String
- DEPLOYMENT_COLUMN → const String
- DEPLOYMENT_STATUS_COLUMN → const String
- DEVICE_ROLE_NAME_COLUMN → const String
- ID_COLUMN → const String
- PARTICIPANT_ID_COLUMN → const String
- PARTICIPANT_ROLE_NAME_COLUMN → const String
- SAMPLING_STATUS_COLUMN → const String
- STUDY_DEPLOYMENT_ID_COLUMN → const String
- STUDY_ID_COLUMN → const String
- STUDY_TABLE_NAME → const String
- TASK_COLUMN → const String
- TASK_ID_COLUMN → const String
- TASK_QUEUE_TABLE_NAME → const String
- UPDATED_ON_COLUMN → const String