Dynamically generating reports in Pentaho and dealing with report definitions store in the database

StackOverflow https://stackoverflow.com/questions/4665380

  •  10-10-2019
  •  | 
  •  

Question

I am developing a reporting application where a user can select(and order) reports from a list of 100 reports and ask for a master report. This master report will contain all the selected reports in the exact order and with a table of contents listing the reports included in the master report. The reports available for the user to select (which could be 100s) are stored in the database.

My questions are :-

  1. To generate the master report with the user selected reports, the only solution I can see is using the Reporting Engine API to generate a dynamic report into which I have to add the user selected reports as subreports. Is this the right and easiest way to approach this problem? Does anyone have samples of the Reporting Engine API usage especially to inject subreports in a Master report?
  2. Since I am storing the reports in the db(blobs), I am trying to find a way to generate my sub reports with an inputstream rather than a URL as specified in ResourceManager.createDirectly(url, MasterReport.class), but haven't been successful till now. How can I generate reports from definitions stored in the database? There should be some resource abstraction.
Was it helpful?

Solution

Read your reports into a byte-array and then use the ResourceManager.createDirectly method as usual. That will solve your problem of parsing the reports.

You can parse them directly into SubReports by using

ResourceManager.createDirectly(bytes, SubReport.class)

These subreports can then be added to your master report as banded subreports. if you want your selected reports to start on a new page, make sure you set the "pagebreak-before" style on your subreport's report-header.

There is a resource abstraction: It is called "LibLoader" and you can create your own ResourceLoaders that deal with the problem of getting your data out of your database as raw-streams so that the ResourceFactory implementations can interpret/parse the raw-data.

But every database is designed differently and thus you as the system integrator have to write the glue code for it. We only can offer the interfaces.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top