Java Code Examples for org.camunda.bpm.engine.filter.Filter#getQuery()
The following examples show how to use
org.camunda.bpm.engine.filter.Filter#getQuery() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterManager.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public Filter insertOrUpdateFilter(Filter filter) { AbstractQuery<?, ?> query = filter.getQuery(); query.validate(StoredQueryValidator.get()); if (filter.getId() == null) { checkAuthorization(CREATE, FILTER, ANY); getDbEntityManager().insert((FilterEntity) filter); createDefaultAuthorizations(filter); } else { checkAuthorization(UPDATE, FILTER, filter.getId()); getDbEntityManager().merge((FilterEntity) filter); } return filter; }
Example 2
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testExtendTaskQueryWithCandidateUserExpressionAndIncludeAssignedTasks() { // create an empty query and save it as a filter TaskQuery emptyQuery = taskService.createTaskQuery(); Filter emptyFilter = filterService.newTaskFilter("empty"); emptyFilter.setQuery(emptyQuery); // create a query with candidate user expression and include assigned tasks // and save it as filter TaskQuery query = taskService.createTaskQuery(); query.taskCandidateUserExpression("${'test'}").includeAssignedTasks(); Filter filter = filterService.newTaskFilter("filter"); filter.setQuery(query); // extend empty query by query with candidate user expression and include assigned tasks Filter extendedFilter = emptyFilter.extend(query); TaskQueryImpl extendedQuery = extendedFilter.getQuery(); assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateUser")); assertTrue(extendedQuery.isIncludeAssignedTasks()); // extend query with candidate user expression and include assigned tasks with empty query extendedFilter = filter.extend(emptyQuery); extendedQuery = extendedFilter.getQuery(); assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateUser")); assertTrue(extendedQuery.isIncludeAssignedTasks()); }
Example 3
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testExtendTaskQueryWithCandidateGroupExpressionAndIncludeAssignedTasks() { // create an empty query and save it as a filter TaskQuery emptyQuery = taskService.createTaskQuery(); Filter emptyFilter = filterService.newTaskFilter("empty"); emptyFilter.setQuery(emptyQuery); // create a query with candidate group expression and include assigned tasks // and save it as filter TaskQuery query = taskService.createTaskQuery(); query.taskCandidateGroupExpression("${'test'}").includeAssignedTasks(); Filter filter = filterService.newTaskFilter("filter"); filter.setQuery(query); // extend empty query by query with candidate group expression and include assigned tasks Filter extendedFilter = emptyFilter.extend(query); TaskQueryImpl extendedQuery = extendedFilter.getQuery(); assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateGroup")); assertTrue(extendedQuery.isIncludeAssignedTasks()); // extend query with candidate group expression and include assigned tasks with empty query extendedFilter = filter.extend(emptyQuery); extendedQuery = extendedFilter.getQuery(); assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateGroup")); assertTrue(extendedQuery.isIncludeAssignedTasks()); }
Example 4
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testExtendTaskQueryWithCandidateGroupInAndCandidateGroup() { // create an query with candidate group in and save it as a filter TaskQueryImpl candidateGroupInQuery = (TaskQueryImpl)taskService.createTaskQuery().taskCandidateGroupIn(Arrays.asList("testGroup", "testGroup2")); assertEquals(2, candidateGroupInQuery.getCandidateGroups().size()); assertEquals("testGroup", candidateGroupInQuery.getCandidateGroups().get(0)); assertEquals("testGroup2", candidateGroupInQuery.getCandidateGroups().get(1)); Filter candidateGroupInFilter = filterService.newTaskFilter("Groups filter"); candidateGroupInFilter.setQuery(candidateGroupInQuery); // create a query with candidate group // and save it as filter TaskQuery candidateGroupQuery = taskService.createTaskQuery().taskCandidateGroup("testGroup2"); // extend candidate group in filter by query with candidate group Filter extendedFilter = candidateGroupInFilter.extend(candidateGroupQuery); TaskQueryImpl extendedQuery = extendedFilter.getQuery(); assertEquals(1, extendedQuery.getCandidateGroups().size()); assertEquals("testGroup2", extendedQuery.getCandidateGroups().get(0)); }
Example 5
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testExtendTaskQueryWithCandidateGroupInExpressionAndIncludeAssignedTasks() { // create an empty query and save it as a filter TaskQuery emptyQuery = taskService.createTaskQuery(); Filter emptyFilter = filterService.newTaskFilter("empty"); emptyFilter.setQuery(emptyQuery); // create a query with candidate group in expression and include assigned tasks // and save it as filter TaskQuery query = taskService.createTaskQuery(); query.taskCandidateGroupInExpression("${'test'}").includeAssignedTasks(); Filter filter = filterService.newTaskFilter("filter"); filter.setQuery(query); // extend empty query by query with candidate group in expression and include assigned tasks Filter extendedFilter = emptyFilter.extend(query); TaskQueryImpl extendedQuery = extendedFilter.getQuery(); assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateGroupIn")); assertTrue(extendedQuery.isIncludeAssignedTasks()); // extend query with candidate group in expression and include assigned tasks with empty query extendedFilter = filter.extend(emptyQuery); extendedQuery = extendedFilter.getQuery(); assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateGroupIn")); assertTrue(extendedQuery.isIncludeAssignedTasks()); }
Example 6
Source File: AbstractExecuteFilterCmd.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected Query<?, ?> getFilterQuery(CommandContext commandContext) { Filter filter = getFilter(commandContext); Query<?, ?> query = filter.getQuery(); if (query instanceof TaskQuery) { ((TaskQuery) query).initializeFormKeys(); } return query; }
Example 7
Source File: MultiTenancyFilterServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testCreateFilterWithTenantIdCriteria() { TaskQuery query = taskService.createTaskQuery().tenantIdIn(TENANT_IDS); filterId = createFilter(query); Filter savedFilter = filterService.getFilter(filterId); TaskQueryImpl savedQuery = savedFilter.getQuery(); assertThat(savedQuery.getTenantIds(), is(TENANT_IDS)); }
Example 8
Source File: MultiTenancyFilterServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testCreateFilterWithNoTenantIdCriteria() { TaskQuery query = taskService.createTaskQuery().withoutTenantId(); filterId = createFilter(query); Filter savedFilter = filterService.getFilter(filterId); TaskQueryImpl savedQuery = savedFilter.getQuery(); assertThat(savedQuery.isTenantIdSet(), is(true)); assertThat(savedQuery.getTenantIds(), is(nullValue())); }
Example 9
Source File: FilterServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testExtendFilter() { TaskQuery extendingQuery = taskService.createTaskQuery() .taskName("newName") .taskOwner("newOwner"); Filter newFilter = filter.extend(extendingQuery); assertNull(newFilter.getId()); TaskQueryImpl filterQuery = newFilter.getQuery(); assertEquals("newName", filterQuery.getName()); assertEquals("newOwner", filterQuery.getOwner()); }
Example 10
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testExtendingSorting() { // create empty query TaskQueryImpl query = (TaskQueryImpl) taskService.createTaskQuery(); saveQuery(query); // assert default sorting query = filter.getQuery(); assertTrue(query.getOrderingProperties().isEmpty()); // extend query by new task query with sorting TaskQueryImpl sortQuery = (TaskQueryImpl) taskService.createTaskQuery().orderByTaskName().asc(); Filter extendedFilter = filter.extend(sortQuery); query = extendedFilter.getQuery(); List<QueryOrderingProperty> expectedOrderingProperties = new ArrayList<QueryOrderingProperty>(sortQuery.getOrderingProperties()); verifyOrderingProperties(expectedOrderingProperties, query.getOrderingProperties()); // extend query by new task query with additional sorting TaskQueryImpl extendingQuery = (TaskQueryImpl) taskService.createTaskQuery().orderByTaskAssignee().desc(); extendedFilter = extendedFilter.extend(extendingQuery); query = extendedFilter.getQuery(); expectedOrderingProperties.addAll(extendingQuery.getOrderingProperties()); verifyOrderingProperties(expectedOrderingProperties, query.getOrderingProperties()); // extend query by incomplete sorting query (should add sorting anyway) sortQuery = (TaskQueryImpl) taskService.createTaskQuery().orderByCaseExecutionId(); extendedFilter = extendedFilter.extend(sortQuery); query = extendedFilter.getQuery(); expectedOrderingProperties.addAll(sortQuery.getOrderingProperties()); verifyOrderingProperties(expectedOrderingProperties, query.getOrderingProperties()); }
Example 11
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void testExtendingVariableQuery() { TaskQuery taskQuery = taskService.createTaskQuery().processVariableValueEquals("hello", "world"); saveQuery(taskQuery); // variables won't overridden variables with same name in different scopes TaskQuery extendingQuery = taskService.createTaskQuery() .taskVariableValueEquals("hello", "world") .caseInstanceVariableValueEquals("hello", "world"); Filter extendedFilter = filter.extend(extendingQuery); TaskQueryImpl extendedQuery = extendedFilter.getQuery(); List<TaskQueryVariableValue> variables = extendedQuery.getVariables(); assertEquals(3, variables.size()); // assert variables (ordering: extending variables are inserted first) assertEquals("hello", variables.get(0).getName()); assertEquals("world", variables.get(0).getValue()); assertEquals(QueryOperator.EQUALS, variables.get(0).getOperator()); assertFalse(variables.get(0).isProcessInstanceVariable()); assertTrue(variables.get(0).isLocal()); assertEquals("hello", variables.get(1).getName()); assertEquals("world", variables.get(1).getValue()); assertEquals(QueryOperator.EQUALS, variables.get(1).getOperator()); assertFalse(variables.get(1).isProcessInstanceVariable()); assertFalse(variables.get(1).isLocal()); assertEquals("hello", variables.get(2).getName()); assertEquals("world", variables.get(2).getValue()); assertEquals(QueryOperator.EQUALS, variables.get(2).getOperator()); assertTrue(variables.get(2).isProcessInstanceVariable()); assertFalse(variables.get(2).isLocal()); // variables will override variables with same name in same scope extendingQuery = taskService.createTaskQuery() .processVariableValueLessThan("hello", 42) .taskVariableValueLessThan("hello", 42) .caseInstanceVariableValueLessThan("hello", 42); extendedFilter = filter.extend(extendingQuery); extendedQuery = extendedFilter.getQuery(); variables = extendedQuery.getVariables(); assertEquals(3, variables.size()); // assert variables (ordering: extending variables are inserted first) assertEquals("hello", variables.get(0).getName()); assertEquals(42, variables.get(0).getValue()); assertEquals(QueryOperator.LESS_THAN, variables.get(0).getOperator()); assertTrue(variables.get(0).isProcessInstanceVariable()); assertFalse(variables.get(0).isLocal()); assertEquals("hello", variables.get(1).getName()); assertEquals(42, variables.get(1).getValue()); assertEquals(QueryOperator.LESS_THAN, variables.get(1).getOperator()); assertFalse(variables.get(1).isProcessInstanceVariable()); assertTrue(variables.get(1).isLocal()); assertEquals("hello", variables.get(2).getName()); assertEquals(42, variables.get(2).getValue()); assertEquals(QueryOperator.LESS_THAN, variables.get(2).getOperator()); assertFalse(variables.get(2).isProcessInstanceVariable()); assertFalse(variables.get(2).isLocal()); }