Search in sources :

Example 1 with FilterEntity

use of org.camunda.bpm.engine.impl.persistence.entity.FilterEntity in project camunda-bpm-platform by camunda.

the class AbstractExecuteFilterCmd method getFilter.

protected Filter getFilter(CommandContext commandContext) {
    ensureNotNull("No filter id given to execute", "filterId", filterId);
    FilterEntity filter = commandContext.getFilterManager().findFilterById(filterId);
    ensureNotNull("No filter found for id '" + filterId + "'", "filter", filter);
    if (extendingQuery != null) {
        ((AbstractQuery<?, ?>) extendingQuery).validate();
        filter = (FilterEntity) filter.extend(extendingQuery);
    }
    return filter;
}
Also used : FilterEntity(org.camunda.bpm.engine.impl.persistence.entity.FilterEntity) AbstractQuery(org.camunda.bpm.engine.impl.AbstractQuery)

Example 2 with FilterEntity

use of org.camunda.bpm.engine.impl.persistence.entity.FilterEntity in project camunda-bpm-platform by camunda.

the class FilterRestServiceInteractionTest method testGetFilterWithVariableTypeSorting.

@Test
public void testGetFilterWithVariableTypeSorting() {
    TaskQuery query = new TaskQueryImpl().orderByExecutionVariable("foo", ValueType.STRING).asc().orderByProcessVariable("foo", ValueType.STRING).asc().orderByTaskVariable("foo", ValueType.STRING).asc().orderByCaseExecutionVariable("foo", ValueType.STRING).asc().orderByCaseInstanceVariable("foo", ValueType.STRING).asc();
    Filter filter = new FilterEntity("Task").setName("test").setQuery(query);
    when(filterServiceMock.getFilter(EXAMPLE_FILTER_ID)).thenReturn(filter);
    Response response = given().pathParam("id", EXAMPLE_FILTER_ID).then().expect().statusCode(Status.OK.getStatusCode()).when().get(SINGLE_FILTER_URL);
    // validate sorting content
    String content = response.asString();
    List<Map<String, Object>> sortings = from(content).getJsonObject("query.sorting");
    assertThat(sortings).hasSize(5);
    assertSorting(sortings.get(0), SORT_BY_EXECUTION_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.STRING);
    assertSorting(sortings.get(1), SORT_BY_PROCESS_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.STRING);
    assertSorting(sortings.get(2), SORT_BY_TASK_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.STRING);
    assertSorting(sortings.get(3), SORT_BY_CASE_EXECUTION_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.STRING);
    assertSorting(sortings.get(4), SORT_BY_CASE_INSTANCE_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.STRING);
}
Also used : Response(com.jayway.restassured.response.Response) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) Filter(org.camunda.bpm.engine.filter.Filter) MockProvider.mockFilter(org.camunda.bpm.engine.rest.helper.MockProvider.mockFilter) FilterEntity(org.camunda.bpm.engine.impl.persistence.entity.FilterEntity) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.anyString(org.mockito.Matchers.anyString) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 3 with FilterEntity

use of org.camunda.bpm.engine.impl.persistence.entity.FilterEntity in project camunda-bpm-platform by camunda.

the class FilterRestServiceInteractionTest method testGetFilterWithVariableSortOrderSorting.

@Test
public void testGetFilterWithVariableSortOrderSorting() {
    TaskQuery query = new TaskQueryImpl().orderByExecutionVariable("foo", ValueType.STRING).asc().orderByExecutionVariable("foo", ValueType.STRING).desc();
    Filter filter = new FilterEntity("Task").setName("test").setQuery(query);
    when(filterServiceMock.getFilter(EXAMPLE_FILTER_ID)).thenReturn(filter);
    Response response = given().pathParam("id", EXAMPLE_FILTER_ID).then().expect().statusCode(Status.OK.getStatusCode()).when().get(SINGLE_FILTER_URL);
    // validate sorting content
    String content = response.asString();
    List<Map<String, Object>> sortings = from(content).getJsonObject("query.sorting");
    assertThat(sortings).hasSize(2);
    assertSorting(sortings.get(0), SORT_BY_EXECUTION_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.STRING);
    assertSorting(sortings.get(1), SORT_BY_EXECUTION_VARIABLE, SORT_ORDER_DESC_VALUE, "foo", ValueType.STRING);
}
Also used : Response(com.jayway.restassured.response.Response) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) Filter(org.camunda.bpm.engine.filter.Filter) MockProvider.mockFilter(org.camunda.bpm.engine.rest.helper.MockProvider.mockFilter) FilterEntity(org.camunda.bpm.engine.impl.persistence.entity.FilterEntity) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.anyString(org.mockito.Matchers.anyString) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 4 with FilterEntity

