Hierarchical Data Source API
As a database application, Logi JReport Designer cannot only access data stored in a database through the JDBC connection and user data source (UDS), but also supports the importing of data from hierarchical data sources (HDS).
The HDS API is a part of the Logi JReport Data Access Model as shown in the following diagram:
The hierarchical data source API:
- Is a Java interface that provides a dataset to Logi JReport.
- Has a PARAMETER string, which can be changed when the HDS object is added into Logi JReport Designer. The result set may differ according to the PARAMETER string. It is very flexible and convenient.
Notes:
- The PARAMETER here is the parameter string given to the HDS interface. That is, the HDS API provides a method getResultSet (String strParam), and PARAMETER is string strParam in the above method. As a reminder, PARAMETER here is different from the parameter object in the Logi JReport catalog. To distinguish between them, an upper case PARAMETER is used to refer to the parameter string in the HDS, and a lower case parameter for the parameter object in a catalog.
- To design a report, Logi JReport requires a metadata (see java.sql.ResultSetMetaData) which corresponds with the ResultSet that the data source has returned. To view or run a report, Logi JReport requires a ResultSet object. The hierarchical data source must provide both of these two parts to Logi JReport.
Below is a list of the sections covered in this topic:
HDS API Interfaces
The HDS API contains three interfaces as listed below that you must implement.
jet.datasource.JRHierarchicalDataSource
Reference: Logi JReport Javadoc jet.datasource.JRHierarchicalDataSource, jet.datasource.JRHierarchicalDataset and jet.datasource.JRHierarchicalDatasetMetaData classes in <install_root>\help\api
.
jet.datasource.JRHierarchicalDataSource
Provides data to Logi JReport for generating reports. The JRHierarchicalDataSource class is developed by users of Logi JReport, and can provide data from a flat file, non-relational database, or application data. The data returned by this class is in JRHierarchicalDataset object, so that users are required to create a JRHierarchicalDataset instance for Logi JReport to use this instance to fetch data. Users can also create their own JRHierarchicalDataset class.
The following are methods provided by the interface.
public JRHierarchicalDataset getHierarchicalDataset (String param) throws JRUserDataSourceException
This method gets the data in JRHierarchicalDataset according to the parameters set.
- PARAMETER: param - A String value used to request and get different result sets. The format of the PARAMETER string is defined and also parsed by yourself.
- Returns: JRHierarchicalDataset object, which implements the interface JRHierarchicalDataset.
- Throws: JRUserDataSourceException - If a data access error occurs.
public void releaseHierarchicalDataset() throws JRUserDataSourceException
This method releases the data and related resources.
- Throws: JRUserDataSourceException - If a data access error occurs.
The class definition may be as follows:
|
jet.datasource.JRHierarchicalDataset
Provides data to Logi JReport for generating reports. The JRHierarchicalDataset class is developed by users of Logi JReport, and can provide data from a flat file, non-relational database, or application data.
The following are methods provided by the interface.
|
jet.datasource.JRHierarchicalDatasetMetaData
Provides meta data for JRHierarchicalDataset. The JRHierarchicalDatasetMetaData class is developed by users of Logi JReport, and it works together with a JRHierarchicalDataset.
The following are methods provided by the interface.
|
Examples of Using the HDS API
The HDS API is flexible and convenient to use. Before you implement it, you should make an overall consideration of the architecture. Logi JReport provides you with several scenarios which use the Logi JReport HDS API. You can refer to them for assistance.
- You can import an XML format hierarchical data source directly from an external data source to Logi JReport Designer using the Logi JReport built-in classes. See Example 2: Importing an HDS from an XML file to a catalog.
- You can also develop your own classes to implement the HDS APIs, and then import your customized hierarchical data source. See Example 1: Adding a general HDS to a catalog.