Generating data object elements for BIRT report designs
To generate data object data sources, data sets, and cubes for a BIRT report design, first configure BIRT_HOME to access the Actuate commercial model API Java archive (JAR) files from Actuate iServer. To accomplish this task, generate a DesignConfig object with a custom BIRT_HOME path, as shown in the following code:
// Create an DesignConfig object.
DesignConfig config = new DesignConfig( );
// Set up the path to your BIRT Home Directory.
config.setBIRTHome("C:/Program Files/Actuate11/iServer/Jar/BIRT/platform");
Use the path to the iServer installation specific to your system.
Using this design configuration object, create and configure a Design Engine object, open a new session, and generate or open a report design object, as shown in the following code:
// Create the engine.
DesignEngine engine = new DesignEngine( config );
SessionHandle sessionHandle = engine.newSessionHandle( ULocale.ENGLISH );
ReportDesignHandle designHandle = sessionHandle.createDesign( );
These objects are contained in the model API package
The ElementFactory class supports access to all the elements in a report. The following code generates an Element Factory object:
ElementFactory factory = designHandle.getElementFactory( );
To generate data sources, data sets, and cubes, use the datamart methods of an ElementFactory object: newDataMartCube( ) for a new cube, newDataMartDataSet( ) for a data set, and newDataMartSource( ) for a new data source. For example, to instantiate a new data source, use the following code:
DataMartDataSourceHandle dataSource =
factory.newDataMartDataSource("Data Object Data Source");
Associate a handle for a data object data source with an actual data source from the contents of a data or data design file. For example, to associate a data source handle with a data source from test.datadesign, use the following code:
dataSource.setDataMartURL( "test" );
dataSource.setAccessType( DesignChoiceConstants.ACCESS_TYPE_TRANSIENT );
Finally, add the data element to the report design, as shown in the following code:
designHandle.getDataSources( ).add( dataSource );
To complete the data source assignment, output the report design into a file and close the design handle object, using code similar to the following:
FileOutputStream fos = new FileOutputStream( "output.rptdesign" );
designHandle.serialize( fos );
// Close the document.
fos.close( );
designHandle.close( );
The resulting output file, output.rptdesign, contains the new data source, retrieved from test.datadesign. This data source appears in Data Sources in Data Explorer and establishes a link to the .datadesign file, test.datadesign. The XML source for output.rptdesign includes markup similar to the following lines:
<datamart-node location="file:/MyProject/test.datadesign">
  <data-mart-data-source name="Data Object Data Source" id="7">
    <property name="datamartURL">test</property>
    <property name="accessType">transient</property>
When exporting this report design to an Encyclopedia volume, also export test.datadesign to maintain the reference to the data source.

Additional Links:

Copyright Actuate Corporation 2012