net.sf.jett.tag.AggTag Maven / Gradle / Ivy
package net.sf.jett.tag;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.apache.poi.ss.usermodel.RichTextString;
import net.sf.jagg.AggregateFunction;
import net.sf.jagg.Aggregation;
import net.sf.jagg.Aggregator;
import net.sf.jagg.exception.JaggException;
import net.sf.jagg.model.AggregateValue;
import net.sf.jett.exception.TagParseException;
import net.sf.jett.transform.BlockTransformer;
import net.sf.jett.util.AttributeUtil;
/**
* An AggTag
represents possibly many aggregate values
* calculated from a List
of values already exposed to the
* context. It uses jAgg
functionality and exposes the results
* and AggregateFunctions
used for display later.
*
*
Attributes:
*
* - Inherits all attributes from {@link BaseTag}.
* - items (required):
List
* - aggs (required):
String
* - aggsVar (optional):
String
* - valuesVar (required):
String
* - groupBy (optional):
String
* - parallel (optional):
int
* - useMsd (optional):
boolean
* - rollup (optional):
int[]
* - rollups (optional):
int[][]
* - cube (optional):
int[]
* - groupingSets (optional):
int[][]
*
*
* @author Randy Gettman
*/
public class AggTag extends BaseTag
{
/**
* Attribute that specifies the List
of items to aggregate.
*/
public static final String ATTR_ITEMS = "items";
/**
* Attribute that specifies the List
of AggregateFunctions to use.
*/
public static final String ATTR_AGGS = "aggs";
/**
* Attribute that specifies the name of the List
of exposed
* aggregate functions.
*/
public static final String ATTR_AGGS_VAR = "aggsVar";
/**
* Attribute that specifies name of the List
of exposed
* aggregation values.
*/
public static final String ATTR_VALUES_VAR = "valuesVar";
/**
* Attribute that specifies the List
of group-by properties.
*/
public static final String ATTR_GROUP_BY = "groupBy";
/**
* Attribute that specifies the degree of parallelism to use.
*/
public static final String ATTR_PARALLEL = "parallel";
/**
* Attribute that specifies whether to use Multiset Discrimination instead
* of sorting during aggregation processing. This means that the results
* will not be sorted by the "group by" properties. It defaults to
* false
-- don't use Multiset Discrimination, use sorting.
* @since 0.4.0
*/
public static final String ATTR_USE_MSD = "useMsd";
/**
* Attribute that specifies a rollup that should occur on the results.
* Specify a List
of 0-based integer indexes that reference the
* original list of properties. E.g. when grouping by two properties,
* prop1
and prop2
, specifying a List
* of {0}
specifies a rollup on prop1
.
* @since 0.4.0
* @see #ATTR_GROUP_BY
*/
public static final String ATTR_ROLLUP = "rollup";
/**
* Attribute that specifies multiple rollups that should occur on the
* results. Specify a List
of Lists
of 0-based
* integer indexes that reference the original list of properties. E.g.
* when grouping by three properties,
* prop1
, prop2
, and prop3
,
* specifying a List
of {{0}, {1, 2}}
specifies a
* rollup on prop1
, and a separate rollup on prop2
* and prop3
.
* @since 0.4.0
* @see #ATTR_GROUP_BY
*/
public static final String ATTR_ROLLUPS = "rollups";
/**
* Attribute that specifies a data cube that should occur on the results.
* Specify a List
of 0-based integer indexes that reference the
* original list of properties. E.g. when grouping by three properties,
* prop1
, prop2
, and prop3
,
* specifying a List
of {0, 1}
specifies a cube on
* prop1
and prop2
.
* @since 0.4.0
* @see #ATTR_GROUP_BY
*/
public static final String ATTR_CUBE = "cube";
/**
* Attribute that specifies the exact grouping sets that should occur on the
* results. Specify a List
of Lists
of 0-based
* integer indexes that reference the original list of properties. E.g.
* when grouping by three properties, prop1
,
* prop2
, and prop3
, specifying a
* List
of {{0}, {1, 2}, {}}
specifies a
* grouping set on prop1
, a separate grouping set on
* prop2
and prop3
, and a third grouping set on no
* properties (a grand total).
* @since 0.4.0
* @see #ATTR_GROUP_BY
*/
public static final String ATTR_GROUPING_SETS = "groupingSets";
private static final List REQ_ATTRS =
new ArrayList<>(Arrays.asList(ATTR_ITEMS, ATTR_AGGS, ATTR_VALUES_VAR));
private static final List OPT_ATTRS =
new ArrayList<>(Arrays.asList(ATTR_AGGS_VAR, ATTR_GROUP_BY, ATTR_PARALLEL, ATTR_USE_MSD, ATTR_ROLLUP,
ATTR_ROLLUPS, ATTR_CUBE, ATTR_GROUPING_SETS));
private List