Page 1 of 2

Mods to Jasper Plugin for Foundsets?

PostPosted: Mon May 11, 2009 6:02 pm
by Kahuna
After some chatter (admitedly started by me :oops: ) Patrick Talbot put quite a bit of effort into modifying the Jasper Plugin code (from the open source).

It seems his work allows the plugin to now use the Servoy foundset rather than having to recode the entire foundset SQL (which may be made up of multiple tableFilterParams in my case) in Jasper plugin call.

I think Patrick has offered to make this available to whoever is managing the Jasper Plugin on behalf of Servoy as per this thread:

viewtopic.php?f=15&t=12247

From a Servoy aspect It seems this would be a good thing, and only enhance the way Servoy can apply the Jasper Plugin. From a user viewpoint - having the Servoy stamp on it offers a comfort factor - and may result in even more enhancement of the plugin.

I recognise its extra work but is there any likelihood that someone from Servoy would take this work on-board on behalf of the user base?

Re: Mods to Jasper Plugin for Foundsets?

PostPosted: Mon May 11, 2009 11:46 pm
by IT2Be
I think this: http://code.google.com/p/servoy-jasperr ... Guidelines will help him/you to commit the changes to the group.

Re: Mods to Jasper Plugin for Foundsets?

PostPosted: Tue May 12, 2009 4:36 am
by ptalbot
IT2Be wrote:I think this: http://code.google.com/p/servoy-jasperr ... Guidelines will help him/you to commit the changes to the group.


I followed the guidelines and tried to be as unobstrusive as possible :
- there's only 2 method added to the IJasperReportsService interface, implemented in the JasperReportsServer class,
- of course, to avoid making dumb copy of he methods I had to do a little bit of refactoring to make my new methods use the same code as the one using the dbalias String,
- same thing for the JasperReportsProvider class, the patch is much bigger than expected because it didn't recongize the code in the refactored method, but there isn't much changed, really.

So since I am still unsure to whom I should submit this patch, you (and others) can find it attached.

Re: Mods to Jasper Plugin for Foundsets?

PostPosted: Tue May 12, 2009 10:07 am
by rgansevles
Patrick,

Can you show an example of a servoy method that uses this patched plugin?

I see you are collecting all data needed for the report and you are sending that to the server part of the plugin where the report is filled with this data.
I wonder how you determine which fields are required for the report.

Does this also support a report with grouping?
For instance a department report with the employees listed:

-- Sales
---- Anne
---- John
-- Marketing
---- Chris
---- Ellen

Rob

Re: Mods to Jasper Plugin for Foundsets?

PostPosted: Tue May 12, 2009 4:06 pm
by ptalbot
rgansevles wrote:Patrick,

Can you show an example of a servoy method that uses this patched plugin?

I see you are collecting all data needed for the report and you are sending that to the server part of the plugin where the report is filled with this data.
I wonder how you determine which fields are required for the report.

Does this also support a report with grouping?
For instance a department report with the employees listed:

-- Sales
---- Anne
---- John
-- Marketing
---- Chris
---- Ellen

Rob


Hi Rob,

