A data provider (data source) provides the data that a template uses to create a report.
The Windward Java Engine ships with two data providers:
- net.windward.datasource.dom4j.Dom4jDataSource – this provides data from an XML file using XPath to select groups.
- net.windward.datasource.jdbc.JdbcDataSource – this provides data from a SQL database using SQL to select groups.
The source to both providers is in WindwardReports.jar. The best way to create your own data source is to start with one of these files and edit it to meet your needs. Each is only 600 – 700 lines long, including numerous comments, so it generally is easy to create a new data source.
A data source is viewed as modeling an XML file. It is a collection of groups where each group has one parent and 0 – N children. These groups can be found and selected via a select statement of some type. The root group has no parent.
This may seem limiting but in practice almost all data can easily fit this model. In the case of SQL, any 1:1 and 1:many relationship in the data fits it perfectly. Many:1 also works fine as long as you view the 1 part as being the parent group. Many:many can be tricky but is generally able to be handled, although the select statements can become a bit complex.
You will find that the data provider implementation requires some code that generally could be handled by Windward Reports and not pushed down to the provider. However, for the rare cases where the data provider needs to handle an issue in a non-standard way, all work was pushed down to the data-provider level. For example, while the out tag has a default value, it is up to the data provider to use that value if a group does not exist. This way the default value can be a key to the actual default value instead of being limited to being the literal string.
Writing Your Own
To create your own data provider, please refer to the Windward Data Source Guide.