Docmosis API 4.5.0

com.docmosis.template.population
Class GroupedSQLDataProviderPopulator

java.lang.Object
  extended bycom.docmosis.template.population.GroupedSQLDataProviderPopulator

public class GroupedSQLDataProviderPopulator
extends Object

A class responsible for plugging data into a data provider given an SQL Result Set and a data provider grouping.
This allows one to group bits of data together in one-to-many relationships, where many children nodes of data can belong to one group of data. Thus, the data can be organised to produce highly complex reports.
An example of what can be done with a grouped data provider populator is below:

 Main Data Provider
      | 
      +------- Organisation  (name)
                     |
                     +---------- Business_Unit  (name)
                     |                 |
                     |                 +---------- Employee  (name, title)
                     |                 |
                     |                 +---------- Employee  (name, title)
                     |
                     |---------- Business_Unit  (name)
                     |                 |
                     |                 +---------- Employee  (name, title)
                     |
                     |---------- Business_Unit  (name)
                                       |
                                       +---------- Employee  (name, title)
                                       |
                                       +---------- Employee  (name, title)
                                       |
                                       +---------- Employee  (name, title)
 
In this example, there is a data provider of key "Organisation". It has a field called "name" and contains three children data providers of key "Business_Unit". Each of the business units has a field called "name" and contains a number of children data providers of key "Employee". Each of the employee data providers has two fields, "name" and "title". To create this structure, three levels of grouping would be required. The top level of grouping would be "Organisation", followed by "Business_Unit" followed by "Employee". More than one type of field can be allowed in a grouping. This means that the grouping used will be an array of three DataProviderGrouping objects.
To read from this structure, one would use the following syntax in Java:
 - To get the organisation name:
 dp.getDataProvider("Organisation", 0).getString("name");
 
 - To get the second business unit's name:
 dp.getDataProvider("Organisation", 0).getDataProvider("Business_Unit", 1).getString("name");
 
 - To get the first employee's title of the third business unit:
 dp.getDataProvider("Organisation", 0).getDataProvider("Business_Unit", 2).getDataProvider("Employee", 0).getString("title");
 

See Also:
SimpleSQLDataProviderPopulator

Method Summary
static void populateDataProvider(MutableDataProvider dp, ResultSet resultSet, DataProviderGrouping[] grouping)
          Populate a data provider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

populateDataProvider

public static void populateDataProvider(MutableDataProvider dp,
                                        ResultSet resultSet,
                                        DataProviderGrouping[] grouping)
                                 throws SQLException,
                                        DataProviderGroupingException,
                                        NoSuchColumnNameException
Populate a data provider.

Parameters:
dp - the data provider to populate.
resultSet - the SQL result set containing all the data in a grid-like manner.
grouping - the various groupings for the data to be laid out in. Each element in the array represents the parent group of the next element.
Throws:
SQLException - if something goes wrong reading from the result set.
DataProviderGroupingException - for general grouping problems.
NoSuchColumnNameException - for invalid column names in the groupings.

Docmosis API 4.5.0

Copyright © 2014 Docmosis Pty Ltd. All Rights Reserved.