Java Code Examples for org.camunda.bpm.engine.filter.Filter#extend()

The following examples show how to use org.camunda.bpm.engine.filter.Filter#extend() . 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: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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 2
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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 3
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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 4
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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 5
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
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());
}