Customizing and integrating BIRT Studio : Providing data : Creating a custom data source : Sample ODA data source
 
Sample ODA data source
Creating a custom user interface to connect to a BIRT JDBC data source does not require additional coding. You must configure the data source and data set and describe the data set columns in the erni_config.xml file, as shown in Listing 14‑3.
Listing 14‑3 Configuring the sample data source in erni_config.xml
<odaconfig>
<name>OdaSample</name>
<displayName>Sample ODA data source</displayName>
<description>A sample ODA data source</description>
<datasourceExtensionId>org.eclipse.birt.report.data.oda.jdbc
</datasourceExtensionId>
<datasourceDisplayName>CLASSICMODELS</datasourceDisplayName>
<datasetExtensionId>org.eclipse.birt.report.data.oda.jdbc.
JdbcSelectDataSet</datasetExtensionId>
<datasetDisplayName>CLASSICMODELS.PAYMENTS</datasetDisplayName>
<odaDriverClass>org.eclipse.birt.report.data.oda.sampledb.
Driver</odaDriverClass>
<odaURL>jdbc:classicmodels:sampledb</odaURL>
<odaUser>ClassicModels</odaUser>
<!-- <odaPassword> </odaPassword> -->
<!-- Data Type can be DECIMAL(3)/INTEGER(4)/FLOAT(6)
/DATE-TIME(93)/DATE(91)/TIME(92)/BOOLEAN(16)/STRING(12)-->
<odaColumns>
<odaColumn>
<name>CUSTOMERNUMBER</name>
<dataType>INTEGER</dataType>
</odaColumn>
<odaColumn>
<name>PAYMENTDATE</name>
<dataType>DATE</dataType>
</odaColumn>
<odaColumn>
<name>CHECKNUMBER</name>
<dataType>STRING</dataType>
</odaColumn>
<odaColumn>
<name>AMOUNT</name>
<dataType>FLOAT</dataType>
</odaColumn>
</odaColumns>
<dataObject>CLASSICMODELS.PAYMENTS</dataObject>
<!-- <queryText> </queryText> -->
<enabledInWorkgroupMode>false</enabledInWorkgroupMode>
<enabledInEnterpriseMode>true</enabledInEnterpriseMode>
<entryPoint></entryPoint>
</odaconfig>
To test the sample ODA data source with BIRT Studio, you must first enable the data source, named OdaSample, by setting the data source’s <enabledInEnterpriseMode> attribute in erni_config.xml to true. The erni_config.xml file is stored in the following location:
<context root>\WEB-INF
Typically, in standard installations the <context root> is as follows:
In iHub:
<ACTUATE_HOME>\iHub2\servletcontainer\iportal
In Information Console:
<ACTUATE_HOME>\iPortal\iportal
After you enable the sample data source, restart the appropriate Windows service for iHub or Information Console, and open BIRT Studio. When prompted, select one of the standard report templates. The Data Source dialog box, as shown in Figure 14‑12, prompts you to select a data source. Select Sample ODA data source.
Figure 14‑12 Selecting a data source
Based on the XML definition in erni_config.xml, the product displays a sample ODA editor with a table, containing the configured database columns, as shown in Figure 14‑13.
Figure 14‑13 Selecting data in the sample ODA editor
The check boxes appearing next to the column names allow the user to select the data for the report. The editor gives the user ability to create a parameter for filtering the data in the last column.
Table 14‑1 lists all the configuration attributes and their descriptions.
Table 14‑1 Attributes of a sample ODA data source
Attribute
Description
<name>
The unique name of the data source. This name follows certain naming conventions. There can be no spaces, for example.
<displayName>
The data source name that appears in the Data Source dialog box, as shown in Figure 14‑12.
<description>
The data source description that appears in the Available Data pane.
<datasetExtensionId>
Identifies the ID of the data set extension of the data driver.
<datasourceDisplayName>
The display name of the data source.
<datasourceExtensionId>
Identifies the ID of the data source extension of the data driver.
<datasetDisplayName>
The display name of the data set.
<odaURL>
The database URL to use to connect to the data source.
<odaUser>
The user name, used to connect to the database.
<odaPassword>
The database password.
<odaColumn><name>
The name of the database column to be included in the user interface.
<odaColumn><dataType>
The type of the database column. Can be one of the following:
DECIMAL(3), INTEGER(4), FLOAT(6),DATE-TIME(93),DATE(91), TIME(92), BOOLEAN(16), STRING(12)
<dataObject>
The name of the database table if single table is used.
<queryText>
The text of the query if the columns are from different tables.
<enabledInWorkgroupMode>
Not used.
<enabledInEnterpriseMode>
Indicates whether this data source is available to users.
<entryPoint>
A URL or servlet that points to the first web page of your custom query builder.
Configuring the ODA data source requires knowledge about your JDBC data source and data set. If you do not know this information, you can obtain the database connection properties from your database administrator. It is a good practice to create first a sample report in BIRT Designer Professional and validate the connection and the database query. You use the XML source of the created report to identify the correct values for the sample ODA configuration. Look for the attribute values in the <data-sources> and <data-sets> tags at the beginning of the report XML.
Listing 14‑4 shows portions of the report XML that contain the configuration attributes and their values.
Listing 14‑4 Report XML source
<data-sources>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="Data Source" id="7">
<property name="odaDriverClass">org.eclipse.birt.report.data.oda.sampledb.Driver</property>
<property name="odaURL">jdbc:classicmodels:sampledb</property>
<property name="odaUser">ClassicModels</property>
</oda-data-source>
</data-sources>
<data-sets>
<oda-data-set extensionID=
"org.eclipse.birt.report.data.oda.jdbc. JdbcSelectDataSet" name="Data Set" id="8">
<xml-property name="queryText"><![CDATA[select *
from CLASSICMODELS.PAYMENTS]]></xml-property>