Skip to content
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

Implement Feature and Record local db entities and DAOs (#19) #41

Merged
merged 16 commits into from
Apr 11, 2019

Conversation

gino-m
Copy link
Collaborator

@gino-m gino-m commented Mar 29, 2019

Sharing an early draft for discussion based on reversable edits instead of rollback snapshots. Once we've agreed on the final sync algorithm design I'll update this to reflect our discussions.

@gino-m gino-m changed the title Initial draft of local db entities and DAOs (#19) Add local db entities and DAOs (#19) Mar 31, 2019
@gino-m gino-m changed the title Add local db entities and DAOs (#19) Implement local db entities and DAOs (#19) Mar 31, 2019
@gino-m gino-m marked this pull request as ready for review March 31, 2019 16:18
@gino-m
Copy link
Collaborator Author

gino-m commented Mar 31, 2019

Sorry the PR is already getting pretty big. Could you kindly review and pull into offline-sync branch?

The main TODO left from this PR is to implement Record values serialization, which I'll implement using JSON for easy debuggability.

Note that this PR only includes DAOs for Feature and Record entities and edits, and not the local cache of Projects. For now the user will need a connection to join the project; the ability to join/leave projects offline shouldn't block testing offline sync for Features and Records though.

@gino-m gino-m changed the title Implement local db entities and DAOs (#19) Implement Feature and Record local db entities and DAOs (#19) Mar 31, 2019
public String key;

// TODO: Add Converter to convert to/from JSON.
@Ignore @Nullable public Value oldValue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't the Value fields specific to record edits? Why put them on the shared Edit instead of RecordEditEntity?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to use the same mechanism to represent edits on Features and Records to a) allow code sharing and b) to facilitate adding custom attributes to Features and/or pre-defined attributes to Record in the future.

I've removed Value from the db persistence as per our other discussions and using a generic representation analogous to Firestore (JSON) for key-value pairs of changed values. Wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, using the JSON means that each edit would store the entire state of the feature or record, right? Instead of just storing the values for the particular key that is to be updated. That could make merging logic trickier if we ever need to support concurrent modifications -- it isn't as clear to see which keys were explicitly modified in this edit, so we might need to overwrite the entire feature state (including keys that the user didn't explicitly set when creating the edit).

We might have discussed this issue before, but I don't remember what we decided :).

@gino-m
Copy link
Collaborator Author

gino-m commented Apr 6, 2019

Responses and six new commits. PTAL!

@gino-m
Copy link
Collaborator Author

gino-m commented Apr 7, 2019

@navinsivakumar Also, in what packages should these classes go? The remote data service interface is in c.g.a.gnd.service.RemoteDataService, with implementation in c.g.a.gnd.service.firestore. Shall we create interface c.g.a.gnd.service.LocalDataService and put impl in c.g.a.service.room as well?

Copy link
Contributor

@navinsivakumar navinsivakumar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gino-m packages sound good -- data model in c.g.a.gnd.repository.local, LocalDataService in gnd.service with implementation in its own subpackage.

public String key;

// TODO: Add Converter to convert to/from JSON.
@Ignore @Nullable public Value oldValue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, using the JSON means that each edit would store the entire state of the feature or record, right? Instead of just storing the values for the particular key that is to be updated. That could make merging logic trickier if we ever need to support concurrent modifications -- it isn't as clear to see which keys were explicitly modified in this edit, so we might need to overwrite the entire feature state (including keys that the user didn't explicitly set when creating the edit).

We might have discussed this issue before, but I don't remember what we decided :).

@navinsivakumar navinsivakumar merged commit 8cc03fa into google:offline-sync Apr 11, 2019
@gino-m gino-m deleted the db-setup branch June 29, 2019 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants