-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add APIs for local changes #105
Conversation
deepankarb
commented
Aug 18, 2020
- Get all local updates
- Delete all local changes by resource (id, type)
fhirengine/src/main/java/com/google/fhirengine/sync/model/Update.kt
Outdated
Show resolved
Hide resolved
import java.util.Date | ||
import java.util.Locale | ||
|
||
object Util { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need a class for this.
The function can just be a top level extension function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function can be re-used. I copied it from ResourceSynchronizer.kt#100.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it can be reused, just that it doesn't need to be part of a class. You can declare the function outside the class, as a top level extension function
|
||
package com.google.fhirengine.db | ||
|
||
class InvalidLocalChangeException(message: String?) : Exception(message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in file name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix.
* Get a list of all updates | ||
*/ | ||
override fun getUpdates(): List<Update> { | ||
val TEST_INSERT = "{\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that this is just dummy for now, but can we move it to it's own file, so we don't pollute this class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for TEST_UPDATE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Will fix in next commit(s).
@@ -86,6 +91,9 @@ internal abstract class ResourceDao { | |||
@Insert(onConflict = OnConflictStrategy.REPLACE) | |||
abstract fun insertNumberIndex(numberIndexEntity: NumberIndexEntity) | |||
|
|||
@Insert(onConflict = OnConflictStrategy.IGNORE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want to replace the local change if it's already there?
Should this kind of conflict ever happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such a conflict should never happen. It can be avoided by adding the timestamp to the primary key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will change the strategy to ABORT
.
val index = fhirIndexer.index(resource) | ||
updateIndicesForResource(index, entity) | ||
} else { | ||
val topChange = localChanges.last() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't insertResource
called also when we get data from the network?
This means that if something was retrieved from the network after an insert was made, then the network data will also be added to the local changes table.
* Result of squashing local changes of a resource for sync with a remote server. | ||
* [payload] is the body of HTTP request as per https://www.hl7.org/fhir/http.html | ||
*/ | ||
data class Update(val resId: String, val resType: String, val payload: String, val type: Type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add info about all params, please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, sorry. Will do.
* Get all local updates * Delete all local changes by resource (id, type)
* Moved interface for getting updates and deleteing local changes to Database. * Added mock implemetation for sync mechanism development.
* Moved db revision interface * db rev mgmt : insert, update or delete a resoource revsion * db rev merge, squash and diff
16af1a2
to
cdc4e8d
Compare
Implemented in #146 |