Software Engineering

My part in its downfall

All the salient facts are true

Issues re Reporting tools and Frameworks

Objective

Simple code to generate the Jasper Reports Charting Samples

Target Audience

Developers new to Jasper Reports

Source Documents

jasper reports
jasper reports server samples
jasper reports workflow
jasper reports syntax
jasper reports library
jasper reports charts
ant ivy intergration
gradle wrapper

Summary

A refactor of the jasper reports charts samples from the jasper reports server samples to run with the gradle wrapper.

Result

A Demo app run with the gradle wrapper using
./gradlew bootRepackage
./gradlew bootRun
The compiled reports can be found in the auto generated ‘chartspdf’ folder

Discussion

JasperReports is an open source reporting library. It turns up in many Java applications particularly legacy (cms, crm) applications or (cms, crm) applications that have been developed over a long period of time. Recently I decided to go a bit deeper in my understanding of the jasper reports syntax and workflow. Rather than wade thru pages of documentation and xsd schemas I prefer just to run examples and look at the source code to quickly discern the patterns. Particularly I was interested in the jasper reports charts.

I ran into and issue with the jasper reports library. The code uses ant and ivy out of the box. I spent approx 10 minutes trying to get it to build but kept getting obscure errors complaining about missing ivy dependencies. To speed up the learning experience I quickly refactored the chart examples to run with the gradle wrapper. If you are new to Jasper reports and you want a simple bootstrap into the Jasper charting plugin you can

  • clone the Demo app

  • Use the gradle wrapper to build and run the code

    ./gradlew bootRepackage ./gradlew bootRun

  • view the reports in the auto generated ‘chartspdf’ folder

More Details

The code sets up and embedded ‘hsqldb’ database. There is a database init script schema. I had to refactor this from the original test.script to get it to work with the hsql in the demo app source. I needed to set the following in the jdbc connection url sql.enforce_size=false .

The Jasper xml can call the database directly and run queries, process the ouput and set up the results see JasperController where you pass the jdbc connection through to the xml.

The Jasper xml can call java methods see BarChartCustomizer, there is the abstraction they call a Customizer see JRChartCustomizer.

There is a distinction between Business Intelligence (BI) and reporting. Jasper is for reporting. By focusing on reporting and not being a hybrid BI and reporting tool is a good thing. Things quickly get out of hand in terms of complexity and I have seen some horrendously overcoupled BI and reporting code bases. Jasper is released under a user and buisness licensce.

Going forward to learn about or implement open source BI tools pentaho is a good choice that integrates with Jasper.

Jasper License.
pentaho license

Demo app


Share