performing dynamic post query filters on resultset

0

using Jasper Reports 5.6.1

We have a report in two formats: CSV and PDF.  We have a new requirement which requires scanning a specified field (input param) for invalid values configured in CSV files.  We cannot create/populate RDBMS tables instead of using CSV files due to usage of regex for invalid filter patterns/values.

We have the need to apply two dynamic filters for this requirement:

1) remove all rows from detail band which have invalid SSNs, for example

2) if as a result of application of filter 1 above, there is only one row remaining for the grouping for the detail band, then remove that row as well (the report compares values and for comparison we need minimum 2 rows in detail band per grouping)

We cannot simply hardcode invalid values in SQL and use NOT IN clause, etc. as the invalid values list in CSV may change in the future.

Currently solving by using a scriptlet which is invoked from detail band's printWhenExpression.  This invokes a method in the scriptlet for every row in detail bands (thousands or millions of invocations depending on amount of data returned by report's SQL query).  If the row needs to be removed/excluded, method returns true, otherwise false.

Experimenting with other overridden methods in scriptlet which extends JRDefaultScriptlet like beforeReportInit().  Goal is to see if I can apply the secondary filter (#2 above) in one of these overridden methods.

Issue I'm having is I don't know how to remove rows in detail band, remove detail band itself completely, or remove group in the Jasper report programmatically from the scriptlet/class which extends JRDefaultScriptlet.  I don't see any examples of how/why/when to use the APIs like beforeReportInit(), etc.  Is it possible to achieve this and how?  Also concerned about performance degradation as a result.  thx.

I don't see any examples in this Scriptlet sample blog regarding "It is within these methods you will place your own logic to manipulate data in the report. "

Also, the Scriptlet.java file is not available/attached at below link apparently.  I have yet to see/find an example which shows dataset manipulation in a scriptlet in Jasper.

Reference: http://jasperreports.sourceforge.net/sample.reference/scriptlet/

asookazian@gmail.com's picture
Joined: Apr 19 2010 - 1:58pm
Last seen: 4 months 2 weeks ago

0 Answers:

No answers yet
Feedback