Search in sources :

Example 1 with VariableQueryParameterDto

use of org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto in project camunda-bpm-platform by camunda.

the class HistoricTaskInstanceQueryDto method applyFilters.

@Override
protected void applyFilters(HistoricTaskInstanceQuery query) {
    if (taskId != null) {
        query.taskId(taskId);
    }
    if (taskParentTaskId != null) {
        query.taskParentTaskId(taskParentTaskId);
    }
    if (processInstanceId != null) {
        query.processInstanceId(processInstanceId);
    }
    if (processInstanceBusinessKey != null) {
        query.processInstanceBusinessKey(processInstanceBusinessKey);
    }
    if (processInstanceBusinessKeyIn != null && processInstanceBusinessKeyIn.length > 0) {
        query.processInstanceBusinessKeyIn(processInstanceBusinessKeyIn);
    }
    if (processInstanceBusinessKeyLike != null) {
        query.processInstanceBusinessKeyLike(processInstanceBusinessKeyLike);
    }
    if (executionId != null) {
        query.executionId(executionId);
    }
    if (activityInstanceIdIn != null && activityInstanceIdIn.length > 0) {
        query.activityInstanceIdIn(activityInstanceIdIn);
    }
    if (processDefinitionId != null) {
        query.processDefinitionId(processDefinitionId);
    }
    if (processDefinitionKey != null) {
        query.processDefinitionKey(processDefinitionKey);
    }
    if (processDefinitionName != null) {
        query.processDefinitionName(processDefinitionName);
    }
    if (taskName != null) {
        query.taskName(taskName);
    }
    if (taskNameLike != null) {
        query.taskNameLike(taskNameLike);
    }
    if (taskDescription != null) {
        query.taskDescription(taskDescription);
    }
    if (taskDescriptionLike != null) {
        query.taskDescriptionLike(taskDescriptionLike);
    }
    if (taskDefinitionKey != null) {
        query.taskDefinitionKey(taskDefinitionKey);
    }
    if (taskDefinitionKeyIn != null && taskDefinitionKeyIn.length > 0) {
        query.taskDefinitionKeyIn(taskDefinitionKeyIn);
    }
    if (taskDeleteReason != null) {
        query.taskDeleteReason(taskDeleteReason);
    }
    if (taskDeleteReasonLike != null) {
        query.taskDeleteReasonLike(taskDeleteReasonLike);
    }
    if (assigned != null) {
        query.taskAssigned();
    }
    if (unassigned != null) {
        query.taskUnassigned();
    }
    if (taskAssignee != null) {
        query.taskAssignee(taskAssignee);
    }
    if (taskAssigneeLike != null) {
        query.taskAssigneeLike(taskAssigneeLike);
    }
    if (taskOwner != null) {
        query.taskOwner(taskOwner);
    }
    if (taskOwnerLike != null) {
        query.taskOwnerLike(taskOwnerLike);
    }
    if (taskPriority != null) {
        query.taskPriority(taskPriority);
    }
    if (finished != null) {
        query.finished();
    }
    if (unfinished != null) {
        query.unfinished();
    }
    if (processFinished != null) {
        query.processFinished();
    }
    if (processUnfinished != null) {
        query.processUnfinished();
    }
    if (taskDueDate != null) {
        query.taskDueDate(taskDueDate);
    }
    if (taskDueDateBefore != null) {
        query.taskDueBefore(taskDueDateBefore);
    }
    if (taskDueDateAfter != null) {
        query.taskDueAfter(taskDueDateAfter);
    }
    if (taskFollowUpDate != null) {
        query.taskFollowUpDate(taskFollowUpDate);
    }
    if (taskFollowUpDateBefore != null) {
        query.taskFollowUpBefore(taskFollowUpDateBefore);
    }
    if (taskFollowUpDateAfter != null) {
        query.taskFollowUpAfter(taskFollowUpDateAfter);
    }
    if (caseDefinitionId != null) {
        query.caseDefinitionId(caseDefinitionId);
    }
    if (caseDefinitionKey != null) {
        query.caseDefinitionKey(caseDefinitionKey);
    }
    if (caseDefinitionName != null) {
        query.caseDefinitionName(caseDefinitionName);
    }
    if (caseInstanceId != null) {
        query.caseInstanceId(caseInstanceId);
    }
    if (caseExecutionId != null) {
        query.caseExecutionId(caseExecutionId);
    }
    if (tenantIds != null && !tenantIds.isEmpty()) {
        query.tenantIdIn(tenantIds.toArray(new String[tenantIds.size()]));
    }
    if (taskInvolvedUser != null) {
        query.taskInvolvedUser(taskInvolvedUser);
    }
    if (taskInvolvedGroup != null) {
        query.taskInvolvedGroup(taskInvolvedGroup);
    }
    if (taskHadCandidateUser != null) {
        query.taskHadCandidateUser(taskHadCandidateUser);
    }
    if (taskHadCandidateGroup != null) {
        query.taskHadCandidateGroup(taskHadCandidateGroup);
    }
    if (withCandidateGroups != null) {
        query.withCandidateGroups();
    }
    if (withoutCandidateGroups != null) {
        query.withoutCandidateGroups();
    }
    if (finishedAfter != null) {
        query.finishedAfter(finishedAfter);
    }
    if (finishedBefore != null) {
        query.finishedBefore(finishedBefore);
    }
    if (startedAfter != null) {
        query.startedAfter(startedAfter);
    }
    if (startedBefore != null) {
        query.startedBefore(startedBefore);
    }
    if (taskVariables != null) {
        for (VariableQueryParameterDto variableQueryParam : taskVariables) {
            String variableName = variableQueryParam.getName();
            String op = variableQueryParam.getOperator();
            Object variableValue = variableQueryParam.resolveValue(objectMapper);
            if (op.equals(VariableQueryParameterDto.EQUALS_OPERATOR_NAME)) {
                query.taskVariableValueEquals(variableName, variableValue);
            } else {
                throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid variable comparator specified: " + op);
            }
        }
    }
    if (processVariables != null) {
        for (VariableQueryParameterDto variableQueryParam : processVariables) {
            String variableName = variableQueryParam.getName();
            String op = variableQueryParam.getOperator();
            Object variableValue = variableQueryParam.resolveValue(objectMapper);
            if (op.equals(VariableQueryParameterDto.EQUALS_OPERATOR_NAME)) {
                query.processVariableValueEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.NOT_EQUALS_OPERATOR_NAME)) {
                query.processVariableValueNotEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OPERATOR_NAME)) {
                query.processVariableValueGreaterThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.processVariableValueGreaterThanOrEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OPERATOR_NAME)) {
                query.processVariableValueLessThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.processVariableValueLessThanOrEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LIKE_OPERATOR_NAME)) {
                query.processVariableValueLike(variableName, String.valueOf(variableValue));
            } else {
                throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid process variable comparator specified: " + op);
            }
        }
    }
}
Also used : InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) VariableQueryParameterDto(org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto)

