Search in sources :

Example 11 with QueryOrderingProperty

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

the class HistoricBatchManager method findHistoricBatchIdsForCleanup.

@SuppressWarnings("unchecked")
public List<String> findHistoricBatchIdsForCleanup(Integer batchSize, Map<String, Integer> batchOperationsForHistoryCleanup) {
    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("currentTimestamp", ClockUtil.getCurrentTime());
    queryParameters.put("map", batchOperationsForHistoryCleanup);
    ListQueryParameterObject parameterObject = new ListQueryParameterObject();
    parameterObject.setParameter(queryParameters);
    parameterObject.getOrderingProperties().add(new QueryOrderingProperty(new QueryPropertyImpl("END_TIME_"), Direction.ASCENDING));
    parameterObject.setFirstResult(0);
    parameterObject.setMaxResults(batchSize);
    return (List<String>) getDbEntityManager().selectList("selectHistoricBatchIdsForCleanup", parameterObject);
}
Also used : ListQueryParameterObject(org.camunda.bpm.engine.impl.db.ListQueryParameterObject) HashMap(java.util.HashMap) QueryPropertyImpl(org.camunda.bpm.engine.impl.QueryPropertyImpl) ListQueryParameterObject(org.camunda.bpm.engine.impl.db.ListQueryParameterObject) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty) List(java.util.List)

Example 12 with QueryOrderingProperty

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

the class FilterTaskQueryTest method testOrderByVariables.

public void testOrderByVariables() {
    // given
    TaskQueryImpl query = (TaskQueryImpl) taskService.createTaskQuery().orderByProcessVariable("foo", ValueType.STRING).asc().orderByExecutionVariable("foo", ValueType.STRING).asc().orderByCaseInstanceVariable("foo", ValueType.STRING).asc().orderByCaseExecutionVariable("foo", ValueType.STRING).asc().orderByTaskVariable("foo", ValueType.STRING).asc();
    Filter filter = filterService.newTaskFilter("extendedOrFilter");
    filter.setQuery(query);
    filterService.saveFilter(filter);
    // when
    filter = filterService.getFilter(filter.getId());
    // then
    List<QueryOrderingProperty> expectedOrderingProperties = new ArrayList<QueryOrderingProperty>(query.getOrderingProperties());
    verifyOrderingProperties(expectedOrderingProperties, ((TaskQueryImpl) filter.getQuery()).getOrderingProperties());
    for (QueryOrderingProperty prop : ((TaskQueryImpl) filter.getQuery()).getOrderingProperties()) {
        assertTrue(prop instanceof VariableOrderProperty);
    }
}
Also used : TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) Filter(org.camunda.bpm.engine.filter.Filter) ArrayList(java.util.ArrayList) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty) VariableOrderProperty(org.camunda.bpm.engine.impl.VariableOrderProperty)

Example 13 with QueryOrderingProperty

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

the class FilterTaskQueryTest method testTaskQuery.

