Base Tool for a Servoy embedded Report Generator ?

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Base Tool for a Servoy embedded Report Generator ?

Postby Bernd.N » Sun Sep 04, 2016 11:15 am

As users want to create their own reports on the fly, we want to create our own table-driven report generator.
Table-driven means that we store the reports the users want to print in two tables reports and report_columns (= 1:n).

The Jasper Report Server would work well for this, however we doubt it would be easy to integrate complicated access restrictions for our data based on security roles.
Also, it should be completely embedded in our own solution, rather than having a complete other UI.

We use already the excelxport plugin which works well, but the resulting files can not be called reports as the users have to work them over a bit to look nice.
Creating HTML-output would be another option, but it has the disadvantage that creating PDFs from that right away is not possible as far as I know.
So we want to start using Velocity to build a report generator on top of it.

As that would involve some days of work, I would like to ask if anyone has a tip for another base tool, that might even be better suited for this task.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Base Tool for a Servoy embedded Report Generator ?

Postby sbutler » Sun Sep 04, 2016 3:49 pm

Some things I've done in the past...

1. Jasper Reports with a custom UI to but a framework in front of it.
This works well if the output columns is always the same. You can build some screens for user input, and pass them in as parameters. Even the entire SQL can be passed in as a parameter. So users can choose date ranges, etc to filter the rows or groupings they get to see, but columns on the report remain the same.

2. Jasper Server
I have not had a good experience with this. The security model just doesn't match up well with the complexities of the security that you can setup in Servoy. You would be implementing the same security logic in both systems *IF* you were even able to get it to work.

3. DynamicJasper or DynamicReports
http://dynamicjasper.com/ and http://www.dynamicreports.org/
You can use their Java API and create Jasper reports on-the-fly, so users can choose what columns they want on the report, and you build them on the fly, then run them.

4. Servoy's ExcelUtils
https://github.com/Servoy/svyUtils/wiki/ExcelUtils
If you just need Excel, then this makes it easy. It converts a DataSet to excel, and has formatting options to make the Excel look nice.

5. Velocity
Similar to Jasper, but the columns could also be dynamic with Velocity. I'm sure Patrick could give you a bunch more positives of Velocity :P

6. Convert to PDF on your own
You can use a Java Library to convert to PDF, or you can also use Servoy. Make an HTML_AREA on a form, set its anchoring, and use the PDF Output plugin to print the form to PDF.

You have a lot of options :) I usually end up with more than 1. So in my solutions, I usually end up with a Reports module with a treeview on the left of reports. Each report has a report_type (jasper, velocity, etc) and a form_name, along with whatever other parameters needed to run the report. Use clicks on a report, we load the form_name into a panel on the right, and it displays whatever the input options necessary for the report are, along with output options. This lets it be flexible.
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 759
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Re: Base Tool for a Servoy embedded Report Generator ?

Postby Bernd.N » Sun Sep 04, 2016 5:01 pm

Thanks for this nice overview. Your remarks regarding JasperReportServer are the same I had in mind, besides the price tag of that tool.

Comparing DynamicJasper and DynamicReports, which would you recommend?

The huge list of examples from DynamicReports is impressive:
http://www.dynamicreports.org/examples/examples-overview
And it has a forum with 1.300 topics:
http://www.dynamicreports.org/forum/
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Base Tool for a Servoy embedded Report Generator ?

Postby sbutler » Sun Sep 04, 2016 6:11 pm

My last work with that was about 2 years ago, and I used DynamicJasper (it was probably the only one out then)

I also created a plugin for it, which I've attached. Your welcome to use it. If others like it, I could put it on ServoyForge, but I haven't tried it in a few years, so keep that in mind.

Preview:
DJ.PNG
DJ.PNG (5.16 KiB) Viewed 7055 times


Example Usage:

Code: Select all
//Plugin doesn't expose all the java Libs, so import them to type-aheads and such work
importPackage(Packages.ar.com.fdvs.dj.domain.constants)
importPackage(Packages.ar.com.fdvs.dj.core)
importPackage(Packages.ar.com.fdvs.dj.core.layout)
importPackage(Packages.ar.com.fdvs.dj.domain.builders)
importPackage(Packages.ar.com.fdvs.dj.domain.entities)
importPackage(Packages.ar.com.fdvs.dj.domain)
importPackage(Packages.java.awt);
importPackage(java.util)

//Setup Styles and Headers
var styleLeft = plugins.DynamicJasper.getStyle()
styleLeft.setHorizontalAlign(HorizontalAlign.LEFT);
styleLeft.setVerticalAlign(VerticalAlign.MIDDLE);

var styleHeader= plugins.DynamicJasper.getStyle()
styleHeader.setHorizontalAlign(HorizontalAlign.LEFT);
styleHeader.setVerticalAlign(VerticalAlign.MIDDLE);
styleHeader.setBackgroundColor(Color.gray);
styleHeader.setTransparency(Packages.ar.com.fdvs.dj.domain.constants.Transparency.OPAQUE)

//Build your Query and args
var query = "SELECT * FROM Blah"
var jasperArgs = {} //your args

//Setup the Fast Report Builder
var frb = plugins.DynamicJasper.getFastReportBuilder()
frb.setQuery(SQL, DJConstants.QUERY_LANGUAGE_SQL)
frb.setUseFullPageWidth(true)

//add columns or groups if you need (optional I think)
frb.addColumn("Column Title","some_id","java.lang.Integer", 50, style)
frb.addColumn("Display","display_name","java.lang.String", 100)
frb.addGroups(1)

