-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Store shared entities for follow up forms #6108
Conversation
Property merging is handled by EntitiesRepository
.clickRefresh() | ||
.clickOnForm("One Question Entity Update") | ||
.clickGetBlankForm() | ||
.clickClearAll() |
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.
Why those forms are both selected here? one-question-entity-update.xml
is already downloaded here so you shouldn't need to click Clear all
and select one-question-entity-follow-up.xml
.
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 want to specifically download 'one-question-entity-follow-up.xmlso that I check that downloading
updated-people.csv` updates the list. I guess a potentially simpler way to test this is to just download both forms at once and check they have the same list, but I'd prefer to test the extreme case here: forms being downloaded individually with different entity lists. Does that make sense?
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.
Yes, it makes sense but my question was about something else. Once you download the first form and open the list of forms to download again the one you already have should be unselected by default. It seems like both are selected as if the first one was removed or not downloaded at all yet. You shouldn't need to click the clear button and then select that form because the form you want to download should be the only one selected.
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.
Ah got you! I think I'd still prefer the "clear all" to make it explicit I'm selecting that form.
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.
Ah got you!
No, I think you don't. Please run that test entityListSecondaryInstancesAreConsistentBetweenFollowUpForms
and add a breakpoint in line 126
before you call clearAll()
. I was asking if it's a bug that both forms are selected by default after opening the list of forms to download when one of them is already downloaded (line 119).
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.
Sorry! That'll be the brain fog last week. I see what you mean: it's weird that both forms are selected. I'm guessing this is a problem with StubOpenRosaServer
rather an actual bug, but I'll look into it.
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.
Yeah it's because StubOpenRosaServer
uses the file path as the form ID for the form list, whereas Collect doesn't trust the server and parses it out of the form itself. That means we end up in a scenario where the form gets downloaded and saved with the ID in the XML, but the server is still using the "fake form ID". I've fixed it so that StubOpenRosaServer
will parse the form ID out of the XForm if it's not given an explicit form ID.
entities/src/main/java/org/odk/collect/entities/AddEntityListDialogFragment.kt
Outdated
Show resolved
Hide resolved
) { | ||
formController.finalizeForm() | ||
formController.getEntities().forEach { entity -> | ||
if (entitiesRepository.getDatasets().contains(entity.dataset)) { |
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.
Wouldn't it be better to check this on a repository level? I mean always call save but in save verify if the dataset exists.
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'm tempted by that. I think the restriction of needing to have declared an entity list is probably temporary though. Later, you'll be able to have a registration form without any follow up forms and have entities created locally for that (that are only available via a browser). @lognaturel does that sound correct?
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 don't want to block you because I will be off till the end of this week. It seems to be the last thing to fix but you can do that later.
collect_app/src/test/java/org/odk/collect/android/formmanagement/ServerFormUseCasesTest.kt
Outdated
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/formmanagement/ServerFormUseCases.kt
Show resolved
Hide resolved
entities/src/main/java/org/odk/collect/entities/LocalEntityUseCases.kt
Outdated
Show resolved
Hide resolved
entities/src/test/java/org/odk/collect/entities/LocalEntitiesFileInstanceParserTest.kt
Outdated
Show resolved
Hide resolved
.around(rule) | ||
|
||
@Test | ||
fun canViewLocallyCreatedEntitiesInBrowser() { |
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 we started using different names... online and offline entities are I think the clearest options but here we have local entities
. The test title below is also not clear it's about online entities.
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.
The reason I ended up using local is because we know store both the "offline" and "online" entities in one place ("local"), but can create or update them locally (rather than those creates/updates coming from the server). It's definitely got me a little twisted up. Do you think we should use "offline" here?
I reckon this will become easier again with #6011, as we'll need to start tracking if local entities are "offline" or "online" so we know whether to delete them or not if they're not in the "online" lists any longer.
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.
It can be local
instead of offline
(maybe it's even better) but it would require reviewing the code and fixing other occurrences of offline
.
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.
Could we leave this for #6011? I think, it'll be best to consolidate the naming there.
@@ -21,15 +22,20 @@ class EntityFormTest { | |||
.around(rule) | |||
|
|||
@Test | |||
fun fillingEntityRegistrationForm_createsEntityInTheBrowser() { | |||
fun fillingEntityRegistrationForm_beforeCreatingEntityList_doesNotCreateEntityForFollowUpForms() { |
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.
This title sounds confusing to me similar to #6108 (comment)
I'm not sure what CreatingEntityList
means. First, you create local entities using the registration form and then you open a form that has online entities. So CreatingEntityList
means opening a form with online entities?
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.
You "create an entity list" in the browser using the "Add entity list" flow. Does that make sense or do you think it needs updated?
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.
You "create an entity list" in the browser using the "Add entity list" flow.
But you don't do that here?
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.
But you don't do that here?
Right. That's the "beforeCreatingEntityList" part. I'm testing that we don't create entities if we haven't manually created an entity list yet.
collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/EntityFormTest.kt
Outdated
Show resolved
Hide resolved
|
||
<!-- Text for button that deletes all entities for the project --> | ||
<string name="clear_entities">Clear all</string> | ||
|
||
<!-- Text for button that adds a new entity list --> | ||
<string name="add_entity_list">Add entity list</string> |
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.
Entity list is the same as dataset right? Here the naming is also confusing.
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.
That was a change in terminology that's happened since we added the first entity code to Collect. The spec now states:
In this specification, collections of Entities are referred to as Datasets. The term “Entity List” is generally recommended instead of “Dataset” in text that is intended for users rather than developers.
We could just call them "entity lists" everywhere in Collect and avoid "datasets" entirely?
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.
Yeah, it would be better to use consistent naming.
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.
Again, I think we should consolidate this in #6011. Agreed that we want to use "entity list" everywhere instead of data sets though.
I'm not able to reproduce. Do you have more specific steps? |
I'm just adding 2 entity lists in the |
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.
There is a couple of new comments.
Closes #6029
Blocked by getodk/javarosa#756The big change here is that we now combine the server's entity list with locally created entities when downloading a form (or update). The
EntitiesRepository
is then used to create the secondary instance used in follow up forms (and the actual CSV is ignored).As the issue mentions, the big caveat here is that you have to manually create the entity list via the entity browser (in experimental settings) to get anything working. In the future, this will likely not have to happen as which media files are entity lists will hopefully be flagged to us by the server.
Something else to point out here is that all entities (including the ones from the server) will be visible in the entity browser now. I could have filtered the "online" ones out, but it felt more useful to see them all anyway.
Why is this the best possible solution? Were any other approaches considered?
The approach here was discussed in the issue.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
This should only affect users with entity forms and only in the cases where they have manually added an entity list via experimental settings (Settings > Experimental > View entity lists > Options menu > Add entity list). As the issue points out, it's pretty hard to simulate the problems solved here without using manual form management (as match exactly will download all updates at once).
Do we need any specific form for testing your changes? If so, please attach one.
It'd be a good idea to test entity forms including create forms, update forms and follow up forms.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest
(or./gradlew testLab
) and confirmed all checks still pass