Filter data in Java
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anirudha_Joshi
Posted On:   Monday, August 22, 2005 03:41 PM

am developing a screen on which user can see various details of an Employee. Details includes fields like Name, Date Of birth, Salary etc. Server side code retrieves data for an employee using different data sources. Some fields are retrieved from the database using JDBC while other are retrieved from external system using API calls. Now, application also allows end-user to configure different VIEW filters and end user can apply them while viewing the data. For ex: User can setup a filter as "Show Employee where firstname like 'A' and DOB > '2/2/2000'. Issue is, how do I filter the dataset? If user sets a filter on the attribute which is getting retrieved from JDBC, I can append this filter in the SQL string as   More>>

am developing a screen on which user can see various details of an Employee. Details includes fields like Name, Date Of birth, Salary etc.
Server side code retrieves data for an employee using different data sources. Some fields are retrieved from the database using JDBC while other are retrieved from external system using API calls.

Now, application also allows end-user to configure different VIEW filters and end user can apply them while viewing the data. For ex: User can setup a filter as "Show Employee where firstname like 'A' and DOB > '2/2/2000'.

Issue is, how do I filter the dataset?

If user sets a filter on the attribute which is getting retrieved from JDBC, I can append this filter in the SQL string as WHERE clause (for ex: where emp.first_name like 'A%'). So no issues for SQL fields.

But how do I apply filter criteria which is set on the non SQL attributes?

One of the solution which I tried to implement is converting final dataset into XML and then applying filter using XPATH. But as I understand XPATH can be used only for String and numeric values. It can not be used for dates and filter criteria like "WHERE DEPTNAME IN A, B, C, D).

Any ideas?

   <<Less

Re: Filter data in Java

Posted By:   Anonymous  
Posted On:   Monday, August 29, 2005 08:37 AM

I've encountered a similar situation sometime back. If you look at the situation closely, it boils down to retrieving a set of objects from a collection that match a particular criteria, in other words you want to query a collection. There are atleast 3 possible solutions:


1. Use JoSQL api: This api allows you to query collection of objects using an SQL like syntax. It is neat and elegant.
Read more on this from http://josql.sourceforge.net/


2. Use JXPAth API: This allows you to query a collection using an XPath like syntax. If you are very confortable with XPath, then employ this.


3. Use Functors from the common collections: This is a sort of "Closures" implementation in java. Very neat and maintainable.


I also suggest not to convert the dataset into XML, parse/query it and add performance bottlenecks to ur application.

Re: Filter data in Java

Posted By:   Christopher_Koenigsberg  
Posted On:   Friday, August 26, 2005 09:35 AM

We just had a presentation from Data Direct, and they mentioned they are working on an implementation of "XQJ" which does just what you describe, provide a unified XML DOM view, with XML QUERY capability, of data which behind the scenes may come from multiple relational databases and XML sources.
About | Sitemap | Contact