-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix reading form metadata in forms containing multiple meta sections #7141
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
5 commits
Select commit
Hold shift + click to select a range
e2b0a6e
Add a failing test
grzesiek2010 3431f99
Use the top-level meta block to read metadata
grzesiek2010 cb61789
Remove redundant code
grzesiek2010 34d6ff3
Improve variable names
grzesiek2010 03b73ff
Convert InstanceMetadata to kotlin
grzesiek2010 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
24 changes: 0 additions & 24 deletions
24
collect_app/src/main/java/org/odk/collect/android/javarosawrapper/InstanceMetadata.java
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
collect_app/src/main/java/org/odk/collect/android/javarosawrapper/InstanceMetadata.kt
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,12 @@ | ||
| package org.odk.collect.android.javarosawrapper | ||
|
|
||
| import org.odk.collect.android.formentry.audit.AuditConfig | ||
| import org.odk.collect.android.utilities.FormNameUtils | ||
|
|
||
| data class InstanceMetadata( | ||
| @JvmField val instanceId: String?, | ||
| private val rawInstanceName: String?, | ||
| @JvmField val auditConfig: AuditConfig? | ||
| ) { | ||
| @JvmField val instanceName: String? = FormNameUtils.normalizeFormName(rawInstanceName, false) | ||
| } |
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
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.
Was this needed here in any way? I can’t really imagine a use case, but maybe I’m missing something.
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.
To make the change here very explicit, Collect previously allowed the "meta block" to be defined anywhere within the primary instance. This PR changes that so that it's only supported if it is a direct child of the primary instance. Is that your understanding @grzesiek2010?
As far as I can see, the spec is actually a little ambiguous on where the meta block should live. All the examples show it as a direct child, but that requirement isn't really stated explicitly. The closes we get to that is probably:
"contains" isn't really specific enough to make this change, but I suspect the intention in the spec is that the meta block should be a direct child. I'd like to get second opinions from @lindsay-stevens or @lognaturel.
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.
Kind of, I mean yes, and that's why I got rid of
findDepthFirstfunction, but here the question was more about usingSubmissionProfile. Whether it was needed for something or not.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 PR is not the first where we assume the main meta block (with
instanceId,instanceName,audit) is the direct child, see:https://github.com/getodk/collect/blob/master/collect_app/src/main/java/org/odk/collect/android/formmanagement/finalization/EditedFormFinalizationProcessor.kt#L23
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.
Good point! Ok so if there is a problem with that, it will already exist. I'd still like to hear from others (so we can at least make the spec clearer), but this is good to go.
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.
Very interesting, I'd never noticed that ambiguity. I assume the original intent was indeed the direct
metachild, that's certainly an important assumption for the whole way the multiple Entity declaration spec works. I think we should make the spec more specific.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 pyxform is currently doing as expected but I've filed XLSForm/pyxform#831 to improve test coverage. The spec examples show the main meta element being a child of the primary data instance root element (usually
data), but it wouldn't hurt to also say that in the text, and perhaps also that any other meta elements (expected for entities) must only have entities in them (thoughmetaisn't currently a reserved name so that might be a stretch).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.
Great! I can get a PR up for the spec then.