Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

We also support Jakarta-Commons (org.jfree.logger.jcl.JakartaLogTarget) and JDK14 style logging (org.jfree.logger.java14.Java14LogTarget). These log-target implementation can be found in the JCommons-Logging package. (Downloadable at http://www.jfree.org/jcommon/download/ )

How to include Definitions from the Pentaho Report-Wizzard or Pentaho Report-Designer into Swing Applications

The scope of Pentaho Reporting's development is primarily focused on generating great content in an easy way. Therefore Pentaho Reporting does not come with any automatic query-management, like the Pentaho-Plattform does.

The scope of Pentaho Reporting's development is primarily focused on generating great content in an easy way. Therefore Pentaho Reporting does not come with any automatic query-management, like the Pentaho-Plattform does. The Pentaho-Plattform, for now, does not come with the ability to start Pentaho Reporting's GUI.

Using MDX-Queries without the Plattform is hard, if not impossible. Including JDBC-Queries, however, is easy and can be done in a few lines of code.

This manual coding is ugly and will change sooner or later.

Both GUI tools generate an XAction and a report definition file. The XAction file describes how the Pentaho-Plattform prepares the report and which parameters are needed to configure the report processing.

Important: The Report-Designer uses an abstract report definition model as internal storage format. These definitions have the extension '.report'. Pentaho Reporting cannot understand these files - you have to export the report to generate the '.xml' file (the Pentaho Reporting report definiton) and the corresponding action sequence.

You can safely ignore that file, except for one thing: It also contains the SQL-Query string that is needed to get the data for the report. So fire up your favourite XML or Text-editor and extract the query string. (It is contained in an element <query> inside the action-definition.)

The code to get a JDBC-ResultSet is standard JDBC code, there's nothing special here. Get a connection, create a statement and fire the query.

Code Block

public ResultSet performQuery(String query)
{
  final Properties prop = new Properties();
  prop.setProperty("user", "sa");
  prop.setProperty("password", "");

  // Note: You have to provide your own URL here
  final Connection c = DriverManager.getConnection
          ("jdbc:hsqldb:/home/src/pentaho/pentaho-jfree/sql/sampledata", prop);
  final Statement s = c.createStatement();
  final ResultSet resultSet = s.executeQuery(query);
  return resultSet;
}

Now we have the data, but Pentaho Reporting needs TableModels to work with. So let's wrap that resultset into a TableModel. The ResultSetTableModelFactory is part of Pentaho Reporting's core code.

Code Block

final CloseableTableModel model =
    ResultSetTableModelFactory.getInstance().createTableModel(resultSet);

The ".xml" file the tools created contain your report definition. Copy that file into a suitable location and obtain an URL to that xml-file. Use the 'executeReport' method from above together with your URL and the tablemodel and execute the report. After the reporting, don't forget to close the TableModel to free the ResultSet.