Example 2 with VariableQueryParameterDto

use of org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto in project camunda-bpm-platform by camunda.

the class VariableListConverter method convertQueryParameterToType.

/**
 * Expects a query parameter of multiple variable expressions formatted as KEY_OPERATOR_VALUE, e.g. aVariable_eq_aValue.
 * Multiple values are expected to be comma-separated.
 */
@Override
public List<VariableQueryParameterDto> convertQueryParameterToType(String value) {
    String[] expressions = value.split(EXPRESSION_DELIMITER);
    List<VariableQueryParameterDto> queryVariables = new ArrayList<VariableQueryParameterDto>();
    for (String expression : expressions) {
        String[] valueTriple = expression.split(ATTRIBUTE_DELIMITER);
        if (valueTriple.length != 3) {
            throw new InvalidRequestException(Status.BAD_REQUEST, "variable query parameter has to have format KEY_OPERATOR_VALUE.");
        }
        VariableQueryParameterDto queryVariable = new VariableQueryParameterDto();
        queryVariable.setName(valueTriple[0]);
        queryVariable.setOperator(valueTriple[1]);
        queryVariable.setValue(valueTriple[2]);
        queryVariables.add(queryVariable);
    }
    return queryVariables;
}
Also used : ArrayList(java.util.ArrayList) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) VariableQueryParameterDto(org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto)

