public class AggregationInfo
extends java.lang.Object
//This is a batch data request with aggregation type requests over two objects (V0101 and F060116) //Set used capabilities in login environment loginEnv.getUsedCapabilities().add(AISClientCapability.DATA_SERVICE); loginEnv.getUsedCapabilities().add(AISClientCapability.DATA_SERVICE_AGGREGATION); //create a new data request for V0101 DataRequest dataAggregation = new DataRequest(loginEnv); //set type to aggregation dataAggregation.setDataServiceType(DataRequest.TYPE_AGGREGATION); dataAggregation.setTargetName("V0101"); dataAggregation.setTargetType(DataRequest.TARGET_VIEW); //create aggergation info object AggregationInfo aggregation = new AggregationInfo(loginEnv); //add desired aggregations aggregation.addAggregationColumn("AN8", AggregationType.AGG_TYPE_SUM()); aggregation.addAggregationColumn("AN8", AggregationType.AGG_TYPE_AVG()); aggregation.addAggregationColumn("AT1", AggregationType.AGG_TYPE_COUNT_DISTINCT()); aggregation.addCount(); //this is for COUNT * //add aggregation to request dataAggregation.setAggregation(aggregation); //query can be combined with aggregation Query an8Query = new Query(loginEnv); an8Query.setAutoFind(true); an8Query.setMatchType(Query.MATCH_ALL); an8Query.addNumberCondition("F0101.AN8", NumericOperator.LESS(), 6001); dataAggregation.setQuery(an8Query); //create a second datat request for F060116 aggregatoin DataRequest dataAggregation2 = new DataRequest(loginEnv); dataAggregation2.setFindOnEntry(true); dataAggregation2.setDataServiceType(DataRequest.TYPE_AGGREGATION); dataAggregation2.setTargetName("F060116"); dataAggregation2.setTargetType(DataRequest.TARGET_TABLE); //create aggregation info object and add desired aggredgations AggregationInfo aggregation2 = new AggregationInfo(loginEnv); aggregation2.addAggregationColumn("SAL", AggregationType.AGG_TYPE_SUM()); aggregation2.addAggregationColumn("SAL", AggregationType.AGG_TYPE_AVG()); aggregation2.addAggregationColumn("SAL", AggregationType.AGG_TYPE_AVG_DISTINCT()); aggregation2.addAggregationColumn("SAL", AggregationType.AGG_TYPE_MAX()); aggregation2.addAggregationColumn("SAL", AggregationType.AGG_TYPE_MIN()); aggregation2.addAggregationColumn("SAL", AggregationType.AGG_TYPE_SUM_DISTINCT()); aggregation2.addCount(); aggregation2.addAggregationColumn("AN8", AggregationType.AGG_TYPE_COUNT_DISTINCT()); //add desired group by columnst aggregation2.addAggregationGroupBy("HMCO"); aggregation2.addAggregationGroupBy("HMCU"); //add desired order by with direction aggregation2.addAggregationOrderBy("HMCO", OrderByDirection.ORDER_DIRECT_DESCENDING()); //set the aggregation info in the request dataAggregation2.setAggregation(aggregation2); //add these two requests to a batch data request BatchDataRequest batchDataRequest = new BatchDataRequest(loginEnv); batchDataRequest.getDataRequests().add(dataAggregation); batchDataRequest.getDataRequests().add(dataAggregation2); //call the service String response = JDERestServiceProvider.jdeRestServiceCall(loginEnv, batchDataRequest, JDERestServiceProvider.POST_METHOD, JDERestServiceProvider.DATA_SERVICE_URI); //get the number of distinct AT1 values JsonNode distinct = AggregationResponseHelper.getSimpleAggregateValueBatch(response, "V0101", 0, AggregationType.AGG_TYPE_COUNT_DISTINCT(), "AT1"); if (distinct != null) { System.out.println("AT1 Distinct: " + distinct.asInt()); } //get the count * System.out.println("Count: " +AggregationResponseHelper.getCountBatch(response, "V0101", 0)); //get the groupbed aggregations from the F060116 response, loop trhough and add the specific one (average to a hash map by group by) ArrayNode array = AggregationResponseHelper.getAggregateValuesArrayBatch(response, "F060116", 1); HashMapchartMap = new HashMap (); for (Iterator groups = array.iterator(); groups.hasNext();) { JsonNode aGroup = (JsonNode) groups.next(); JsonNode groupByInfo = aGroup.get(AggregationResponseHelper.GROUP_BY); JsonNode average = aGroup.get("SAL_SUM"); chartMap.put(groupByInfo.get("HMCO").asText().trim() + "-" + groupByInfo.get("HMCU").asText().trim(), average.asDouble()); } //print the map System.out.println("SAL SUM by HMCO/HMCU Map: " + chartMap);
Modifier and Type | Class and Description |
---|---|
static class |
AggregationInfo.CurrencyProcessing
Used for providing currency decimal processing parameters within an aggregation request.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CALENDAR_QUARTER |
protected static java.lang.String |
COUNT |
static java.lang.String |
DATE_USER_FORMATTED |
Constructor and Description |
---|
AggregationInfo(LoginEnvironment loginEnv) |
Modifier and Type | Method and Description |
---|---|
void |
addAggregationColumn(java.lang.String columnId,
AggregationType type)
Deprecated.
As of release 1.5.0, replaced by
addAggregationColumn(String tableId,String columnId, AggregationType type) |
void |
addAggregationColumn(java.lang.String tableId,
java.lang.String columnId,
AggregationType type)
Use this method to add an aggregation column to the request
|
void |
addAggregationGroupBy(LoginEnvironment loginEnv,
java.lang.String tableId,
java.lang.String columnId,
java.text.SimpleDateFormat simpleDateFormat)
Use this method to add an aggregation group by to the request, with a special date group by based on SimpleDateFormat
The result will be grouped by date and the dates will be formated in the requested format
|
void |
addAggregationGroupBy(LoginEnvironment loginEnv,
java.lang.String tableId,
java.lang.String columnId,
java.lang.String specialHandling)
Use this method to add an aggregation group by to the request, with a special date group by string (use constants)
|
void |
addAggregationGroupBy(java.lang.String columnId)
Deprecated.
As of release 1.5.0, replaced by
addAggregationGroupBy(String tableId,String columnId) |
void |
addAggregationGroupBy(java.lang.String tableId,
java.lang.String columnId)
Use this method to add an aggregation group by to the request
|
void |
addAggregationOrderBy(java.lang.String columnId,
AggregationType aggregation,
OrderByDirection direction)
Deprecated.
As of release 1.5.0, replaced by
addAggregationOrderBy(String tableId, String columnId, AggregationType aggregation, OrderByDirection direction) |
void |
addAggregationOrderBy(java.lang.String columnId,
OrderByDirection direction)
Deprecated.
As of release 1.5.0, replaced by
addAggregationOrderBy(String tableId,String columnId, OrderByDirection direction) |
void |
addAggregationOrderBy(java.lang.String tableId,
java.lang.String columnId,
AggregationType aggregation,
OrderByDirection direction)
Use this method to add an order by to the aggregation request, where the order is based on an aggregation result
|
void |
addAggregationOrderBy(java.lang.String tableId,
java.lang.String columnId,
OrderByDirection direction)
Use this method to add an order by to the aggregation request
|
void |
addAggregationOrderByCount(OrderByDirection direction)
Use this method to add an order by to the aggregation request, where the order is based on a count result
|
void |
addCount()
Use this method to request a COUNT * aggregation
|
java.util.ArrayList<AggregationItem> |
getAggregations() |
AggregationInfo.CurrencyProcessing |
getCurrency() |
java.util.ArrayList<AggregationItem> |
getGroupBy() |
java.util.ArrayList<AggregationItem> |
getOrderBy() |
protected void |
setAggregations(java.util.ArrayList<AggregationItem> aggregations) |
void |
setCurrency(AggregationInfo.CurrencyProcessing currency) |
protected void |
setGroupBy(java.util.ArrayList<AggregationItem> groupBy) |
protected void |
setOrderBy(java.util.ArrayList<AggregationItem> orderBy) |
protected void |
setSingleAggregations(AggregationItem aggregations) |
protected void |
setSingleGroupBy(AggregationItem groupBy) |
protected void |
setSingleOrderBy(AggregationItem orderBy) |
protected static final java.lang.String COUNT
public static final java.lang.String DATE_USER_FORMATTED
public static final java.lang.String CALENDAR_QUARTER
public AggregationInfo(LoginEnvironment loginEnv) throws CapabilityException
CapabilityException
public void addCount()
@Deprecated public void addAggregationColumn(java.lang.String columnId, AggregationType type)
addAggregationColumn(String tableId,String columnId, AggregationType type)
public void addAggregationColumn(java.lang.String tableId, java.lang.String columnId, AggregationType type)
tableId
- columnId
- type
- @Deprecated public void addAggregationGroupBy(java.lang.String columnId)
addAggregationGroupBy(String tableId,String columnId)
public void addAggregationGroupBy(java.lang.String tableId, java.lang.String columnId)
tableId
- columnId
- public void addAggregationGroupBy(LoginEnvironment loginEnv, java.lang.String tableId, java.lang.String columnId, java.lang.String specialHandling) throws CapabilityException
tableId
- columnId
- CapabilityException
public void addAggregationGroupBy(LoginEnvironment loginEnv, java.lang.String tableId, java.lang.String columnId, java.text.SimpleDateFormat simpleDateFormat) throws CapabilityException
loginEnv
- tableId
- columnId
- simpleDateFormat
- CapabilityException
@Deprecated public void addAggregationOrderBy(java.lang.String columnId, OrderByDirection direction)
addAggregationOrderBy(String tableId,String columnId, OrderByDirection direction)
public void addAggregationOrderBy(java.lang.String tableId, java.lang.String columnId, OrderByDirection direction)
tableId
- columnId
- direction
- @Deprecated public void addAggregationOrderBy(java.lang.String columnId, AggregationType aggregation, OrderByDirection direction)
addAggregationOrderBy(String tableId, String columnId, AggregationType aggregation, OrderByDirection direction)
columnId
- aggregation
- direction
- public void addAggregationOrderBy(java.lang.String tableId, java.lang.String columnId, AggregationType aggregation, OrderByDirection direction)
tableId
- columnId
- aggregation
- direction
- public void addAggregationOrderByCount(OrderByDirection direction)
direction
- protected void setSingleAggregations(AggregationItem aggregations)
protected void setAggregations(java.util.ArrayList<AggregationItem> aggregations)
public java.util.ArrayList<AggregationItem> getAggregations()
protected void setSingleGroupBy(AggregationItem groupBy)
public java.util.ArrayList<AggregationItem> getGroupBy()
protected void setSingleOrderBy(AggregationItem orderBy)
public java.util.ArrayList<AggregationItem> getOrderBy()
protected void setGroupBy(java.util.ArrayList<AggregationItem> groupBy)
protected void setOrderBy(java.util.ArrayList<AggregationItem> orderBy)
public void setCurrency(AggregationInfo.CurrencyProcessing currency)
public AggregationInfo.CurrencyProcessing getCurrency()
Copyright © 2017 Oracle and/or its affiliates. All Rights Reserved.