public void testTaskQuery() {
    // create query
    TaskQueryImpl query = new TaskQueryImpl();
    query.taskId(testString);
    query.taskName(testString);
    query.taskNameNotEqual(testString);
    query.taskNameLike(testString);
    query.taskNameNotLike(testString);
    query.taskDescription(testString);
    query.taskDescriptionLike(testString);
    query.taskPriority(testInteger);
    query.taskMinPriority(testInteger);
    query.taskMaxPriority(testInteger);
    query.taskAssignee(testString);
    query.taskAssigneeExpression(testString);
    query.taskAssigneeLike(testString);
    query.taskAssigneeLikeExpression(testString);
    query.taskInvolvedUser(testString);
    query.taskInvolvedUserExpression(testString);
    query.taskOwner(testString);
    query.taskOwnerExpression(testString);
    query.taskUnassigned();
    query.taskAssigned();
    query.taskDelegationState(testDelegationState);
    query.taskCandidateGroupIn(testCandidateGroups);
    query.taskCandidateGroupInExpression(testString);
    query.withCandidateGroups();
    query.withoutCandidateGroups();
    query.withCandidateUsers();
    query.withoutCandidateUsers();
    query.processInstanceId(testString);
    query.executionId(testString);
    query.activityInstanceIdIn(testActivityInstances);
    query.taskCreatedOn(testDate);
    query.taskCreatedOnExpression(testString);
    query.taskCreatedBefore(testDate);
    query.taskCreatedBeforeExpression(testString);
    query.taskCreatedAfter(testDate);
    query.taskCreatedAfterExpression(testString);
    query.taskDefinitionKey(testString);
    query.taskDefinitionKeyIn(testKeys);
    query.taskDefinitionKeyLike(testString);
    query.processDefinitionKey(testString);
    query.processDefinitionKeyIn(testKeys);
    query.processDefinitionId(testString);
    query.processDefinitionName(testString);
    query.processDefinitionNameLike(testString);
    query.processInstanceBusinessKey(testString);
    query.processInstanceBusinessKeyExpression(testString);
    query.processInstanceBusinessKeyIn(testKeys);
    query.processInstanceBusinessKeyLike(testString);
    query.processInstanceBusinessKeyLikeExpression(testString);
    // variables
    query.taskVariableValueEquals(variableNames[0], variableValues[0]);
    query.taskVariableValueGreaterThanOrEquals(variableNames[1], variableValues[1]);
    query.processVariableValueLessThan(variableNames[2], variableValues[2]);
    query.processVariableValueLike(variableNames[3], (String) variableValues[3]);
    query.caseInstanceVariableValueNotEquals(variableNames[4], variableValues[4]);
    query.caseInstanceVariableValueLessThanOrEquals(variableNames[5], variableValues[5]);
    query.dueDate(testDate);
    query.dueDateExpression(testString);
    query.dueBefore(testDate);
    query.dueBeforeExpression(testString);
    query.dueAfter(testDate);
    query.dueAfterExpression(testString);
    query.followUpDate(testDate);
    query.followUpDateExpression(testString);
    query.followUpBefore(testDate);
    query.followUpBeforeExpression(testString);
    query.followUpAfter(testDate);
    query.followUpAfterExpression(testString);
    query.excludeSubtasks();
    query.suspended();
    query.caseDefinitionKey(testString);
    query.caseDefinitionId(testString);
    query.caseDefinitionName(testString);
    query.caseDefinitionNameLike(testString);
    query.caseInstanceId(testString);
    query.caseInstanceBusinessKey(testString);
    query.caseInstanceBusinessKeyLike(testString);
    query.caseExecutionId(testString);
    // ordering
    query.orderByExecutionId().desc();
    query.orderByDueDate().asc();
    query.orderByProcessVariable("var", ValueType.STRING).desc();
    List<QueryOrderingProperty> expectedOrderingProperties = query.getOrderingProperties();
    // save filter
    filter.setQuery(query);
    filterService.saveFilter(filter);
    // fetch from db
    filter = filterService.createTaskFilterQuery().singleResult();
    // test query
    query = filter.getQuery();
    assertEquals(testString, query.getTaskId());
    assertEquals(testString, query.getName());
    assertEquals(testString, query.getNameNotEqual());
    assertEquals(testString, query.getNameNotLike());
    assertEquals(testString, query.getNameLike());
    assertEquals(testString, query.getDescription());
    assertEquals(testString, query.getDescriptionLike());
    assertEquals(testInteger, query.getPriority());
    assertEquals(testInteger, query.getMinPriority());
    assertEquals(testInteger, query.getMaxPriority());
    assertEquals(testString, query.getAssignee());
    assertEquals(testString, query.getExpressions().get("taskAssignee"));
    assertEquals(testString, query.getAssigneeLike());
    assertEquals(testString, query.getExpressions().get("taskAssigneeLike"));
    assertEquals(testString, query.getInvolvedUser());
    assertEquals(testString, query.getExpressions().get("taskInvolvedUser"));
    assertEquals(testString, query.getOwner());
    assertEquals(testString, query.getExpressions().get("taskOwner"));
    assertTrue(query.isUnassigned());
    assertTrue(query.isAssigned());
    assertEquals(testDelegationState, query.getDelegationState());
    assertEquals(testCandidateGroups, query.getCandidateGroups());
    assertTrue(query.isWithCandidateGroups());
    assertTrue(query.isWithoutCandidateGroups());
    assertTrue(query.isWithCandidateUsers());
    assertTrue(query.isWithoutCandidateUsers());
    assertEquals(testString, query.getExpressions().get("taskCandidateGroupIn"));
    assertEquals(testString, query.getProcessInstanceId());
    assertEquals(testString, query.getExecutionId());
    assertEquals(testActivityInstances.length, query.getActivityInstanceIdIn().length);
    for (int i = 0; i < query.getActivityInstanceIdIn().length; i++) {
        assertEquals(testActivityInstances[i], query.getActivityInstanceIdIn()[i]);
    }
    assertEquals(testDate, query.getCreateTime());
    assertEquals(testString, query.getExpressions().get("taskCreatedOn"));
    assertEquals(testDate, query.getCreateTimeBefore());
    assertEquals(testString, query.getExpressions().get("taskCreatedBefore"));
    assertEquals(testDate, query.getCreateTimeAfter());
    assertEquals(testString, query.getExpressions().get("taskCreatedAfter"));
    assertEquals(testString, query.getKey());
    assertEquals(testKeys.length, query.getKeys().length);
    for (int i = 0; i < query.getKeys().length; i++) {
        assertEquals(testKeys[i], query.getKeys()[i]);
    }
    assertEquals(testString, query.getKeyLike());
    assertEquals(testString, query.getProcessDefinitionKey());
    for (int i = 0; i < query.getProcessDefinitionKeys().length; i++) {
        assertEquals(testKeys[i], query.getProcessDefinitionKeys()[i]);
    }
    assertEquals(testString, query.getProcessDefinitionId());
    assertEquals(testString, query.getProcessDefinitionName());
    assertEquals(testString, query.getProcessDefinitionNameLike());
    assertEquals(testString, query.getProcessInstanceBusinessKey());
    assertEquals(testString, query.getExpressions().get("processInstanceBusinessKey"));
    for (int i = 0; i < query.getProcessInstanceBusinessKeys().length; i++) {
        assertEquals(testKeys[i], query.getProcessInstanceBusinessKeys()[i]);
    }
    assertEquals(testString, query.getProcessInstanceBusinessKeyLike());
    assertEquals(testString, query.getExpressions().get("processInstanceBusinessKeyLike"));
    // variables
    List<TaskQueryVariableValue> variables = query.getVariables();
    for (int i = 0; i < variables.size(); i++) {
        TaskQueryVariableValue variable = variables.get(i);
        assertEquals(variableNames[i], variable.getName());
        assertEquals(variableValues[i], variable.getValue());
        assertEquals(variableOperators[i], variable.getOperator());
        assertEquals(isTaskVariable[i], variable.isLocal());
        assertEquals(isProcessVariable[i], variable.isProcessInstanceVariable());
    }
    assertEquals(testDate, query.getDueDate());
    assertEquals(testString, query.getExpressions().get("dueDate"));
    assertEquals(testDate, query.getDueBefore());
    assertEquals(testString, query.getExpressions().get("dueBefore"));
    assertEquals(testDate, query.getDueAfter());
    assertEquals(testString, query.getExpressions().get("dueAfter"));
    assertEquals(testDate, query.getFollowUpDate());
    assertEquals(testString, query.getExpressions().get("followUpDate"));
    assertEquals(testDate, query.getFollowUpBefore());
    assertEquals(testString, query.getExpressions().get("followUpBefore"));
    assertEquals(testDate, query.getFollowUpAfter());
    assertEquals(testString, query.getExpressions().get("followUpAfter"));
    assertTrue(query.isExcludeSubtasks());
    assertEquals(SuspensionState.SUSPENDED, query.getSuspensionState());
    assertEquals(testString, query.getCaseDefinitionKey());
    assertEquals(testString, query.getCaseDefinitionId());
    assertEquals(testString, query.getCaseDefinitionName());
    assertEquals(testString, query.getCaseDefinitionNameLike());
    assertEquals(testString, query.getCaseInstanceId());
    assertEquals(testString, query.getCaseInstanceBusinessKey());
    assertEquals(testString, query.getCaseInstanceBusinessKeyLike());
    assertEquals(testString, query.getCaseExecutionId());
    // ordering
    verifyOrderingProperties(expectedOrderingProperties, query.getOrderingProperties());
}
Also used : TaskQueryVariableValue(org.camunda.bpm.engine.impl.TaskQueryVariableValue) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty)

