Java Code Examples for org.camunda.bpm.engine.filter.Filter#setQuery()
The following examples show how to use
org.camunda.bpm.engine.filter.Filter#setQuery() .
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 |
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void testIntOutOfRangeVariable() { // given runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("longVariable", Integer.MAX_VALUE+1L)); TaskQuery query = taskService.createTaskQuery() .processVariableValueEquals("longVariable", Integer.MAX_VALUE+1L); Filter filter = filterService.newTaskFilter("filter"); filter.setQuery(query); // when filterService.saveFilter(filter); // then assertThat(filterService.count(filter.getId()), is(1L)); }
Example 2
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 3
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void testBooleanVariable() { // given runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("booleanVariable", true)); TaskQuery query = taskService.createTaskQuery() .processVariableValueEquals("booleanVariable", true); Filter filter = filterService.newTaskFilter("filter"); filter.setQuery(query); // when filterService.saveFilter(filter); // then assertThat(filterService.count(filter.getId()), is(1L)); }
Example 4
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 5
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 6
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testTaskQueryByBusinessKeyLikeExpressionInAdhocQuery() { // given processEngineConfiguration.setEnableExpressionsInAdhocQueries(true); String aBusinessKey = "business key"; Mocks.register("aBusinessKeyLike", "%" + aBusinessKey.substring(5)); createDeploymentWithBusinessKey(aBusinessKey); // when Filter filter = filterService.newTaskFilter("aFilterName"); filter.setQuery(taskService.createTaskQuery()); filterService.saveFilter(filter); TaskQueryImpl extendingQuery = (TaskQueryImpl)taskService.createTaskQuery() .processInstanceBusinessKeyLikeExpression("${ " + Mocks.getMocks().keySet().toArray()[0] + " }"); // then assertEquals(extendingQuery.getExpressions().get("processInstanceBusinessKeyLike"), "${ " + Mocks.getMocks().keySet().toArray()[0] + " }"); assertEquals(1, filterService.list(filter.getId(), extendingQuery).size()); }
Example 7
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
/** * See CAM-9613 */ @Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void FAILING_testByteArrayVariable() { // given runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("bytesVariable", "aByteArray".getBytes())); TaskQuery query = taskService.createTaskQuery() .processVariableValueEquals("bytesVariable", "aByteArray".getBytes()); Filter filter = filterService.newTaskFilter("filter"); filter.setQuery(query); // when filterService.saveFilter(filter); // then assertThat(filterService.count(filter.getId()), is(1L)); }
Example 8
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testTaskQueryByBusinessKeyExpressionInAdhocQuery() { // given processEngineConfiguration.setEnableExpressionsInAdhocQueries(true); String aBusinessKey = "business key"; Mocks.register("aBusinessKey", aBusinessKey); createDeploymentWithBusinessKey(aBusinessKey); // when Filter filter = filterService.newTaskFilter("aFilterName"); filter.setQuery(taskService.createTaskQuery()); filterService.saveFilter(filter); TaskQueryImpl extendingQuery = (TaskQueryImpl)taskService.createTaskQuery() .processInstanceBusinessKeyExpression("${ " + Mocks.getMocks().keySet().toArray()[0] + " }"); // then assertEquals(extendingQuery.getExpressions().get("processInstanceBusinessKey"), "${ " + Mocks.getMocks().keySet().toArray()[0] + " }"); assertEquals(1, filterService.list(filter.getId(), extendingQuery).size()); }
Example 9
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void testDoubleVariable() { // given runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("doubleVariable", 88.89D)); TaskQuery query = taskService.createTaskQuery() .processVariableValueEquals("doubleVariable", 88.89D); Filter filter = filterService.newTaskFilter("filter"); filter.setQuery(query); // when filterService.saveFilter(filter); // then assertThat(filterService.count(filter.getId()), is(1L)); }
Example 10
Source File: TaskQueryDisabledStoredExpressionsTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testUpdateFilterWithExpression() { // given a stored filter TaskQuery taskQuery = taskService.createTaskQuery().dueAfter(new Date()); Filter filter = filterService.newTaskFilter("filter"); filter.setQuery(taskQuery); filterService.saveFilter(filter); // updating the filter with an expression does not suceed filter.setQuery(taskQuery.dueBeforeExpression(STATE_MANIPULATING_EXPRESSION)); assertEquals(1, filterService.createFilterQuery().count()); try { filterService.saveFilter(filter); } catch (ProcessEngineException e) { assertTextPresent(EXPECTED_STORED_QUERY_FAILURE_MESSAGE, e.getMessage()); } assertTrue(fieldIsUnchanged()); // cleanup filterService.deleteFilter(filter.getId()); }
Example 11
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void testStringVariable() { // given runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("stringVariable", "aVariableValue")); TaskQuery query = taskService.createTaskQuery() .processVariableValueEquals("stringVariable", "aVariableValue"); Filter filter = filterService.newTaskFilter("filter"); filter.setQuery(query); // when filterService.saveFilter(filter); // then assertThat(filterService.count(filter.getId()), is(1L)); }
Example 12
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
/** * See CAM-9613 */ @Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void FAILING_testDateVariable() { // given Date date = new Date(); runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("dateVariable", date)); TaskQuery query = taskService.createTaskQuery() .processVariableValueEquals("dateVariable", date); Filter filter = filterService.newTaskFilter("filter"); filter.setQuery(query); // when filterService.saveFilter(filter); // then assertThat(filterService.count(filter.getId()), is(1L)); }
Example 13
Source File: TaskQueryDisabledAdhocExpressionsTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testExtendStoredFilterByExpression() { // given a stored filter TaskQuery taskQuery = taskService.createTaskQuery().dueAfterExpression("${now()}"); Filter filter = filterService.newTaskFilter("filter"); filter.setQuery(taskQuery); filterService.saveFilter(filter); // it is possible to execute the stored query with an expression assertEquals(new Long(0), filterService.count(filter.getId())); assertEquals(0, filterService.list(filter.getId()).size()); // but it is not possible to executed the filter with an extended query that uses expressions extendFilterAndValidateFailingQuery(filter, taskService.createTaskQuery().dueAfterExpression(STATE_MANIPULATING_EXPRESSION)); // cleanup filterService.deleteFilter(filter.getId()); }
Example 14
Source File: BoundedNumberOfMaxResultsTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void shouldThrowExceptionWhenFilterQueryListPage_MaxResultsLimitExceeded() { // given Filter foo = engineRule.getFilterService().newTaskFilter("foo"); foo.setQuery(taskService.createTaskQuery()); engineRule.getFilterService().saveFilter(foo); String filterId = engineRule.getFilterService() .createFilterQuery() .singleResult() .getId(); try { // when engineRule.getFilterService().listPage(filterId, 0, 11); fail("Exception expected!"); } catch (BadUserRequestException e) { // then assertThat(e).hasMessage("Max results limit of 10 exceeded!"); } // clear engineRule.getFilterService().deleteFilter(filterId); }
Example 15
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void testDueDate() { // given Date date = new Date(); String processInstanceId = runtimeService.startProcessInstanceByKey("oneTaskProcess").getId(); Task task = taskService.createTaskQuery() .processInstanceId(processInstanceId) .singleResult(); task.setDueDate(date); taskService.saveTask(task); TaskQuery query = taskService.createTaskQuery() .dueDate(date); Filter filter = filterService.newTaskFilter("filter"); filter.setQuery(query); // when filterService.saveFilter(filter); // then assertThat(filterService.count(filter.getId()), is(1L)); }
Example 16
Source File: TaskQueryDisabledStoredExpressionsTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testStoreFilterWithoutExpression() { TaskQuery taskQuery = taskService.createTaskQuery().dueAfter(new Date()); Filter filter = filterService.newTaskFilter("filter"); filter.setQuery(taskQuery); // saving the filter suceeds filterService.saveFilter(filter); assertEquals(1, filterService.createFilterQuery().count()); // cleanup filterService.deleteFilter(filter.getId()); }
Example 17
Source File: BoundedNumberOfMaxResultsTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldThrowExceptionWhenExtendedFilterQueryList_MaxResultsLimitExceeded() { // given Filter foo = engineRule.getFilterService().newTaskFilter("foo"); foo.setQuery(taskService.createTaskQuery()); engineRule.getFilterService().saveFilter(foo); String filterId = engineRule.getFilterService() .createFilterQuery() .singleResult() .getId(); TaskQuery extendingQuery = taskService.createTaskQuery() .taskCandidateGroup("aCandidateGroup"); try { // when engineRule.getFilterService().list(filterId, extendingQuery); fail("Exception expected!"); } catch (BadUserRequestException e) { // then assertThat(e).hasMessage("An unbound number of results is forbidden!"); } // clear engineRule.getFilterService().deleteFilter(filterId); }
Example 18
Source File: FilterDto.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void updateFilter(Filter filter, ProcessEngine engine) { if (getResourceType() != null && !getResourceType().equals(filter.getResourceType())) { throw new InvalidRequestException(Status.BAD_REQUEST, "Unable to update filter from resource type '" + filter.getResourceType() + "' to '" + getResourceType() + "'"); } filter.setName(getName()); filter.setOwner(getOwner()); filter.setQuery(query.toQuery(engine)); filter.setProperties(getProperties()); }
Example 19
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testExtendTaskQuery_ORInExtendingQuery() { // given createTasksForOrQueries(); // when TaskQuery extendedQuery = taskService.createTaskQuery() .taskName("taskForOr"); Filter extendedFilter = filterService.newTaskFilter("extendedOrFilter"); extendedFilter.setQuery(extendedQuery); filterService.saveFilter(extendedFilter); TaskQuery extendingQuery = taskService.createTaskQuery() .or() .taskDescription("aTaskDescription") .taskOwner("aTaskOwner") .endOr() .or() .taskPriority(3) .taskAssignee("aTaskAssignee") .endOr(); // then assertEquals(4, extendedQuery.list().size()); assertEquals(4, filterService.list(extendedFilter.getId()).size()); assertEquals(6, extendingQuery.list().size()); assertEquals(3, filterService.list(extendedFilter.getId(), extendingQuery).size()); }
Example 20
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testExtendTaskQuery_ORInExtendedQuery() { // given createTasksForOrQueries(); // when TaskQuery extendedQuery = taskService.createTaskQuery() .or() .taskDescription("aTaskDescription") .taskOwner("aTaskOwner") .endOr() .or() .taskPriority(3) .taskAssignee("aTaskAssignee") .endOr(); Filter extendedFilter = filterService.newTaskFilter("extendedOrFilter"); extendedFilter.setQuery(extendedQuery); filterService.saveFilter(extendedFilter); TaskQuery extendingQuery = taskService.createTaskQuery() .taskName("taskForOr"); // then assertEquals(6, extendedQuery.list().size()); assertEquals(6, filterService.list(extendedFilter.getId()).size()); assertEquals(4, extendingQuery.list().size()); assertEquals(3, filterService.list(extendedFilter.getId(), extendingQuery).size()); }