//Build it and get the JRXML
var dr = frb.build()
var djh = plugins.DynamicJasper.getDynamicJasperHelper()
var jrxmlData = djh.generateJRXML(dr, new ClassicLayoutManager(), jasperArgs, "UTF-8");

//Get it on the server
var fileName = application.getUUID() + ".jrxml"
plugins.it2be_tools.server().writeTXTFile(plugins.jasperPluginRMI.reportDirectory + "/" + fileName, jrxmlData)

//Run it
plugins.jasperPluginRMI.runReport('your server name', fileName, null, OUTPUT_FORMAT.VIEW, jasperArgs, null);
Attachments
dynamic_jasper.zip
Dynamic Jasper Plugin
(337.14 KiB) Downloaded 243 times
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 759
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Re: Base Tool for a Servoy embedded Report Generator ?

Postby Bernd.N » Sun Sep 04, 2016 6:23 pm

Thanks a lot!
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Base Tool for a Servoy embedded Report Generator ?

Postby sergei.sheinin » Sat Sep 17, 2016 11:05 am

Hello Scott,


Your code generates warnings in Eclipse. Please let us know if there is a manual for your plugin. May you answer these questions about usage:

- What format are objects "HorizontalAlign", "VerticalAlign", "Color" and "style"?

- What is the syntax for frb.setQuery()?

- Line var jrxmlData = djh.generateJRXML(dr, new ClassicLayoutManager(), jasperArgs, "UTF-8"); generates warning "The method generateJRXML() is undefined for the type ar.com.fdvs.dj.core.DynamicJasperHelper". What would be its proper use?

- What is proper use of "importPackage()"? Is it an extension?



Thank you.
Sergei Sheinin
JavaScript, RDBMS
http://js2dx.com
sergei.sheinin
 
Posts: 79
Joined: Wed May 07, 2014 3:22 pm

Re: Base Tool for a Servoy embedded Report Generator ?

Postby sbutler » Mon Sep 19, 2016 12:12 am

The plugin just exposes a small portion of the DynamicJasper Java libraries, and gives you an entry point into that Java Library. The information about those objects ("HorizontalAlign", "VerticalAlign", "Color" and "style"), and the functions, like frb.setQuery(), are all found in the JavaDoc for Dynamic Jasper: http://dynamicjasper.com/docs/3.x/apidocs/

Examples:
HorizontalAlign: http://dynamicjasper.com/docs/3.x/apido ... Align.html
Fast Report Builder: http://dynamicjasper.com/docs/3.x/apido ... ilder.html
Fast Report Builder extends DynamicReportBuilder (which is where setQuery is): http://dynamicjasper.com/docs/3.x/apido ... ilder.html

importPackage is a feature of Rhino: https://developer.mozilla.org/en-US/doc ... pting_Java
It allows you to make Java packages, and their classes, available in scope of your JavaScript method.
Servoy under-the-hood is all Java. The code you write in JavaScript is executed using Rhino (JavaScript engine written in Java). Rhino gives you the ability to write Java and JavaScript within the same code. For example, lets take the standard Java HashMap class.

You could reference it like this:
Code: Select all
var myHashMap = new Packages.java.util.HashMap()


You could also just import the package, so you don't need the full package path. This makes things easier when working with lots of java classes.
Code: Select all
importPackage(java.util)
var myHashMap = new HashMap()


Thats a lot of info to throw at you, but essentially, you can work with almost any Java package in Servoy without a Plugin. Plugin makes things easier because they provide some entry points and expose some of the method names. In this example, its a little of both because DynamicJasper is a HUGE project with tons of classes, so building a full extensive plugin was more time that I had to spend on it.

PS. as I mentioned, I created it a few years ago, and haven't used it in a while, so there is no documentation nor support. Happy to help as I have some free time. If there is priority or urgency, consider sponsoring it and I'll move it to ServoyForge.
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 759
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Re: Base Tool for a Servoy embedded Report Generator ?

Postby marco.rossi » Mon Sep 19, 2016 5:38 pm

Hi Bernd,

I don't remember how to interact with the Jasper Server security because I don't use it since some years but an idea could be to embed the Jasper Server Dashboard within your
Servoy solution using Java-FX.
Marco Rossi
Senior Analyst Developer
Freelance Consultant

IT Manager @Mantho
Webmaster @Sitoliquido
marco.rossi
 
Posts: 110
Joined: Sun Apr 12, 2015 9:33 pm

Re: Base Tool for a Servoy embedded Report Generator ?

Postby Bernd.N » Tue Sep 20, 2016 4:55 pm

Thanks for the idea, Marco. I want to try without the Jasper Report Server first, as it would be quite heavy to integrate it.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Base Tool for a Servoy embedded Report Generator ?

Postby sergei.sheinin » Sun Sep 25, 2016 11:44 am

Scott,

I updated my previous question. Please explain why in code below


Code: Select all
var djh = plugins.DynamicJasper.getDynamicJasperHelper()
var jrxmlData = djh.generateJRXML(dr, new ClassicLayoutManager(), jasperArgs, "UTF-8");


A warning "The method generateJRXML() is undefined for the type ar.com.fdvs.dj.core.DynamicJasperHelper" is generated?
Sergei Sheinin
JavaScript, RDBMS
http://js2dx.com
sergei.sheinin
 
Posts: 79
Joined: Wed May 07, 2014 3:22 pm


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 16 guests

cron