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;
}
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));
}
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());
}
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);
}
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);
}
}
Aggregations