Example 14 with QueryOrderingProperty

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

the class FilterTaskQueryTest method testExtendingSorting.

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());
}
Also used : TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) Filter(org.camunda.bpm.engine.filter.Filter) ArrayList(java.util.ArrayList) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty)

Example 15 with QueryOrderingProperty

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

the class FilterTaskQueryTest method verifyOrderingProperties.

protected void verifyOrderingProperties(List<QueryOrderingProperty> expectedProperties, List<QueryOrderingProperty> actualProperties) {
    assertEquals(expectedProperties.size(), actualProperties.size());
    for (int i = 0; i < expectedProperties.size(); i++) {
        QueryOrderingProperty expectedProperty = expectedProperties.get(i);
        QueryOrderingProperty actualProperty = actualProperties.get(i);
        assertEquals(expectedProperty.getRelation(), actualProperty.getRelation());
        assertEquals(expectedProperty.getDirection(), actualProperty.getDirection());
        assertEquals(expectedProperty.isContainedProperty(), actualProperty.isContainedProperty());
        assertEquals(expectedProperty.getQueryProperty(), actualProperty.getQueryProperty());
        List<QueryEntityRelationCondition> expectedRelationConditions = expectedProperty.getRelationConditions();
        List<QueryEntityRelationCondition> actualRelationConditions = expectedProperty.getRelationConditions();
        if (expectedRelationConditions != null && actualRelationConditions != null) {
            assertEquals(expectedRelationConditions.size(), actualRelationConditions.size());
            for (int j = 0; j < expectedRelationConditions.size(); j++) {
                QueryEntityRelationCondition expectedFilteringProperty = expectedRelationConditions.get(j);
                QueryEntityRelationCondition actualFilteringProperty = expectedRelationConditions.get(j);
                assertEquals(expectedFilteringProperty.getProperty(), actualFilteringProperty.getProperty());
                assertEquals(expectedFilteringProperty.getComparisonProperty(), actualFilteringProperty.getComparisonProperty());
                assertEquals(expectedFilteringProperty.getScalarValue(), actualFilteringProperty.getScalarValue());
            }
        } else if ((expectedRelationConditions == null && actualRelationConditions != null) || (expectedRelationConditions != null && actualRelationConditions == null)) {
            fail("Expected filtering properties: " + expectedRelationConditions + ". " + "Actual filtering properties: " + actualRelationConditions);
        }
    }
}
Also used : QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty) QueryEntityRelationCondition(org.camunda.bpm.engine.impl.QueryEntityRelationCondition)

