-
-
Notifications
You must be signed in to change notification settings - Fork 45
Adds support for last_sync attribute for Indexed Fixtures #2085
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e016043
Adds last_sync col to Indexed fixture index table
shubham1g5 36ef3bb
last sync parsing
shubham1g5 520e678
Adds last sync in projection
shubham1g5 faf96c6
Supports all kinds of attributes on indexed fixtures
shubham1g5 d33e45c
Moved the index fixture constants back to core, code cleaup
shubham1g5 b3e7d95
Cleanup
shubham1g5 6051707
Lazily deserializes indexed fixture attributes
shubham1g5 4563659
minor cleanup
shubham1g5 fc52d3d
Adds test for index fixture root attribute lookup
shubham1g5 4829cc9
Creates Android instance initializer with right test sandbox
shubham1g5 62e5a8e
Better constructors
shubham1g5 66dac55
Corrects xpath instance
shubham1g5 6a18511
Makes loadAttributes synchronized, better error
shubham1g5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
app/src/org/commcare/engine/cases/AndroidIndexedFixtureInstanceTreeElement.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| package org.commcare.engine.cases; | ||
|
|
||
| import org.commcare.cases.instance.IndexedFixtureInstanceTreeElement; | ||
| import org.commcare.cases.model.StorageIndexedTreeElementModel; | ||
| import org.commcare.core.interfaces.UserSandbox; | ||
| import org.commcare.utils.SerializationUtil; | ||
| import org.javarosa.core.model.IndexedFixtureIdentifier; | ||
| import org.javarosa.core.model.instance.AbstractTreeElement; | ||
| import org.javarosa.core.model.instance.InstanceBase; | ||
| import org.javarosa.core.model.instance.TreeElement; | ||
| import org.javarosa.core.services.storage.IStorageUtilityIndexed; | ||
| import org.javarosa.core.util.externalizable.DeserializationException; | ||
|
|
||
| /** | ||
| * The root element for an indexed fixture data instance | ||
| * with support for attributes lookup | ||
| */ | ||
|
|
||
| public class AndroidIndexedFixtureInstanceTreeElement extends IndexedFixtureInstanceTreeElement { | ||
|
|
||
| private TreeElement attributes; | ||
|
|
||
| public AndroidIndexedFixtureInstanceTreeElement(AbstractTreeElement instanceRoot, | ||
| IStorageUtilityIndexed<StorageIndexedTreeElementModel> storage, | ||
| IndexedFixtureIdentifier indexedFixtureIdentifier) { | ||
| super(instanceRoot, storage, indexedFixtureIdentifier); | ||
| } | ||
|
|
||
| public static IndexedFixtureInstanceTreeElement get(UserSandbox sandbox, | ||
| String instanceName, | ||
| InstanceBase instanceBase) { | ||
| IndexedFixtureIdentifier indexedFixtureIdentifier = sandbox.getIndexedFixtureIdentifier(instanceName); | ||
| if (indexedFixtureIdentifier == null) { | ||
| return null; | ||
| } else { | ||
| IStorageUtilityIndexed<StorageIndexedTreeElementModel> storage = | ||
| sandbox.getIndexedFixtureStorage(instanceName); | ||
| return new AndroidIndexedFixtureInstanceTreeElement(instanceBase, storage, indexedFixtureIdentifier); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public int getAttributeCount() { | ||
| return loadAttributes().getAttributeCount(); | ||
| } | ||
|
|
||
| @Override | ||
| public String getAttributeNamespace(int index) { | ||
| return loadAttributes().getAttributeNamespace(index); | ||
| } | ||
|
|
||
| @Override | ||
| public String getAttributeName(int index) { | ||
| return loadAttributes().getAttributeName(index); | ||
| } | ||
|
|
||
| @Override | ||
| public String getAttributeValue(int index) { | ||
| return loadAttributes().getAttributeValue(index); | ||
| } | ||
|
|
||
| @Override | ||
| public AbstractTreeElement getAttribute(String namespace, String name) { | ||
| TreeElement attr = loadAttributes().getAttribute(namespace, name); | ||
| attr.setParent(this); | ||
| return attr; | ||
| } | ||
|
|
||
| @Override | ||
| public String getAttributeValue(String namespace, String name) { | ||
| return loadAttributes().getAttributeValue(namespace, name); | ||
| } | ||
|
|
||
| private synchronized TreeElement loadAttributes() { | ||
| if (attributes == null) { | ||
| try { | ||
| attributes = SerializationUtil.deserialize(attrHolder, TreeElement.class); | ||
| } catch (Exception e) { | ||
| if (e.getCause() instanceof DeserializationException) { | ||
| String newMessage = "Deserialization failed for indexed fixture root atrribute wrapper: " + e.getMessage(); | ||
| throw new RuntimeException(newMessage); | ||
| } | ||
| } | ||
| } | ||
| return attributes; | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@shubham1g5 We should make sure that we've also implemented anything we need to implement here for Formplayer.
This may require, for example, require us to bump the version DB (which requires us to clear out Incomplete Forms).
Unrelated to this PR structure, but useful for us to know whether we need to update the Formplayer DB Version # with the next commcare-core pull in that library before merging this one (let me know if this comment doesn't make sense).