question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: introduce the concept of a native DataProvider filter

See original GitHub issue

When I implemented a concrete implementations of Vaadin DataProvider (the JpaDataProvider, the EntityDataProvider and SqlDataProvider data provider implementations) it became clear that those data providers can’t simply accept any type of filters: for example SqlDataProvider can only accept filters that can be turned into valid SQL92 where clauses. Another example would be a JPADataProvider which can only accept JPA Criteria API classes. Neither of those data providers are for example able to accept a String filter (as provided by the ComboBox) since it’s not clear what kind of matching is to be used, and which columns should be matched. Also, nosql data providers will introduce their own set of filters which would be quite incompatible with SQL-based data providers.

I believe it would be useful to introduce a concept of filters that are native to a particular DataProvider implementation:

  • JPADataProvider would only accept JPA Criteria API classes;
  • SqlDataProvider would introduce its own set of filters it accepts
  • MongodbDataProvider would introduce its own set of filters it accepts
  • ListDataProvider accepts a SerializablePredicate<T> as its filter
  • An app-proprietary RestDataProvider using proprietary set of filters to fetch data

It would make no sense to try to convert Mongodb filters into SqlDataProvider and vice versa, therefore there should be no such support from the DataProvider.

Originally it was believed that, given a proper converter, a DataProvider could be able to use foreign filters (for example filters produced by Vaadin components - ComboBox provides search text as typed in by the user as String). However, it is not clear how to match String against a SQL table or a JPA entity. Also, the matching may tend to differ for different usage scenarios: say, one ComboBox shows entity Person while another shows entity Address and both of those entities are produced by the JPADataProvider.

That’s why ComboBox employs call-site filter conversion: it implements (Vaadin8) HasFilterableDataProvider.setDataProvider(DataProvider, SerializableFunction) and requires the user to provide a proper String->F converter for every ComboBox.

I would therefore propose to introduce the concept of native filters into the DataProvider javadoc. This will allow us to rewrite DataProvider.withConfigurableFilter() to only combine filters of type F and produce a filter of type F. That would make the function way simpler to use since it will use two generic parameters instead of four. This would also make the filter conversion in DataProvider unnecessary.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
Legiothcommented, Jun 1, 2018

If the withConvertedFilter() method would be dropped, it would mean that the UI logic that e.g. configures a ComboBox would also have to be concerned with backend technologies such as JPA. This would to some degree be against the separation of concerns that many architectures try to maintain.

By having both DataProvider.withConvertedFilter(SerializableFunction) and HasFilterableDataProvider.setDataProvider(DataProvider, SerializableFunction), the application developer can choose in which part of the code they want to do the conversion.

0reactions
mvysnycommented, Jun 4, 2018

I see your point. It seems that the API is hitting Java limitations and can’t be done in a clean and simple manner. We would need extension methods to introduce withFilter() methods for particular filter types only (e.g. fun <T> DataProvider<T, JPAFilter>.withFilter(...)), but that’s Kotlin-only. I guess there is nothing more we can do, please feel free to close this issue as won’t fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

To view and filter the data in a data provider
You can filter data in a data provider based on the values you specify. Open a Web Intelligence document in ... Select Custom...
Read more >
Index - Advantage Database Server
NET Data Provider ... 3105 Unsupported data type value in record filter expression ... 7205 Cannot establish a connection to the Advantage SQL...
Read more >
Virtual Dataverse tables with no code, via Connectors
I can create a personal view “products currently sold” that filters out all products with a value in SellEndDate field. I can sort...
Read more >
JUnit 5 User Guide
Tags are a JUnit Platform concept for marking and filtering tests. The programming model for adding tags to containers and tests is defined...
Read more >
OnBase Certified Admin Handbook
discuss and get ideas/feedback from other admins. ... OnBase Keyword Types & Options per Document Type and filter by the.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found