Search in sources :

Example 1 with ColumnFilter

use of org.dashbuilder.dataset.filter.ColumnFilter in project jbpm by kiegroup.

the class TestQueryParamBuilder method build.

@Override
public ColumnFilter build() {
    // return null if it was already invoked
    if (built) {
        return null;
    }
    String columnName = "processInstanceId";
    ColumnFilter filter = FilterFactory.OR(FilterFactory.greaterOrEqualsTo((Long) parameters.get("min")), FilterFactory.lowerOrEqualsTo((Long) parameters.get("max")));
    filter.setColumnId(columnName);
    built = true;
    return filter;
}
Also used : ColumnFilter(org.dashbuilder.dataset.filter.ColumnFilter)

Example 2 with ColumnFilter

use of org.dashbuilder.dataset.filter.ColumnFilter 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)

Example 3 with ColumnFilter

use of org.dashbuilder.dataset.filter.ColumnFilter in project jbpm by kiegroup.

the class CoreFunctionQueryParamBuilderTest method testLogicalExprPassedAsQueryParam.

@Test
public void testLogicalExprPassedAsQueryParam() {
    ArrayList values = new ArrayList();
    values.add("value1");
    values.add("value2");
    final ColumnFilter filter1 = likeTo(COLUMN_PROCESSNAME, "%processName%");
    final ColumnFilter filter2 = likeTo(COLUMN_PROCESSID, "%processName%");
    ArrayList terms = new ArrayList();
    terms.add(filter1);
    terms.add(filter2);
    QueryParam queryParam = new QueryParam("", LogicalExprType.OR.toString(), terms);
    ArrayList queryParams = new ArrayList();
    queryParams.add(queryParam);
    coreFunctionQueryParamBuilder = new CoreFunctionQueryParamBuilder(queryParam);
    Object builded = coreFunctionQueryParamBuilder.build();
    assertTrue(builded instanceof LogicalExprFilter);
    assertEquals("(" + COLUMN_PROCESSNAME + " like %processName%, true OR " + COLUMN_PROCESSID + " like %processName%, true)", builded.toString());
}
Also used : QueryParam(org.jbpm.services.api.query.model.QueryParam) ArrayList(java.util.ArrayList) ColumnFilter(org.dashbuilder.dataset.filter.ColumnFilter) LogicalExprFilter(org.dashbuilder.dataset.filter.LogicalExprFilter) Test(org.junit.Test)

Example 4 with ColumnFilter

use of org.dashbuilder.dataset.filter.ColumnFilter in project jbpm by kiegroup.

the class BusinessAdminTasksPreprocessor method preprocess.

@SuppressWarnings("rawtypes")
@Override
public void preprocess(DataSetLookup lookup) {
    if (identityProvider == null) {
        return;
    }
    if (ADMIN_USER.equals(identityProvider.getName()) || identityProvider.getRoles().stream().filter(s -> s.equals(ADMIN_GROUP)).findFirst().isPresent()) {
        return;
    }
    final List<Comparable> orgEntities = new ArrayList<Comparable>(identityProvider.getRoles());
    orgEntities.add(identityProvider.getName());
    final ColumnFilter columnFilter = equalsTo(COLUMN_ORGANIZATIONAL_ENTITY, orgEntities);
    LOGGER.debug("Adding column filter: {}", columnFilter);
    if (lookup.getFirstFilterOp() != null) {
        lookup.getFirstFilterOp().addFilterColumn(columnFilter);
    } else {
        DataSetFilter filter = new DataSetFilter();
        filter.addFilterColumn(columnFilter);
        lookup.addOperation(filter);
    }
    super.preprocess(lookup);
}
Also used : FilterFactory.equalsTo(org.dashbuilder.dataset.filter.FilterFactory.equalsTo) IdentityProvider(org.kie.internal.identity.IdentityProvider) COLUMN_ORGANIZATIONAL_ENTITY(org.jbpm.services.api.query.QueryResultMapper.COLUMN_ORGANIZATIONAL_ENTITY) DataSetLookup(org.dashbuilder.dataset.DataSetLookup) List(java.util.List) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) ColumnFilter(org.dashbuilder.dataset.filter.ColumnFilter) DataSetMetadata(org.dashbuilder.dataset.DataSetMetadata) DataSetFilter(org.dashbuilder.dataset.filter.DataSetFilter) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) DataSetFilter(org.dashbuilder.dataset.filter.DataSetFilter) ColumnFilter(org.dashbuilder.dataset.filter.ColumnFilter)

Example 5 with ColumnFilter

use of org.dashbuilder.dataset.filter.ColumnFilter in project jbpm by kiegroup.

the class DeploymentIdsPreprocessor method preprocess.

@Override
public void preprocess(DataSetLookup lookup) {
    if (identityProvider == null) {
        return;
    }
    final List<String> deploymentIds = deploymentRolesManager.getDeploymentsForUser(identityProvider);
    final ColumnFilter columnFilter = in(columnId, deploymentIds);
    LOGGER.debug("Adding column filter: {}", columnFilter);
    if (lookup.getFirstFilterOp() != null) {
        lookup.getFirstFilterOp().addFilterColumn(columnFilter);
    } else {
        DataSetFilter filter = new DataSetFilter();
        filter.addFilterColumn(columnFilter);
        lookup.addOperation(filter);
    }
}
Also used : DataSetFilter(org.dashbuilder.dataset.filter.DataSetFilter) ColumnFilter(org.dashbuilder.dataset.filter.ColumnFilter)

Aggregations

ColumnFilter (org.dashbuilder.dataset.filter.ColumnFilter)8 ArrayList (java.util.ArrayList)4 DataSetFilter (org.dashbuilder.dataset.filter.DataSetFilter)3 List (java.util.List)2 LogicalExprFilter (org.dashbuilder.dataset.filter.LogicalExprFilter)2 QueryParam (org.jbpm.services.api.query.model.QueryParam)2 DataSet (org.dashbuilder.dataset.DataSet)1 DataSetLookup (org.dashbuilder.dataset.DataSetLookup)1 DataSetMetadata (org.dashbuilder.dataset.DataSetMetadata)1 CoreFunctionFilter (org.dashbuilder.dataset.filter.CoreFunctionFilter)1 CoreFunctionType (org.dashbuilder.dataset.filter.CoreFunctionType)1 FilterFactory.equalsTo (org.dashbuilder.dataset.filter.FilterFactory.equalsTo)1 LogicalExprType (org.dashbuilder.dataset.filter.LogicalExprType)1 AggregateFunctionType (org.dashbuilder.dataset.group.AggregateFunctionType)1 AbstractDataSetLookupBuilder (org.dashbuilder.dataset.impl.AbstractDataSetLookupBuilder)1 QueryNotFoundException (org.jbpm.services.api.query.QueryNotFoundException)1 COLUMN_ORGANIZATIONAL_ENTITY (org.jbpm.services.api.query.QueryResultMapper.COLUMN_ORGANIZATIONAL_ENTITY)1 Test (org.junit.Test)1 AdvancedQueryContext (org.kie.api.runtime.query.AdvancedQueryContext)1 UserGroupCallback (org.kie.api.task.UserGroupCallback)1