While reviewing the sample solution below, I just noticed a problem with the patch I submitted yesterday (it was running late, so I didn't see this one, sorry), you will find a new version attached, but if you prefer you can edit, in the JasperReportsProvider.java file, the lines 375,376:
Code: Select all
           } else if (obj instanceof SerializableTableModel) {
              model = (SerializableTableModel)obj;

should read:
Code: Select all
           } else if (obj instanceof TableModel) {
              model = new SerializableTableModel((TableModel)obj);


About your question: in the attached archive, you will find a very simple solution based on the "udm" sample database. This solution contains one method demonstrating the use of my patched version. You will also find the jasper report (compiled for jasper 3.0.0 and along with the source), that should show you how I achieved grouping in the report.

Basically, I first convert my foundset to a dataset with convertToDataSet(foundset, array), where the array contains the field I want to retrieve (also works with related fields), then convert this dataset to a TableModel, using dataset.getAsTableModel(), then call the plugin with this dataset. There really is only 3 lines of significant code.

On the jasper report side, you will see that I have created fields with the same name as the fields I put in the array (including the relation and dot when applicable, for example "contacts_to_companies.company_name"), and then I created a group based on one of these fields (in my case "$F{contacts_to_companies.company_id}"), that's it!

To be able to test it, I did create a source on the udm database and made a query retrieving the same data with the same fields name, but this step is not necessary if you know what you are doing.

Hope this answer your question,

Re: Mods to Jasper Plugin for Foundsets?

PostPosted: Tue Jun 02, 2009 11:45 am
by rgansevles
Patrick,

We have been working on the jasper reports plugin to allow reports on foundsets directly.
This is taking your work even a step further.

In classic servoy jasper reports, you have to duplicate the sql which is executed on the server.

In your approach you can collect record data (including related fields and calculations) in your reporting method and send the data to the server for processing.
The data is collected in the client and the report is processed in the server.
If the report changes (other fields are needed) you need to change the collection method as well.

Our next approach is to allow reports directly on foundsets.
In the report you can use fields, aggregates, related data, calculations.
You define the report on the foundset fields and simply pass the foundset in the run method if the plugin.
The report is executed on the client only.

I am planning to include both extensions into the next plugin version.

Rob

Re: Mods to Jasper Plugin for Foundsets?

PostPosted: Tue Jun 02, 2009 12:09 pm
by Kahuna
rgansevles wrote:Patrick,

We have been working on the jasper reports plugin to allow reports on foundsets directly.
This is taking your work even a step further.

In classic servoy jasper reports, you have to duplicate the sql which is executed on the server.

In your approach you can collect record data (including related fields and calculations) in your reporting method and send the data to the server for processing.
The data is collected in the client and the report is processed in the server.
If the report changes (other fields are needed) you need to change the collection method as well.

Our next approach is to allow reports directly on foundsets.
In the report you can use fields, aggregates, related data, calculations.
You define the report on the foundset fields and simply pass the foundset in the run method if the plugin.
The report is executed on the client only.

I am planning to include both extensions into the next plugin version.

Rob


Rob - this is fantastic news and IMHO makes Jasper a really effective reporting tool for Servoy. Having to duplicate (and sometimes not really knowing what the SQL would be) the SQL to run a report made the Jasper plugin pretty much useless to us. I think the take-up of Jasper should soar with this functionality.

Thanks to Patrick for starting this ball rolling and to you Servoy guys for 'grasping the nettle' and adding this functionality.

When will this be available Rob?

It's exactly the right time for us as we're moving to final (and more complex) reports, as opposed to Servoy Forms as reports.

Re: Mods to Jasper Plugin for Foundsets?

PostPosted: Tue Jun 02, 2009 8:24 pm
by ptalbot
Rob,

I agrre with Kahuna, that's fantastic.
This will make the use of the JasperReport engine far more integrated and optimized for using in Servoy.

Thank you!

Re: Mods to Jasper Plugin for Foundsets?

PostPosted: Tue Jun 02, 2009 8:32 pm
by david
rgansevles wrote:Patrick,

We have been working on the jasper reports plugin to allow reports on foundsets directly.
This is taking your work even a step further.

...


Awesome! Looking forward to this.

Re: Mods to Jasper Plugin for Foundsets?

PostPosted: Tue Jun 02, 2009 9:55 pm
by Thomas Parry
Sicne the code is on Google perhaps Servoy could consider beta testing of the changes to ensure the widest possible user base and the wildest possible usage mashups? I think David at Data Mosaic might agree to that concept?

Re: Mods to Jasper Plugin for Foundsets?

PostPosted: Tue Jun 02, 2009 10:17 pm
by ptalbot
I agree with you Tom,

Improving the integration with Jasper is a key improvement for complex reports, and Servoy need to provide a complete solution for this and open source and beta testing is the best way to ensure the largest possible coverage for the code.

Re: Mods to Jasper Plugin for Foundsets?

PostPosted: Wed Jun 03, 2009 10:43 am
by stefbrt
This news is great and will help much. I'm looking forward to this and would help testing.

But when will this be available Rob?

Re: Mods to Jasper Plugin for Foundsets?

PostPosted: Wed Jun 03, 2009 10:53 am
by Harjo
this is sooooo great! :D
Can't wait to try it.

Re: Mods to Jasper Plugin for Foundsets?

PostPosted: Thu Jun 04, 2009 11:53 pm
by rgansevles
I have commited the first alpha, see
http://groups.google.com/group/servoy-j ... ef2dc9ec86

Download here:

http://code.google.com/p/servoy-jasperr ... loads/list

Patrick, it also includes your patch.

Rob

Re: Mods to Jasper Plugin for Foundsets?

PostPosted: Fri Jun 05, 2009 3:54 am
by ptalbot
Rob, you are the best! ;-)

Will try that in the following days.

Thanks again!