Skip to content

Commit

Permalink
Add API access for data in the LocalChangeEntity table
Browse files Browse the repository at this point in the history
  • Loading branch information
ndegwamartin committed Sep 24, 2024
1 parent 8301d62 commit ad7e1c4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions engine/src/main/java/com/google/android/fhir/FhirEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ interface FhirEngine {
*/
suspend fun getLocalChanges(type: ResourceType, id: String): List<LocalChange>

suspend fun getUnsyncedLocalChanges(): List<LocalChange>

/**
* Purges a resource from the database without deleting data from the server.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ internal class FhirEngineImpl(private val database: Database, private val contex
override suspend fun getLocalChanges(type: ResourceType, id: String) =
withContext(Dispatchers.IO) { database.getLocalChanges(type, id) }

override suspend fun getUnsyncedLocalChanges(): List<LocalChange> = database.getAllLocalChanges()

override suspend fun purge(type: ResourceType, id: String, forcePurge: Boolean) =
withContext(Dispatchers.IO) { database.purge(type, setOf(id), forcePurge) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ internal object TestFhirEngineImpl : FhirEngine {
)
}

override suspend fun getUnsyncedLocalChanges(): List<LocalChange> = listOf()

override suspend fun purge(type: ResourceType, id: String, forcePurge: Boolean) {}

override suspend fun purge(type: ResourceType, ids: Set<String>, forcePurge: Boolean) {}
Expand Down

0 comments on commit ad7e1c4

Please sign in to comment.