One-Dimensional Queries

You can use a grouping DataSource to return one-dimensional data set. First, define the DataSource with one grouping field in AXVW (you can use calculated grouping field with a formula or with an SQL expression as well):

<dataSource type="grouping" id="roomAreaByRoomStandardDataSource">
<table name="rm"/>

<!-- Group records by room standard -->
<field name="rm_std" groupBy="true"/>

<!-- Calculate sum of room area. -->
<field name="total_area" formula="sum" baseField="rm.area" dataType="number" size="6" decimals="0">
<title>Total Area</title>
</field>
</dataSource>


This DataSource can be used as is with any standard panel such as grid. But you can also load and use it from within a workflow rule code:

DataSourceGroupingImpl ds = (DataSourceGroupingImpl) DataSourceFactory.loadDataSourceFromFile( "ab-ex-custom-chart.axvw", "requestDs");


You can now use the grouping data source instance to get grouped records and their totals:

List<DataRecord> records = ds.getRecords(restriction);
List<DataRecord> totals = ds.getTotals(restriction);


The records list contains grouped records, with one value per "measure" (calculated visible field).

The totals list contains records for all "dimension" (calculated grouping field) values, one value in each record.

Web Central also provides a specialized Data Set class that packages 1D data into a format that preserves the grouping field information that can be used on the client:

// specify the grouping field name in the constructor
DataSet1D dataSet = new DataSet1D("rm.rm_std");
dataSet.addRecords(records);
dataSet.addTotals(totals);
return dataSet;

On the client the WFR result will be represented by an Ab.data.DataSet1D object instead of a list of records.