Search in sources :

Example 1 with AbstractQuery

use of org.camunda.bpm.engine.impl.AbstractQuery 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 AbstractQuery

use of org.camunda.bpm.engine.impl.AbstractQuery in project camunda-bpm-platform by camunda.

the class HistoricCaseActivityInstanceTest method assertQuerySorting.

@SuppressWarnings({ "rawtypes", "unchecked" })
protected void assertQuerySorting(String property, Query<?, ?> query, Comparable... items) {
    AbstractQuery<?, ?> queryImpl = (AbstractQuery<?, ?>) query;
    // save order properties to later reverse ordering
    List<QueryOrderingProperty> orderProperties = queryImpl.getOrderingProperties();
    List<? extends Comparable> sortedList = Arrays.asList(items);
    Collections.sort(sortedList);
    List<Matcher<Object>> matchers = new ArrayList<Matcher<Object>>();
    for (Comparable comparable : sortedList) {
        matchers.add(hasProperty(property, equalTo(comparable)));
    }
    List<?> instances = query.asc().list();
    assertEquals(sortedList.size(), instances.size());
    assertThat(instances, contains(matchers.toArray(new Matcher[matchers.size()])));
    // reverse ordering
    for (QueryOrderingProperty orderingProperty : orderProperties) {
        orderingProperty.setDirection(Direction.DESCENDING);
    }
    // reverse matchers
    Collections.reverse(matchers);
    instances = query.list();
    assertEquals(sortedList.size(), instances.size());
    assertThat(instances, contains(matchers.toArray(new Matcher[matchers.size()])));
}
Also used : Matcher(org.hamcrest.Matcher) ArrayList(java.util.ArrayList) AbstractQuery(org.camunda.bpm.engine.impl.AbstractQuery) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty)

Aggregations

AbstractQuery (org.camunda.bpm.engine.impl.AbstractQuery)2 ArrayList (java.util.ArrayList)1 QueryOrderingProperty (org.camunda.bpm.engine.impl.QueryOrderingProperty)1 FilterEntity (org.camunda.bpm.engine.impl.persistence.entity.FilterEntity)1 Matcher (org.hamcrest.Matcher)1