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 iHub. To accomplish this task, generate a DesignConfig object with a custom BIRT_HOME path, as shown in the following code:
Use the path to the iHub 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:
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:
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:
<data-mart-data-sourcename="Data Object Data Source"id="7">
<propertyname="datamartURL">test</property>
<propertyname="accessType">transient</property>
</data-mart-data-source>
</data-sources>
When exporting this report design to a volume, also export test.datadesign to maintain the reference to the data source.
Creating data object data sets for BIRT report designs
To create a data object data set, use the newDataMartDataSet( ) method from ElementFactory. For example, to instantiate a new data set, use the following code:
Associate the data object data cube with a DataMartDataSourceHandle object and then add the name of a data set from the data or data design file. For example, to access a data set called "SetName", use the following code:
dataSet.setDataSource( dataSource.getName( ) );
dataSet.setDataObject( "SetName" );
DataMartDataSetHandle inherits the setDataSource( ) method from DataSetHandle.
Finally, add the data element to the report design, as shown in the following code:
designHandle.getDataSets( ).add( dataSet );
Creating data object data cubes for BIRT report designs
To create a data object data cube, use the newDataMartDataCube( ) method from ElementFactory. For example, to instantiate a new data cube, use the following code:
Associate the data object data cube with a DataMartDataSourceHandle object and assign a data cube from the data or data design file. For example, to access a data cube called "CubeName", use the following code:
dataCube.setDataSource( dataSource.getName( ) );
dataCube.setDataObject("CubeName");
Finally, add the data element to the report design, as shown in the following code: