Search in sources :

Example 11 with FilterQuery

use of org.camunda.bpm.engine.filter.FilterQuery in project camunda-bpm-platform by camunda.

the class FilterRestServiceImpl method getFilters.

public List<FilterDto> getFilters(UriInfo uriInfo, Boolean itemCount, Integer firstResult, Integer maxResults) {
    FilterService filterService = getProcessEngine().getFilterService();
    FilterQuery query = getQueryFromQueryParameters(uriInfo.getQueryParameters());
    List<Filter> matchingFilters = executeFilterQuery(query, firstResult, maxResults);
    List<FilterDto> filters = new ArrayList<FilterDto>();
    for (Filter filter : matchingFilters) {
        FilterDto dto = FilterDto.fromFilter(filter);
        if (itemCount != null && itemCount) {
            dto.setItemCount(filterService.count(filter.getId()));
        }
        filters.add(dto);
    }
    return filters;
}
Also used : Filter(org.camunda.bpm.engine.filter.Filter) FilterService(org.camunda.bpm.engine.FilterService) ArrayList(java.util.ArrayList) FilterQuery(org.camunda.bpm.engine.filter.FilterQuery) FilterDto(org.camunda.bpm.engine.rest.dto.runtime.FilterDto)

Example 12 with FilterQuery

use of org.camunda.bpm.engine.filter.FilterQuery in project camunda-bpm-platform by camunda.

the class FilterQueryTest method testQueryByName.

public void testQueryByName() {
    FilterQuery query = filterService.createFilterQuery().filterName("a");
    assertNotNull(query.singleResult());
    assertEquals(1, query.list().size());
    assertEquals(1, query.count());
}
Also used : FilterQuery(org.camunda.bpm.engine.filter.FilterQuery)

Example 13 with FilterQuery

use of org.camunda.bpm.engine.filter.FilterQuery in project camunda-bpm-platform by camunda.

the class FilterQueryTest method testQueryByNameLike.

public void testQueryByNameLike() {
    FilterQuery query = filterService.createFilterQuery().filterNameLike("%\\_");
    assertNotNull(query.singleResult());
    assertEquals(1, query.list().size());
    assertEquals(1, query.count());
}
Also used : FilterQuery(org.camunda.bpm.engine.filter.FilterQuery)

Example 14 with FilterQuery

use of org.camunda.bpm.engine.filter.FilterQuery in project camunda-bpm-platform by camunda.

the class FilterQueryTest method testQueryByOwner.

public void testQueryByOwner() {
    FilterQuery query = filterService.createFilterQuery().filterOwner("a");
    assertNotNull(query.singleResult());
    assertEquals(1, query.list().size());
    assertEquals(1, query.count());
}
Also used : FilterQuery(org.camunda.bpm.engine.filter.FilterQuery)

Example 15 with FilterQuery

use of org.camunda.bpm.engine.filter.FilterQuery in project camunda-bpm-platform by camunda.

the class FilterRestServiceInteractionTest method setUpRuntimeData.

@Before
@SuppressWarnings("unchecked")
public void setUpRuntimeData() {
    filterServiceMock = mock(FilterService.class);
    when(processEngine.getFilterService()).thenReturn(filterServiceMock);
    FilterQuery filterQuery = MockProvider.createMockFilterQuery();
    when(filterServiceMock.createFilterQuery()).thenReturn(filterQuery);
    filterMock = MockProvider.createMockFilter();
    when(filterServiceMock.newTaskFilter()).thenReturn(filterMock);
    when(filterServiceMock.saveFilter(eq(filterMock))).thenReturn(filterMock);
    when(filterServiceMock.getFilter(eq(EXAMPLE_FILTER_ID))).thenReturn(filterMock);
    when(filterServiceMock.getFilter(eq(MockProvider.NON_EXISTING_ID))).thenReturn(null);
    List<Object> mockTasks = Collections.<Object>singletonList(new TaskEntity());
    when(filterServiceMock.singleResult(eq(EXAMPLE_FILTER_ID))).thenReturn(mockTasks.get(0));
    when(filterServiceMock.singleResult(eq(EXAMPLE_FILTER_ID), any(Query.class))).thenReturn(mockTasks.get(0));
    when(filterServiceMock.list(eq(EXAMPLE_FILTER_ID))).thenReturn(mockTasks);
    when(filterServiceMock.list(eq(EXAMPLE_FILTER_ID), any(Query.class))).thenReturn(mockTasks);
    when(filterServiceMock.listPage(eq(EXAMPLE_FILTER_ID), anyInt(), anyInt())).thenReturn(mockTasks);
    when(filterServiceMock.listPage(eq(EXAMPLE_FILTER_ID), any(Query.class), anyInt(), anyInt())).thenReturn(mockTasks);
    when(filterServiceMock.count(eq(EXAMPLE_FILTER_ID))).thenReturn((long) 1);
    when(filterServiceMock.count(eq(EXAMPLE_FILTER_ID), any(Query.class))).thenReturn((long) 1);
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).singleResult(eq(MockProvider.NON_EXISTING_ID));
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).singleResult(eq(MockProvider.NON_EXISTING_ID), any(Query.class));
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).list(eq(MockProvider.NON_EXISTING_ID));
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).list(eq(MockProvider.NON_EXISTING_ID), any(Query.class));
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).listPage(eq(MockProvider.NON_EXISTING_ID), anyInt(), anyInt());
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).listPage(eq(MockProvider.NON_EXISTING_ID), any(Query.class), anyInt(), anyInt());
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).count(eq(MockProvider.NON_EXISTING_ID));
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).count(eq(MockProvider.NON_EXISTING_ID), any(Query.class));
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).deleteFilter(eq(MockProvider.NON_EXISTING_ID));
    authorizationServiceMock = mock(AuthorizationServiceImpl.class);
    identityServiceMock = mock(IdentityServiceImpl.class);
    processEngineConfigurationMock = mock(ProcessEngineConfiguration.class);
    when(processEngine.getAuthorizationService()).thenReturn(authorizationServiceMock);
    when(processEngine.getIdentityService()).thenReturn(identityServiceMock);
    when(processEngine.getProcessEngineConfiguration()).thenReturn(processEngineConfigurationMock);
    TaskService taskService = processEngine.getTaskService();
    when(taskService.createTaskQuery()).thenReturn(new TaskQueryImpl());
    variableInstanceQueryMock = mock(VariableInstanceQuery.class);
    when(processEngine.getRuntimeService().createVariableInstanceQuery()).thenReturn(variableInstanceQueryMock);
    when(variableInstanceQueryMock.variableScopeIdIn((String) anyVararg())).thenReturn(variableInstanceQueryMock);
    when(variableInstanceQueryMock.variableNameIn((String) anyVararg())).thenReturn(variableInstanceQueryMock);
    when(variableInstanceQueryMock.disableBinaryFetching()).thenReturn(variableInstanceQueryMock);
    when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock);
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) FilterQuery(org.camunda.bpm.engine.filter.FilterQuery) Query(org.camunda.bpm.engine.query.Query) VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) IdentityServiceImpl(org.camunda.bpm.engine.impl.IdentityServiceImpl) TaskService(org.camunda.bpm.engine.TaskService) FilterService(org.camunda.bpm.engine.FilterService) FilterQuery(org.camunda.bpm.engine.filter.FilterQuery) NullValueException(org.camunda.bpm.engine.exception.NullValueException) ProcessEngineConfiguration(org.camunda.bpm.engine.ProcessEngineConfiguration) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) AuthorizationServiceImpl(org.camunda.bpm.engine.impl.AuthorizationServiceImpl) Before(org.junit.Before)

Aggregations

FilterQuery (org.camunda.bpm.engine.filter.FilterQuery)15 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)6 Filter (org.camunda.bpm.engine.filter.Filter)3 ArrayList (java.util.ArrayList)2 FilterService (org.camunda.bpm.engine.FilterService)2 ProcessEngineConfiguration (org.camunda.bpm.engine.ProcessEngineConfiguration)1 TaskService (org.camunda.bpm.engine.TaskService)1 NullValueException (org.camunda.bpm.engine.exception.NullValueException)1 AuthorizationServiceImpl (org.camunda.bpm.engine.impl.AuthorizationServiceImpl)1 IdentityServiceImpl (org.camunda.bpm.engine.impl.IdentityServiceImpl)1 TaskQueryImpl (org.camunda.bpm.engine.impl.TaskQueryImpl)1 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)1 Query (org.camunda.bpm.engine.query.Query)1 FilterDto (org.camunda.bpm.engine.rest.dto.runtime.FilterDto)1 VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)1 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)1 Before (org.junit.Before)1