Home > OS >  How to integrate BIRT with Python Django Project by using Py4j
How to integrate BIRT with Python Django Project by using Py4j

Time:09-16

Hi is there anyone who is help me to Integrate BIRT report with Django Projects? or any suggestion for connect third party reporting tools with Django like Crystal or Crystal Clear Report.

CodePudding user response:

Some of the 3rd-party Crystal Reports viewers listed here provide a full command line API, so your python code can preview/export/print reports via subprocess.call()

The resulting process can span anything between an interactive Crystal Report viewer session (user can login, set/change parameters, print, export) and an automated (no user interaction) report printing/exporting.

While this would simplify your code, it would restrict deployment to Windows.

CodePudding user response:

For prototyping, or if you don't mind performance, you can call from BIRT from the command line.

For example, download the POJO runtime and use the script genReport.bat (IIRC) to generate a report to a file (eg. PDF format). You can specify the output options and the report parameters on the command line.

However, the BIRT startup is heavy overhead (several seconds). For achieving reasonable performance, it is much better to perform this only once.

To achieve this goal, there are at least two possible ways:

You can use the BIRT viewer servlet (which is included as a WAR file with the POJO runtime). So you start the servlet with a web server, then you use HTTP requests to generate reports. This looks technically old-fashioned (eg. no JSON Requests), but it should work. However, I never used this approach.

The other option is to write your own BIRT server.

In our product, we followed this approach.

You can take the viewer servlet as a template for seeing how this could work.

The basic idea is: You start one (or possibly more than one) Java process. The Java process initializes the BIRT runtime (this is what takes some seconds). After that, the Java process listens for requests somehow (we used a plain socket listener, but of course you could use HTTP or some REST server framework as well).

A request would contain the following information:

  • which module to run
  • which output format
  • report parameters (specific to the module)
  • possibly other data/metadata, e.g. for authentication

This would create a RunAndRenderTask or separate RunTask and RenderTasks.

Depending on your reports, you might consider returning the resulting output (e.g. PDF) directly as a response, or using an asynchronous approach.

Note that BIRT will happily create several reports at the same time - multi-threading is no problem (except for the initialization), given enough RAM.

Be warned, however, that you will need at least a few days to build a POC for this "create your own server" approach, and probably some weeks for prodction quality.

So if you just want to build something fast to see if the right tool for you, you should start with the command line approach, then the servlet approach and only then, and only if you find that the servlet approach is not quite good enough, you should go the "create your own server" way.

It's a pity that currently there doesn't seem to exist an open-source, production-quality, modern BIRT REST service.

That would make a really good contribution to the BIRT open-source project... (https://github.com/eclipse/birt)

  • Related