Example 3 with VariableQueryParameterDto

use of org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto 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;
}
Also used : TaskQueryVariableValue(org.camunda.bpm.engine.impl.TaskQueryVariableValue) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty) VariableQueryParameterDto(org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto)

Example 4 with VariableQueryParameterDto

use of org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto in project camunda-bpm-platform by camunda.

the class TaskQueryDto method applyFilters.

@Override
protected void applyFilters(TaskQuery query) {
    if (orQueries != null) {
        for (TaskQueryDto orQueryDto : orQueries) {
            TaskQueryImpl orQuery = new TaskQueryImpl();
            orQuery.setOrQueryActive();
            orQueryDto.applyFilters(orQuery);
            ((TaskQueryImpl) query).addOrQuery(orQuery);
        }
    }
    if (processInstanceBusinessKey != null) {
        query.processInstanceBusinessKey(processInstanceBusinessKey);
    }
    if (processInstanceBusinessKeyExpression != null) {
        query.processInstanceBusinessKeyExpression(processInstanceBusinessKeyExpression);
    }
    if (processInstanceBusinessKeyIn != null && processInstanceBusinessKeyIn.length > 0) {
        query.processInstanceBusinessKeyIn(processInstanceBusinessKeyIn);
    }
    if (processInstanceBusinessKeyLike != null) {
        query.processInstanceBusinessKeyLike(processInstanceBusinessKeyLike);
    }
    if (processInstanceBusinessKeyLikeExpression != null) {
        query.processInstanceBusinessKeyLikeExpression(processInstanceBusinessKeyLikeExpression);
    }
    if (processDefinitionKey != null) {
        query.processDefinitionKey(processDefinitionKey);
    }
    if (processDefinitionKeyIn != null && processDefinitionKeyIn.length > 0) {
        query.processDefinitionKeyIn(processDefinitionKeyIn);
    }
    if (processDefinitionId != null) {
        query.processDefinitionId(processDefinitionId);
    }
    if (executionId != null) {
        query.executionId(executionId);
    }
    if (activityInstanceIdIn != null && activityInstanceIdIn.length > 0) {
        query.activityInstanceIdIn(activityInstanceIdIn);
    }
    if (tenantIdIn != null && tenantIdIn.length > 0) {
        query.tenantIdIn(tenantIdIn);
    }
    if (TRUE.equals(withoutTenantId)) {
        query.withoutTenantId();
    }
    if (processDefinitionName != null) {
        query.processDefinitionName(processDefinitionName);
    }
    if (processDefinitionNameLike != null) {
        query.processDefinitionNameLike(processDefinitionNameLike);
    }
    if (processInstanceId != null) {
        query.processInstanceId(processInstanceId);
    }
    if (assignee != null) {
        query.taskAssignee(assignee);
    }
    if (assigneeExpression != null) {
        query.taskAssigneeExpression(assigneeExpression);
    }
    if (assigneeLike != null) {
        query.taskAssigneeLike(assigneeLike);
    }
    if (assigneeLikeExpression != null) {
        query.taskAssigneeLikeExpression(assigneeLikeExpression);
    }
    if (candidateGroup != null) {
        query.taskCandidateGroup(candidateGroup);
    }
    if (candidateGroupExpression != null) {
        query.taskCandidateGroupExpression(candidateGroupExpression);
    }
    if (withCandidateGroups != null && withCandidateGroups) {
        query.withCandidateGroups();
    }
    if (withoutCandidateGroups != null && withoutCandidateGroups) {
        query.withoutCandidateGroups();
    }
    if (withCandidateUsers != null && withCandidateUsers) {
        query.withCandidateUsers();
    }
    if (withoutCandidateUsers != null && withoutCandidateUsers) {
        query.withoutCandidateUsers();
    }
    if (candidateUser != null) {
        query.taskCandidateUser(candidateUser);
    }
    if (candidateUserExpression != null) {
        query.taskCandidateUserExpression(candidateUserExpression);
    }
    if (taskDefinitionKeyIn != null && taskDefinitionKeyIn.length > 0) {
        query.taskDefinitionKeyIn(taskDefinitionKeyIn);
    }
    if (taskDefinitionKey != null) {
        query.taskDefinitionKey(taskDefinitionKey);
    }
    if (taskDefinitionKeyLike != null) {
        query.taskDefinitionKeyLike(taskDefinitionKeyLike);
    }
    if (description != null) {
        query.taskDescription(description);
    }
    if (descriptionLike != null) {
        query.taskDescriptionLike(descriptionLike);
    }
    if (involvedUser != null) {
        query.taskInvolvedUser(involvedUser);
    }
    if (involvedUserExpression != null) {
        query.taskInvolvedUserExpression(involvedUserExpression);
    }
    if (maxPriority != null) {
        query.taskMaxPriority(maxPriority);
    }
    if (minPriority != null) {
        query.taskMinPriority(minPriority);
    }
    if (name != null) {
        query.taskName(name);
    }
    if (nameNotEqual != null) {
        query.taskNameNotEqual(nameNotEqual);
    }
    if (nameLike != null) {
        query.taskNameLike(nameLike);
    }
    if (nameNotLike != null) {
        query.taskNameNotLike(nameNotLike);
    }
    if (owner != null) {
        query.taskOwner(owner);
    }
    if (ownerExpression != null) {
        query.taskOwnerExpression(ownerExpression);
    }
    if (priority != null) {
        query.taskPriority(priority);
    }
    if (parentTaskId != null) {
        query.taskParentTaskId(parentTaskId);
    }
    if (assigned != null && assigned) {
        query.taskAssigned();
    }
    if (unassigned != null && unassigned) {
        query.taskUnassigned();
    }
    if (dueAfter != null) {
        query.dueAfter(dueAfter);
    }
    if (dueAfterExpression != null) {
        query.dueAfterExpression(dueAfterExpression);
    }
    if (dueBefore != null) {
        query.dueBefore(dueBefore);
    }
    if (dueBeforeExpression != null) {
        query.dueBeforeExpression(dueBeforeExpression);
    }
    if (dueDate != null) {
        query.dueDate(dueDate);
    }
    if (dueDateExpression != null) {
        query.dueDateExpression(dueDateExpression);
    }
    if (followUpAfter != null) {
        query.followUpAfter(followUpAfter);
    }
    if (followUpAfterExpression != null) {
        query.followUpAfterExpression(followUpAfterExpression);
    }
    if (followUpBefore != null) {
        query.followUpBefore(followUpBefore);
    }
    if (followUpBeforeExpression != null) {
        query.followUpBeforeExpression(followUpBeforeExpression);
    }
    if (followUpBeforeOrNotExistent != null) {
        query.followUpBeforeOrNotExistent(followUpBeforeOrNotExistent);
    }
    if (followUpBeforeOrNotExistentExpression != null) {
        query.followUpBeforeOrNotExistentExpression(followUpBeforeOrNotExistentExpression);
    }
    if (followUpDate != null) {
        query.followUpDate(followUpDate);
    }
    if (followUpDateExpression != null) {
        query.followUpDateExpression(followUpDateExpression);
    }
    if (createdAfter != null) {
        query.taskCreatedAfter(createdAfter);
    }
    if (createdAfterExpression != null) {
        query.taskCreatedAfterExpression(createdAfterExpression);
    }
    if (createdBefore != null) {
        query.taskCreatedBefore(createdBefore);
    }
    if (createdBeforeExpression != null) {
        query.taskCreatedBeforeExpression(createdBeforeExpression);
    }
    if (createdOn != null) {
        query.taskCreatedOn(createdOn);
    }
    if (createdOnExpression != null) {
        query.taskCreatedOnExpression(createdOnExpression);
    }
    if (delegationState != null) {
        DelegationStateConverter converter = new DelegationStateConverter();
        DelegationState state = converter.convertQueryParameterToType(delegationState);
        query.taskDelegationState(state);
    }
    if (candidateGroups != null) {
        query.taskCandidateGroupIn(candidateGroups);
    }
    if (candidateGroupsExpression != null) {
        query.taskCandidateGroupInExpression(candidateGroupsExpression);
    }
    if (includeAssignedTasks != null && includeAssignedTasks) {
        query.includeAssignedTasks();
    }
    if (active != null && active) {
        query.active();
    }
    if (suspended != null && suspended) {
        query.suspended();
    }
    if (caseDefinitionId != null) {
        query.caseDefinitionId(caseDefinitionId);
    }
    if (caseDefinitionKey != null) {
        query.caseDefinitionKey(caseDefinitionKey);
    }
    if (caseDefinitionName != null) {
        query.caseDefinitionName(caseDefinitionName);
    }
    if (caseDefinitionNameLike != null) {
        query.caseDefinitionNameLike(caseDefinitionNameLike);
    }
    if (caseExecutionId != null) {
        query.caseExecutionId(caseExecutionId);
    }
    if (caseInstanceBusinessKey != null) {
        query.caseInstanceBusinessKey(caseInstanceBusinessKey);
    }
    if (caseInstanceBusinessKeyLike != null) {
        query.caseInstanceBusinessKeyLike(caseInstanceBusinessKeyLike);
    }
    if (caseInstanceId != null) {
        query.caseInstanceId(caseInstanceId);
    }
    if (taskVariables != null) {
        for (VariableQueryParameterDto variableQueryParam : taskVariables) {
            String variableName = variableQueryParam.getName();
            String op = variableQueryParam.getOperator();
            Object variableValue = variableQueryParam.resolveValue(objectMapper);
            if (op.equals(VariableQueryParameterDto.EQUALS_OPERATOR_NAME)) {
                query.taskVariableValueEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.NOT_EQUALS_OPERATOR_NAME)) {
                query.taskVariableValueNotEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OPERATOR_NAME)) {
                query.taskVariableValueGreaterThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.taskVariableValueGreaterThanOrEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OPERATOR_NAME)) {
                query.taskVariableValueLessThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.taskVariableValueLessThanOrEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LIKE_OPERATOR_NAME)) {
                query.taskVariableValueLike(variableName, String.valueOf(variableValue));
            } else {
                throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid task variable comparator specified: " + op);
            }
        }
    }
    if (processVariables != null) {
        for (VariableQueryParameterDto variableQueryParam : processVariables) {
            String variableName = variableQueryParam.getName();
            String op = variableQueryParam.getOperator();
            Object variableValue = variableQueryParam.resolveValue(objectMapper);
            if (op.equals(VariableQueryParameterDto.EQUALS_OPERATOR_NAME)) {
                query.processVariableValueEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.NOT_EQUALS_OPERATOR_NAME)) {
                query.processVariableValueNotEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OPERATOR_NAME)) {
                query.processVariableValueGreaterThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.processVariableValueGreaterThanOrEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OPERATOR_NAME)) {
                query.processVariableValueLessThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.processVariableValueLessThanOrEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LIKE_OPERATOR_NAME)) {
                query.processVariableValueLike(variableName, String.valueOf(variableValue));
            } else {
                throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid process variable comparator specified: " + op);
            }
        }
    }
    if (caseInstanceVariables != null) {
        for (VariableQueryParameterDto variableQueryParam : caseInstanceVariables) {
            String variableName = variableQueryParam.getName();
            String op = variableQueryParam.getOperator();
            Object variableValue = variableQueryParam.resolveValue(objectMapper);
            if (op.equals(VariableQueryParameterDto.EQUALS_OPERATOR_NAME)) {
                query.caseInstanceVariableValueEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.NOT_EQUALS_OPERATOR_NAME)) {
                query.caseInstanceVariableValueNotEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OPERATOR_NAME)) {
                query.caseInstanceVariableValueGreaterThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.caseInstanceVariableValueGreaterThanOrEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OPERATOR_NAME)) {
                query.caseInstanceVariableValueLessThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.caseInstanceVariableValueLessThanOrEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LIKE_OPERATOR_NAME)) {
                query.caseInstanceVariableValueLike(variableName, String.valueOf(variableValue));
            } else {
                throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid case variable comparator specified: " + op);
            }
        }
    }
}
Also used : DelegationState(org.camunda.bpm.engine.task.DelegationState) DelegationStateConverter(org.camunda.bpm.engine.rest.dto.converter.DelegationStateConverter) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) VariableQueryParameterDto(org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto)

