Focusing on open APIs for enterprise applications

Open Web Magazine

Subscribe to Open Web Magazine: eMailAlertsEmail Alerts newslettersWeekly Newsletters
Get Open Web Magazine: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Open Web Authors: Bob Gourley, Kevin Benedict, Pat Romanski, PR.com Newswire, RealWire News Distribution

Related Topics: Eclipse Platform, Open Web Magazine

Eclipse Platform: Article

How to Develop an Application Using the Eclipse BIRT Design Engine API

Creating a customized report design application

This article is the second in a series on developing an application using Eclipse BIRT Engine APIs. It focuses on developing an application using the Eclipse BIRT Design Engine API. The last article focused on the Eclipse BIRT Report Engine API.

The Eclipse Business Intelligence Reporting Tool (BIRT) is a set of plug-in extensions that enable a developer to add reporting functionality to an application. BIRT provides a Design Engine API that a developer can use to create a customized report design application. The org.eclipse.birt.report.engine.api package contains a set of interfaces and implementation classes that supports integrating the design-time part of BIRT into a reporting application.

Programming with a Report Design
A reporting application typically generates a report from a report design. In this type of reporting application, you develop a report design and include the design along with the application at deployment. Any changes to the generated report depend on the values of report parameters and the data from the data set. To access the report design, the application uses an IReportRunnable object.

Sometimes business logic requires changes to the report design before generating the report. You can make some changes by using parameters and scripting. Other changes can only occur by modifying the report design itself.

A reporting application can make changes to the report design and the Report Object Model (ROM) elements that make up the design. To access the structure of the report design, the application obtains a ReportDesignHandle object from the design engine. To access the design engine, an application must first instantiate a report engine, as in any other reporting application.

The ReportDesignHandle object provides access to all properties of the report design and to the elements that the report design contains. The model API provides handle classes to access all ROM elements. For example, a GridHandle object provides access to a grid element in the report design. All ROM element handles, including the report design handle, inherit from DesignElementHandle. Report items inherit from ReportElementHandle and ReportItemHandle.

After making changes to a report design or its elements, the application can write the result to a stream or a file. The report engine can then open an IReportRunnable object on the resulting design and generate a report.

An application typically accesses the items in a report design to do one of the following tasks:

  • Modify an existing report design programmatically to change the contents and appearance of the report output. An application can modify page characteristics, grids, tables, and other report items in the design, the data source, and the data set that extracts data from a data source.
  • Build a report design and generate report output entirely in an application without using BIRT Report Designer.
A reporting application can access and modify the structures in a template or a library file like the structures in a report design. The techniques described in the rest of this article are applicable to these files as well as to report designs.

The functionality of a template is identical to a report design. For this reason, the ReportDesignHandle class provides access to a template. The LibraryHandle class provides access to a library. Both these classes derive from the ModuleHandle class, which provides the fields and methods for the common functionality, such as accessing elements in the file.

The package that contains the classes and interfaces to work with the items in a report design, library, or template is org.eclipse.birt.report.model.api.

BIRT Model API Capabilities
A report developer can write an application that creates and modifies a report design programmatically. The BIRT model API has the same capabilities as BIRT Report Designer. For example, the following list shows some of the ways in which you can use the BIRT model API to manipulate a report design programmatically:

Modify a report item in a report design:

  • Format a report item, change the font, font color, fill color, format, alignment, or size. Modify the expression or other property of a report item.
  • Change the data set bound to a table or list.
    Add a report item to a report design:
  • Add a simple report item such as a data item, label, or image.
  • Set the value to display in the new report item, such as the expression of a data item or the text in a label item.
  • Create a complex item such as a grid, table, or list.
  • Add other items into a grid, table, or list.
    Change the structure of a report design:
  • Add or delete a group or column in a table or list.
  • Add a report parameter.
    Modify non-visual elements in a report design:
  • Specify a data source for a data set.
  • Set a design property such as a report title, author, wallpaper, or comment.
  • Set a page property such as height, width, or margins.
Opening a Report Design Programmatically for Editing
To access a report design and its contents, the application must instantiate a report engine then use a ReportDesignHandle object. You instantiate a ReportDesignHandle by calling a method on another class such as the model class, SessionHandle, or the report engine interface, IReportRunnable.

The SessionHandle object manages the state of all open report designs. Use a SessionHandle to open, close, and create report designs, and set global properties, such as the locale and the units of measure for report elements. The SessionHandle can open a report design from a file or a stream. Create the session handle only once. BIRT supports only a single SessionHandle for a user of a reporting application.

Configuring the Design Engine To Access a Design Handle
The DesignEngine class provides access to all the functionality of the ROM in the same way that the ReportEngine class provides access to report generation functionality. To create a DesignEngine object, you first create a DesignConfig object to contain configuration settings for the design engine. The DesignConfig object sets up custom access to resources and custom configuration variables for scripting. Instantiate a DesignEngine object with the DesignConfig object as an argument to the constructor.

Create the SessionHandle object by calling the method, newSessionHandle( ) on the DesignHandle object. To open the report design, call the method, openDesign( ), on the SessionHandle object. This method takes the name of the report design as an argument and instantiates a ReportDesignHandle object.


More Stories By Jason Weathersby

Jason Weathersby is a member of the extended BIRT development team at Actuate Corporation and has backgrounds in both computer science and technical writing. He has many years experience in technical consulting, training, writing, and publishing about reporting, business intelligence tools, and database technologies.

More Stories By Tom Bondur

Tom Bondur is a member of the extended BIRT development team at Actuate Corporation and has backgrounds in both computer science and technical writing. He has many years experience in technical consulting, training, writing, and publishing about reporting, business intelligence tools, and database technologies.

More Stories By Jane Tatchell

Jane Tatchell is a content development manager in the Developer Communications group of Actuate Engineering.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.