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

Add ability for for clients to provide their own instance parsing #756

Merged
merged 3 commits into from
Apr 26, 2024

Conversation

seadowg
Copy link
Member

@seadowg seadowg commented Apr 11, 2024

Work towards getodk/collect#6029

This adds a new FilterInstanceParser interface that is now used by GeoJsonExternalInstance and CsvExternalInstance and allows clients to add their own implementations.

What has been done to verify that this works as intended?

Verified with a spike in Collect.

Why is this the best possible solution? Were any other approaches considered?

I tired using an "interceptor"/"preprocessor" approach, but then realised that the way we parse CSV and GeoJSON files is already a "chain" of parsers so formalising that made the most sense.

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?

Shouldn't change behaviour - it adds the ability for clients to change behaviour from their side.

@seadowg seadowg marked this pull request as ready for review April 25, 2024 13:51
@seadowg seadowg requested a review from lognaturel April 25, 2024 13:51
fileInstanceParsers = Stream.concat(
Stream.of(fileInstanceParser),
fileInstanceParsers.stream()
).collect(Collectors.toList());
Copy link
Member

Choose a reason for hiding this comment

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

This got a little bit of an eyebrow raise from me. 😅 Is it taking a streaming approach too far? Do you want to avoid fileInstanceParsers.add(0, fileInstanceParser) to avoid direct mutation? Is it substantively different here? Is it to be consistent with other stream-based list processing?

I don't feel strongly but wanted to share my eyebrow raise.

Copy link
Member Author

@seadowg seadowg Apr 26, 2024

Choose a reason for hiding this comment

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

It's "completely forgetting about add(0, fileInstanceParser) and trying to just append two lists". Remember we don't have to deal with any of this insanity in Collect any longer!

Copy link
Member Author

@seadowg seadowg Apr 26, 2024

Choose a reason for hiding this comment

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

Derp. Can't do that because it's an immutable list. I already merged 🤦‍♂️. Sigh.

@lognaturel
Copy link
Member

Looks good! Feel free to merge after taking or leaving my one comment!

@seadowg seadowg force-pushed the instance-interceptor branch from c4acf68 to ef7afa4 Compare April 26, 2024 11:45
@seadowg seadowg merged commit 8908e4a into getodk:master Apr 26, 2024
3 checks passed
@seadowg seadowg deleted the instance-interceptor branch April 26, 2024 11:49
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.

2 participants