Example 5 with VariableQueryParameterDto

use of org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto in project camunda-bpm-platform by camunda.

the class CaseExecutionQueryDto method applyFilters.

@Override
protected void applyFilters(CaseExecutionQuery query) {
    if (caseExecutionId != null) {
        query.caseExecutionId(caseExecutionId);
    }
    if (caseInstanceId != null) {
        query.caseInstanceId(caseInstanceId);
    }
    if (businessKey != null) {
        query.caseInstanceBusinessKey(businessKey);
    }
    if (caseDefinitionKey != null) {
        query.caseDefinitionKey(caseDefinitionKey);
    }
    if (caseDefinitionId != null) {
        query.caseDefinitionId(caseDefinitionId);
    }
    if (activityId != null) {
        query.activityId(activityId);
    }
    if (tenantIds != null && !tenantIds.isEmpty()) {
        query.tenantIdIn(tenantIds.toArray(new String[tenantIds.size()]));
    }
    if (required != null && required == true) {
        query.required();
    }
    if (active != null && active == true) {
        query.active();
    }
    if (enabled != null && enabled == true) {
        query.enabled();
    }
    if (disabled != null && disabled == true) {
        query.disabled();
    }
    if (variables != null) {
        for (VariableQueryParameterDto variableQueryParam : variables) {
            String variableName = variableQueryParam.getName();
            String op = variableQueryParam.getOperator();
            Object variableValue = variableQueryParam.resolveValue(objectMapper);
            if (op.equals(VariableQueryParameterDto.EQUALS_OPERATOR_NAME)) {
                query.variableValueEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OPERATOR_NAME)) {
                query.variableValueGreaterThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.variableValueGreaterThanOrEqual(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OPERATOR_NAME)) {
                query.variableValueLessThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.variableValueLessThanOrEqual(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.NOT_EQUALS_OPERATOR_NAME)) {
                query.variableValueNotEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LIKE_OPERATOR_NAME)) {
                query.variableValueLike(variableName, String.valueOf(variableValue));
            } else {
                throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid variable comparator specified: " + op);
            }
        }
    }
    if (caseInstanceVariables != null) {
        for (VariableQueryParameterDto variableQueryParam : caseInstanceVariables) {
            String variableName = variableQueryParam.getName();
            String op = variableQueryParam.getOperator();
            Object variableValue = variableQueryParam.resolveValue(objectMapper);
            if (op.equals(VariableQueryParameterDto.EQUALS_OPERATOR_NAME)) {
                query.caseInstanceVariableValueEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OPERATOR_NAME)) {
                query.caseInstanceVariableValueGreaterThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.caseInstanceVariableValueGreaterThanOrEqual(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OPERATOR_NAME)) {
                query.caseInstanceVariableValueLessThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.caseInstanceVariableValueLessThanOrEqual(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.NOT_EQUALS_OPERATOR_NAME)) {
                query.caseInstanceVariableValueNotEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LIKE_OPERATOR_NAME)) {
                query.caseInstanceVariableValueLike(variableName, String.valueOf(variableValue));
            } else {
                throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid variable comparator specified: " + op);
            }
        }
    }
}
Also used : InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) VariableQueryParameterDto(org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto)

Aggregations

VariableQueryParameterDto (org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto)11 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)10 TaskQueryImpl (org.camunda.bpm.engine.impl.TaskQueryImpl)2 ArrayList (java.util.ArrayList)1 QueryOrderingProperty (org.camunda.bpm.engine.impl.QueryOrderingProperty)1 TaskQueryVariableValue (org.camunda.bpm.engine.impl.TaskQueryVariableValue)1 DelegationStateConverter (org.camunda.bpm.engine.rest.dto.converter.DelegationStateConverter)1 DelegationState (org.camunda.bpm.engine.task.DelegationState)1