Aggregations

QueryOrderingProperty (org.camunda.bpm.engine.impl.QueryOrderingProperty)18 TaskQueryImpl (org.camunda.bpm.engine.impl.TaskQueryImpl)8 ArrayList (java.util.ArrayList)6 QueryPropertyImpl (org.camunda.bpm.engine.impl.QueryPropertyImpl)5 VariableOrderProperty (org.camunda.bpm.engine.impl.VariableOrderProperty)3 ListQueryParameterObject (org.camunda.bpm.engine.impl.db.ListQueryParameterObject)3 JsonTaskQueryConverter (org.camunda.bpm.engine.impl.json.JsonTaskQueryConverter)3 JSONObject (org.camunda.bpm.engine.impl.util.json.JSONObject)3 Filter (org.camunda.bpm.engine.filter.Filter)2 QueryEntityRelationCondition (org.camunda.bpm.engine.impl.QueryEntityRelationCondition)2 TaskQueryVariableValue (org.camunda.bpm.engine.impl.TaskQueryVariableValue)2 QueryProperty (org.camunda.bpm.engine.query.QueryProperty)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 AuthenticationException (javax.naming.AuthenticationException)1 NamingException (javax.naming.NamingException)1 Control (javax.naming.ldap.Control)1 SortControl (javax.naming.ldap.SortControl)1