use of org.camunda.bpm.engine.impl.QueryOrderingProperty in project camunda-bpm-platform by camunda.
the class TaskQueryDto method fromQuery.
public static TaskQueryDto fromQuery(Query<?, ?> query, boolean isOrQueryActive) {
TaskQueryImpl taskQuery = (TaskQueryImpl) query;
TaskQueryDto dto = new TaskQueryDto();
if (!isOrQueryActive) {
dto.orQueries = new ArrayList<TaskQueryDto>();
for (TaskQueryImpl orQuery : taskQuery.getQueries()) {
if (orQuery.isOrQueryActive()) {
dto.orQueries.add(fromQuery(orQuery, true));
}
}
}
dto.activityInstanceIdIn = taskQuery.getActivityInstanceIdIn();
dto.caseDefinitionId = taskQuery.getCaseDefinitionId();
dto.caseDefinitionKey = taskQuery.getCaseDefinitionKey();
dto.caseDefinitionName = taskQuery.getCaseDefinitionName();
dto.caseDefinitionNameLike = taskQuery.getCaseDefinitionNameLike();
dto.caseExecutionId = taskQuery.getCaseExecutionId();
dto.caseInstanceBusinessKey = taskQuery.getCaseInstanceBusinessKey();
dto.caseInstanceBusinessKeyLike = taskQuery.getCaseInstanceBusinessKeyLike();
dto.caseInstanceId = taskQuery.getCaseInstanceId();
dto.candidateUser = taskQuery.getCandidateUser();
dto.candidateGroup = taskQuery.getCandidateGroup();
dto.candidateGroups = taskQuery.getCandidateGroupsInternal();
dto.includeAssignedTasks = taskQuery.isIncludeAssignedTasksInternal();
dto.withCandidateGroups = taskQuery.isWithCandidateGroups();
dto.withoutCandidateGroups = taskQuery.isWithoutCandidateGroups();
dto.withCandidateUsers = taskQuery.isWithCandidateUsers();
dto.withoutCandidateUsers = taskQuery.isWithoutCandidateUsers();
dto.processInstanceBusinessKey = taskQuery.getProcessInstanceBusinessKey();
dto.processInstanceBusinessKeyLike = taskQuery.getProcessInstanceBusinessKeyLike();
dto.processDefinitionKey = taskQuery.getProcessDefinitionKey();
dto.processDefinitionKeyIn = taskQuery.getProcessDefinitionKeys();
dto.processDefinitionId = taskQuery.getProcessDefinitionId();
dto.executionId = taskQuery.getExecutionId();
dto.processDefinitionName = taskQuery.getProcessDefinitionName();
dto.processDefinitionNameLike = taskQuery.getProcessDefinitionNameLike();
dto.processInstanceId = taskQuery.getProcessInstanceId();
dto.assignee = taskQuery.getAssignee();
dto.assigneeLike = taskQuery.getAssigneeLike();
dto.taskDefinitionKey = taskQuery.getKey();
dto.taskDefinitionKeyIn = taskQuery.getKeys();
dto.taskDefinitionKeyLike = taskQuery.getKeyLike();
dto.description = taskQuery.getDescription();
dto.descriptionLike = taskQuery.getDescriptionLike();
dto.involvedUser = taskQuery.getInvolvedUser();
dto.maxPriority = taskQuery.getMaxPriority();
dto.minPriority = taskQuery.getMinPriority();
dto.name = taskQuery.getName();
dto.nameNotEqual = taskQuery.getNameNotEqual();
dto.nameLike = taskQuery.getNameLike();
dto.nameNotLike = taskQuery.getNameNotLike();
dto.owner = taskQuery.getOwner();
dto.priority = taskQuery.getPriority();
dto.assigned = taskQuery.isAssignedInternal();
dto.unassigned = taskQuery.isUnassignedInternal();
dto.parentTaskId = taskQuery.getParentTaskId();
dto.dueAfter = taskQuery.getDueAfter();
dto.dueBefore = taskQuery.getDueBefore();
dto.dueDate = taskQuery.getDueDate();
dto.followUpAfter = taskQuery.getFollowUpAfter();
if (taskQuery.isFollowUpNullAccepted()) {
dto.followUpBeforeOrNotExistent = taskQuery.getFollowUpBefore();
} else {
dto.followUpBefore = taskQuery.getFollowUpBefore();
}
dto.followUpDate = taskQuery.getFollowUpDate();
dto.createdAfter = taskQuery.getCreateTimeAfter();
dto.createdBefore = taskQuery.getCreateTimeBefore();
dto.createdOn = taskQuery.getCreateTime();
if (taskQuery.getDelegationState() != null) {
dto.delegationState = taskQuery.getDelegationState().toString();
}
if (taskQuery.isTenantIdSet()) {
if (taskQuery.getTenantIds() != null) {
dto.tenantIdIn = taskQuery.getTenantIds();
} else {
dto.withoutTenantId = true;
}
}
dto.processVariables = new ArrayList<VariableQueryParameterDto>();
dto.taskVariables = new ArrayList<VariableQueryParameterDto>();
dto.caseInstanceVariables = new ArrayList<VariableQueryParameterDto>();
for (TaskQueryVariableValue variableValue : taskQuery.getVariables()) {
VariableQueryParameterDto variableValueDto = new VariableQueryParameterDto(variableValue);
if (variableValue.isProcessInstanceVariable()) {
dto.processVariables.add(variableValueDto);
} else if (variableValue.isLocal()) {
dto.taskVariables.add(variableValueDto);
} else {
dto.caseInstanceVariables.add(variableValueDto);
}
}
if (taskQuery.getSuspensionState() == SuspensionState.ACTIVE) {
dto.active = true;
}
if (taskQuery.getSuspensionState() == SuspensionState.SUSPENDED) {
dto.suspended = true;
}
// sorting
List<QueryOrderingProperty> orderingProperties = taskQuery.getOrderingProperties();
if (!orderingProperties.isEmpty()) {
dto.setSorting(convertQueryOrderingPropertiesToSortingDtos(orderingProperties));
}
// expressions
Map<String, String> expressions = taskQuery.getExpressions();
if (expressions.containsKey("taskAssignee")) {
dto.setAssigneeExpression(expressions.get("taskAssignee"));
}
if (expressions.containsKey("taskAssigneeLike")) {
dto.setAssigneeLikeExpression(expressions.get("taskAssigneeLike"));
}
if (expressions.containsKey("taskOwner")) {
dto.setOwnerExpression(expressions.get("taskOwner"));
}
if (expressions.containsKey("taskCandidateUser")) {
dto.setCandidateUserExpression(expressions.get("taskCandidateUser"));
}
if (expressions.containsKey("taskInvolvedUser")) {
dto.setInvolvedUserExpression(expressions.get("taskInvolvedUser"));
}
if (expressions.containsKey("taskCandidateGroup")) {
dto.setCandidateGroupExpression(expressions.get("taskCandidateGroup"));
}
if (expressions.containsKey("taskCandidateGroupIn")) {
dto.setCandidateGroupsExpression(expressions.get("taskCandidateGroupIn"));
}
if (expressions.containsKey("taskCreatedOne")) {
dto.setCreatedOnExpression(expressions.get("taskCreatedOne"));
}
if (expressions.containsKey("taskCreatedBefore")) {
dto.setCreatedBeforeExpression(expressions.get("taskCreatedBefore"));
}
if (expressions.containsKey("taskCreatedAfter")) {
dto.setCreatedAfterExpression(expressions.get("taskCreatedAfter"));
}
if (expressions.containsKey("dueDate")) {
dto.setDueDateExpression(expressions.get("dueDate"));
}
if (expressions.containsKey("dueBefore")) {
dto.setDueBeforeExpression(expressions.get("dueBefore"));
}
if (expressions.containsKey("dueAfter")) {
dto.setDueAfterExpression(expressions.get("dueAfter"));
}
if (expressions.containsKey("followUpDate")) {
dto.setFollowUpDateExpression(expressions.get("followUpDate"));
}
if (expressions.containsKey("followUpBefore")) {
dto.setFollowUpBeforeExpression(expressions.get("followUpBefore"));
}
if (expressions.containsKey("followUpBeforeOrNotExistent")) {
dto.setFollowUpBeforeOrNotExistentExpression(expressions.get("followUpBeforeOrNotExistent"));
}
if (expressions.containsKey("followUpAfter")) {
dto.setFollowUpAfterExpression(expressions.get("followUpAfter"));
}
if (expressions.containsKey("processInstanceBusinessKey")) {
dto.setProcessInstanceBusinessKeyExpression(expressions.get("processInstanceBusinessKey"));
}
if (expressions.containsKey("processInstanceBusinessKeyLike")) {
dto.setProcessInstanceBusinessKeyLikeExpression(expressions.get("processInstanceBusinessKeyLike"));
}
return dto;
}
use of org.camunda.bpm.engine.impl.QueryOrderingProperty in project camunda-bpm-platform by camunda.
the class TaskQueryDto method convertQueryOrderingPropertiesToSortingDtos.
public static List<SortingDto> convertQueryOrderingPropertiesToSortingDtos(List<QueryOrderingProperty> orderingProperties) {
List<SortingDto> sortingDtos = new ArrayList<SortingDto>();
for (QueryOrderingProperty orderingProperty : orderingProperties) {
SortingDto sortingDto;
if (orderingProperty instanceof VariableOrderProperty) {
sortingDto = convertVariableOrderPropertyToSortingDto((VariableOrderProperty) orderingProperty);
} else {
sortingDto = convertQueryOrderingPropertyToSortingDto(orderingProperty);
}
sortingDtos.add(sortingDto);
}
return sortingDtos;
}
use of org.camunda.bpm.engine.impl.QueryOrderingProperty in project camunda-bpm-platform by camunda.
the class ExternalTaskManager method selectExternalTasksForTopics.
public List<ExternalTaskEntity> selectExternalTasksForTopics(Collection<TopicFetchInstruction> queryFilters, boolean filterByBusinessKey, int maxResults, boolean usePriority) {
if (queryFilters.isEmpty()) {
return new ArrayList<ExternalTaskEntity>();
}
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("topics", queryFilters);
parameters.put("businessKeyFilter", filterByBusinessKey);
parameters.put("now", ClockUtil.getCurrentTime());
parameters.put("applyOrdering", usePriority);
List<QueryOrderingProperty> orderingProperties = new ArrayList<QueryOrderingProperty>();
orderingProperties.add(EXT_TASK_PRIORITY_ORDERING_PROPERTY);
parameters.put("orderingProperties", orderingProperties);
ListQueryParameterObject parameter = new ListQueryParameterObject(parameters, 0, maxResults);
configureQuery(parameter);
DbEntityManager manager = getDbEntityManager();
return manager.selectList("selectExternalTasksForTopics", parameter);
}
use of org.camunda.bpm.engine.impl.QueryOrderingProperty in project camunda-bpm-platform by camunda.
the class CommentManager method findEventsByTaskId.
@SuppressWarnings("unchecked")
public List<Event> findEventsByTaskId(String taskId) {
checkHistoryEnabled();
ListQueryParameterObject query = new ListQueryParameterObject();
query.setParameter(taskId);
query.getOrderingProperties().add(new QueryOrderingProperty(new QueryPropertyImpl("TIME_"), Direction.DESCENDING));
return getDbEntityManager().selectList("selectEventsByTaskId", query);
}
use of org.camunda.bpm.engine.impl.QueryOrderingProperty in project camunda-bpm-platform by camunda.
the class FilterTaskQueryTest method testDeprecatedOrderingFormatDeserializationSecondaryOrdering.
/**
* Tests compatibility with serialization format that was used in 7.2
*/
@SuppressWarnings("deprecation")
public void testDeprecatedOrderingFormatDeserializationSecondaryOrdering() {
String sortByNameAsc = "RES." + TaskQueryProperty.NAME.getName() + " " + Direction.ASCENDING.getName();
String secondaryOrdering = sortByNameAsc + ", RES." + TaskQueryProperty.ASSIGNEE.getName() + " " + Direction.DESCENDING.getName();
JsonTaskQueryConverter converter = (JsonTaskQueryConverter) FilterEntity.queryConverter.get(EntityTypes.TASK);
JSONObject queryJson = converter.toJsonObject(filter.<TaskQuery>getQuery());
// when I apply a secondary ordering
queryJson.put(JsonTaskQueryConverter.ORDER_BY, secondaryOrdering);
TaskQueryImpl deserializedTaskQuery = (TaskQueryImpl) converter.toObject(queryJson);
// then the ordering is applied accordingly
assertEquals(2, deserializedTaskQuery.getOrderingProperties().size());
QueryOrderingProperty orderingProperty1 = deserializedTaskQuery.getOrderingProperties().get(0);
assertNull(orderingProperty1.getRelation());
assertEquals("asc", orderingProperty1.getDirection().getName());
assertNull(orderingProperty1.getRelationConditions());
assertTrue(orderingProperty1.isContainedProperty());
assertEquals(TaskQueryProperty.NAME.getName(), orderingProperty1.getQueryProperty().getName());
assertNull(orderingProperty1.getQueryProperty().getFunction());
QueryOrderingProperty orderingProperty2 = deserializedTaskQuery.getOrderingProperties().get(1);
assertNull(orderingProperty2.getRelation());
assertEquals("desc", orderingProperty2.getDirection().getName());
assertNull(orderingProperty2.getRelationConditions());
assertTrue(orderingProperty2.isContainedProperty());
assertEquals(TaskQueryProperty.ASSIGNEE.getName(), orderingProperty2.getQueryProperty().getName());
assertNull(orderingProperty2.getQueryProperty().getFunction());
}
Aggregations