use of org.camunda.bpm.engine.impl.persistence.entity.FilterEntity in project camunda-bpm-platform by camunda.

the class FilterRestServiceInteractionTest method testGetFilterWithMultipleSorting.

@Test
public void testGetFilterWithMultipleSorting() {
    TaskQuery query = new TaskQueryImpl().orderByDueDate().asc().orderByCaseExecutionId().desc();
    Filter filter = new FilterEntity("Task").setName("test").setQuery(query);
    when(filterServiceMock.getFilter(EXAMPLE_FILTER_ID)).thenReturn(filter);
    Response response = given().pathParam("id", EXAMPLE_FILTER_ID).then().expect().statusCode(Status.OK.getStatusCode()).when().get(SINGLE_FILTER_URL);
    // validate sorting content
    String content = response.asString();
    List<Map<String, Object>> sortings = from(content).getJsonObject("query.sorting");
    assertThat(sortings).hasSize(2);
    assertSorting(sortings.get(0), SORT_BY_DUE_DATE_VALUE, SORT_ORDER_ASC_VALUE);
    assertSorting(sortings.get(1), SORT_BY_CASE_EXECUTION_ID_VALUE, SORT_ORDER_DESC_VALUE);
}
Also used : Response(com.jayway.restassured.response.Response) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) Filter(org.camunda.bpm.engine.filter.Filter) MockProvider.mockFilter(org.camunda.bpm.engine.rest.helper.MockProvider.mockFilter) FilterEntity(org.camunda.bpm.engine.impl.persistence.entity.FilterEntity) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.anyString(org.mockito.Matchers.anyString) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 5 with FilterEntity

use of org.camunda.bpm.engine.impl.persistence.entity.FilterEntity in project camunda-bpm-platform by camunda.

the class FilterRestServiceInteractionTest method testGetFilterWithCandidateGroupQuery.

@Test
public void testGetFilterWithCandidateGroupQuery() {
    TaskQueryImpl query = new TaskQueryImpl();
    query.taskCandidateGroup("abc");
    Filter filter = new FilterEntity("Task").setName("test").setQuery(query);
    when(filterServiceMock.getFilter(EXAMPLE_FILTER_ID)).thenReturn(filter);
    given().pathParam("id", EXAMPLE_FILTER_ID).then().expect().statusCode(Status.OK.getStatusCode()).body("query.candidateGroup", equalTo("abc")).body("query.containsKey('candidateGroups')", is(false)).body("query.containsKey('includeAssignedTasks')", is(false)).when().get(SINGLE_FILTER_URL);
}
Also used : TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) Filter(org.camunda.bpm.engine.filter.Filter) MockProvider.mockFilter(org.camunda.bpm.engine.rest.helper.MockProvider.mockFilter) FilterEntity(org.camunda.bpm.engine.impl.persistence.entity.FilterEntity) Test(org.junit.Test)

Aggregations

FilterEntity (org.camunda.bpm.engine.impl.persistence.entity.FilterEntity)16 Filter (org.camunda.bpm.engine.filter.Filter)14 TaskQueryImpl (org.camunda.bpm.engine.impl.TaskQueryImpl)12 MockProvider.mockFilter (org.camunda.bpm.engine.rest.helper.MockProvider.mockFilter)12 Test (org.junit.Test)12 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)8 Response (com.jayway.restassured.response.Response)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)6 Matchers.anyString (org.mockito.Matchers.anyString)6 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)1 AbstractQuery (org.camunda.bpm.engine.impl.AbstractQuery)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1