-
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
Proposal for #4059 First nested repeat not created… #4797
Conversation
Incidentally, being well aware there's a lot going on with Collect at the moment, I'm not expecting review of my offerings anytime soon. When someone does have time to look at them, can I suggest in the following order?
|
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 looks like quality checks are failing and need fixed before we look at this. Running ./gradlew checkCode
(or gradlew.bat checkCode
) will show the report locally.
All checks* seemed ok at my end, but I'll run them again and update as required. * Except of course for the thirty or so PMD fails in the cloned Javarosa code (and another thirty from circleci Checkstyle) . Now updated these - with some misgivings as not my code. Which reminds me that of course there's no way I'd want these commits merged. |
Marking this as a draft seeing as it's a set of changes for JavaRosa rather than Collect. |
@dimwight what errors are you seeing building JavaRosa on your machine? It'd be good to make sure JavaRosa development can happen on Windows as well as *nix. |
As mentioned above,
Unlike in Collect's separate |
@dimwight I'm wondering if there is a way we could get CheckStyle running on Windows rather than avoiding. What exact error/failure are you seeing? |
There's no problem running it, it just fails every time on Windows line endings. |
@dimwight is that on a clean check out or only once you've added/changed code? I'm wondering if there is an editor setting that can sort this out. |
To be exact,
All the errors are To my eye the most straightforward solution would be to omit Checkstyle from the Javarosa |
Further update. Woke up this morning and decided to try the brute force solution of fixing by hand each of the eighteen files complained of by However Is there anyone on the Javarosa team I could raise this with, who's an expert on the build files? |
@dimwight my best guess here is that git is checking out files with Windows line endings. To make your Git config more Unix friendly (probably a good idea for working with any open source project) you can set Thanks for soldiering through the horrible Unix/Windows incompatibilities! |
Sounds promising, even if it means I have to bite the bullet on the Git CLI. |
@dimwight if you're using SourceTree, you can hit "Settings" (top right) then "Advanced" and then "Edit Config File..." to change the Git config being used. That way you can stay away from the CLI I think! |
Thanks @seadowg for these suggestions. They were very helpful in that they put me on the right track, though the actual anwer came out different. On looking
So this makes no promises about working files which are what Checkstyle was failing on. But on the same page is the following:
This seemed much more promising and indeed does the trick. So now I was ready to close this PR with thanks for your assistance, except that as a next stage I wanted to test my updated Javarosa code in Collect. Unfortunately these instructions tripped me up at step 2 with the issue described here. In the absence of any error message it does seem likely that I need to prepare my Javarosa folder somehow before trying to import into Collect. Any thoughts? |
I had a thought - switch to the instructions for building a jar and referencing it in Collect. I built my jar, but didn't succeed in setting the path.
|
Looks like our instructions are out of date, and you should use |
Closing this. If you have run into any more problems, then please post in #javarosa-code or #collect-code on Slack. |
Proposal for resolving #4059
This is very much a draft PR since it's on the wrong repository. I tried forking Javarosa but can't build it due to Checkstyle's dislike of Windows line endings.
As a workaround I cloned to Collect the classes that seem to need attention, then committed my proposed changes on top of them. This approach has the merit of being testable within Collect more or less as described in #4059.
The issue
Logging the state of the form instance shows that the crucial code is indeed in Javarosa. The initial instance tree is created with its nested repeat(s), but subsequent repeats are not.
Stepping through creation of a repeat shows that in the template tree acquired in
FormDef.createNewRepeat
the root has the right descendants.However when called via
FormInstance.copyNode
,TreeElement.deepCopy
fails to copy these because their multiplicity isINDEX_TEMPLATE
ie -2; even if it did copy them their multiplicities would stop them being indexable.The fix
The obvious solution is to clone the template tree and set multiplicities to
DEFAULT_MULTIPLICITY
ie 0: this will be correct for nested repeats and the appropriate value for the repeat root is set incopyNode
.Both
copyNode
anddeepCopy
have multiple call sites, so modifying either will most likely (certainly?) result in regression.However in
createNewRepeat
we can pass tocopyNode
a clone of the template with adjusted multiplicities, created using an analogue inTreeElement
ofdeepCopy
. (The subsequent copying incopyNode
will then be harmlessly redundant.)This small change has the desired effect and should be safe from regression.
The code
As noted above
Testing
NestedRepeatTest
loads the form specified inNestedRepeats.xlsx, incidentally demonstrating that the fix works for at least one further level of nesting.