BackPrevious Page Next PageNext

Adding an HDS to a Catalog

You have two ways to add an HDS to a catalog:

The following examples explain the above two methods in detail.

Example 1: Adding a general HDS

There are three classes used in this example. Their source code files are HierarchicalDataSource.java, HierarchicalDatasetMetaData.java, and HierarchicalDataset.java, which are available in <install_root>\help\samples\APIUDS\hierarchicalUDS. In this example, the HierarchicalDataSource.java will return the result set from the demo HSQL DB.

  1. Copy the above three files to <install_root>\help. Modify the demo HSQL DB path in both HierarchicalDatasetMetaData.java and HierarchicalDataset.java.
  2. Compile the Java files to generate HierarchicalDataSource.class, HierarchicalDatasetMetaData.class, and HierarchicalDataset.class.
  3. Append the path <install_root>\help into the ADDCLASSPATH variable of the batch file setenv.bat in <install_root>\bin, so that at runtime HierarchicalDataSource can be found.
  4. Start JReport Designer with the batch file you just modified and open an existing catalog.
  5. In the Catalog Manager, right-click the data source to which to add the HDS, then select New General Hierarchical Data Source from the shortcut menu. The New General Hierarchical Data Source dialog appears.
  6. Click the Browse button to find the class HierarchicalDataSource.class.
  7. Type a number in the Parameter box. Then, only the records whose employee ID is less than this number will be fetched.
  8. Click Load Tree. The data source tree will then be parsed.
  9. Modify the column properties in the Columns box as required.
  10. Click OK to add the HDS.

Example 2: Importing an HDS from an XML file to a catalog

To import an HDS from an XML file, follow the steps below:

  1. Start JReport Designer and open the catalog file SampleReports.cat in <install_root>\Demo\Reports\SampleReports.
  2. In the Catalog Manager, right-click the data source to which to add the HDS, and then select New XML Hierarchical Data Source from the shortcut menu. The New XML Hierarchical Data Source dialog appears.
  3. Provide the information respectively according to your data source information.

    JReport Designer supports all kinds of URI as the XML data source.

    When importing the XML file, you have to define the types of some data in the Format column. For example, if it is Date type, such as 1978-03-12, in the corresponding Format column, type in yyyy-MM-dd. If the data is $12,345.32, in the corresponding Format column, type in $##,###.##. By default, the value of the Scale column is 0, therefore, for decimal type data, you will have to specify the scale value in its corresponding Scale column, that is, modify this value to the number of digits that you want to appear to the right of the decimal point, for example, if the data is 123.23, then in the Scale column, modify this value to 2. For the Currency and Array columns, check them if required.

  4. Click OK to import the HDS.

The XSD file

When you import an XML format HDS with an XSD file, the XML file only provides the data to the JReport Designer reports, while the structure, data type, and so on of the data from the XML file is defined in the XSD file. That is, the structure of the HDS is determined by the XSD file. You should be aware of the following points about the XSD file in order to generate a correct report based on an XML format HDS with an XSD file.

Data type conversion table

Before the data type defined in the XSD file can function with JReport Designer, it should first be converted into a corresponding data type when the XML format hierarchical data source is imported, following the rules in the conversion table below.

XML Data Type JReport Data Type
SchemaSymbols.ATTVAL_BOOLEAN java.sql.Types.BIT
SchemaSymbols.ATTVAL_INT java.sql.Types.INTEGER
SchemaSymbols.ATTVAL_SHORT java.sql.Types.SMALLINT
SchemaSymbols.ATTVAL_BYTE java.sql.Types.TINYINT
SchemaSymbols.ATTVAL_INTEGER java.sql.Types.INTEGER
SchemaSymbols.ATTVAL_NONPOSITIVEINTEGER java.sql.Types.INTEGER
SchemaSymbols.ATTVAL_NEGATIVEINTEGER java.sql.Types.INTEGER
SchemaSymbols.ATTVAL_NONNEGATIVEINTEGER java.sql.Types.INTEGER
SchemaSymbols.ATTVAL_UNSIGNEDLONG java.sql.Types.BIGINT
SchemaSymbols.ATTVAL_LONG java.sql.Types.BIGINT
SchemaSymbols.ATTVAL_UNSIGNEDINT, //4294967295 java.sql.Types.BIGINT
SchemaSymbols.ATTVAL_UNSIGNEDSHORT, //65535  java.sql.Types.INTEGER
SchemaSymbols.ATTVAL_UNSIGNEDBYTE, //255 java.sql.Types.SMALLINT
SchemaSymbols.ATTVAL_POSITIVEINTEGER java.sql.Types.INTEGER
SchemaSymbols.ATTVAL_FLOAT java.sql.Types.FLOAT
SchemaSymbols.ATTVAL_DOUBLE java.sql.Types.DOUBLE
SchemaSymbols.ATTVAL_DECIMAL java.sql.Types.DECIMAL
SchemaSymbols.ATTVAL_STRING java.sql.Types.VARCHAR
SchemaSymbols.ATTVAL_DATE java.sql.Types.DATE
SchemaSymbols.ATTVAL_TIME java.sql.Types.TIME
SchemaSymbols.ATTVAL_DATETIME java.sql.Types.TIMESTAMP
SchemaSymbols.ATTVAL_HEXBINARY java.sql.Types.LONGVARBINARY

Note:

XSD structure supported by JReport Designer

In JReport Designer, not all XSD structures can be supported. The following diagrams show which structures are supported by JReport Designer.

Notes:

BackPrevious Page Next PageNext