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);
}
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);
}
}
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());
}
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());
}
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);
}
}
}
Aggregations