Search in sources :

Example 1 with AggregateFunctionType

use of org.dashbuilder.dataset.group.AggregateFunctionType in project jbpm by kiegroup.

the class CoreFunctionQueryParamBuilder method build.

@Override
public Object build() {
    if (filterParams.length == 0 || filterParams.length <= index) {
        return null;
    }
    QueryParam param = filterParams[index];
    index++;
    if ("group".equalsIgnoreCase(param.getOperator())) {
        // if operator is group consider it as group functions
        if (param.getValue().size() > 1) {
            return new GroupColumnFilter(param.getColumn(), (String) param.getValue().get(0), (String) param.getValue().get(1), (Integer) param.getValue().get(2));
        } else {
            return new GroupColumnFilter(param.getColumn(), (String) param.getValue().get(0), null, -1);
        }
    }
    // check core functions
    CoreFunctionType type = CoreFunctionType.getByName(param.getOperator());
    if (type != null) {
        return new CoreFunctionFilter(param.getColumn(), type, param.getValue());
    }
    LogicalExprType logicalExprType = LogicalExprType.getByName(param.getOperator());
    if (logicalExprType != null) {
        return new LogicalExprFilter(param.getColumn(), logicalExprType, (List<ColumnFilter>) param.getValue());
    }
    // check aggregate functions
    AggregateFunctionType aggregationType = AggregateFunctionType.getByName(param.getOperator());
    if (aggregationType != null) {
        return new AggregateColumnFilter(aggregationType, param.getColumn(), (String) param.getValue().get(0));
    }
    return new ExtraColumnFilter(param.getColumn(), (String) param.getValue().get(0));
}
Also used : CoreFunctionFilter(org.dashbuilder.dataset.filter.CoreFunctionFilter) AggregateFunctionType(org.dashbuilder.dataset.group.AggregateFunctionType) QueryParam(org.jbpm.services.api.query.model.QueryParam) LogicalExprType(org.dashbuilder.dataset.filter.LogicalExprType) CoreFunctionType(org.dashbuilder.dataset.filter.CoreFunctionType) ColumnFilter(org.dashbuilder.dataset.filter.ColumnFilter) LogicalExprFilter(org.dashbuilder.dataset.filter.LogicalExprFilter)

Aggregations

ColumnFilter (org.dashbuilder.dataset.filter.ColumnFilter)1 CoreFunctionFilter (org.dashbuilder.dataset.filter.CoreFunctionFilter)1 CoreFunctionType (org.dashbuilder.dataset.filter.CoreFunctionType)1 LogicalExprFilter (org.dashbuilder.dataset.filter.LogicalExprFilter)1 LogicalExprType (org.dashbuilder.dataset.filter.LogicalExprType)1 AggregateFunctionType (org.dashbuilder.dataset.group.AggregateFunctionType)1 QueryParam (org.jbpm.services.api.query.model.QueryParam)1