use of org.camunda.bpm.engine.rest.exception.InvalidRequestException 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);
}
}
}
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceReportQueryDto method executeCompletedReport.
public List<HistoricTaskInstanceReportResult> executeCompletedReport(ProcessEngine engine) {
HistoricTaskInstanceReport reportQuery = createNewReportQuery(engine);
applyFilters(reportQuery);
if (PROCESS_DEFINITION.equals(groupby)) {
return reportQuery.countByProcessDefinitionKey();
} else if (TASK_NAME.equals(groupby)) {
return reportQuery.countByTaskName();
} else {
throw new InvalidRequestException(Response.Status.BAD_REQUEST, "groupBy parameter has invalid value: " + groupby);
}
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException 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;
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class ConditionListConverter method convertQueryParameterToType.
@Override
public List<ConditionQueryParameterDto> convertQueryParameterToType(String value) {
String[] expressions = value.split(EXPRESSION_DELIMITER);
List<ConditionQueryParameterDto> queryConditions = new ArrayList<ConditionQueryParameterDto>();
for (String expression : expressions) {
String[] valueTuple = expression.split(ATTRIBUTE_DELIMITER);
if (valueTuple.length != 2) {
throw new InvalidRequestException(Status.BAD_REQUEST, "condition query parameter has to have format OPERATOR_VALUE.");
}
ConditionQueryParameterDto queryCondition = new ConditionQueryParameterDto();
queryCondition.setOperator(valueTuple[0]);
queryCondition.setValue(valueTuple[1]);
queryConditions.add(queryCondition);
}
return queryConditions;
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class AbstractSearchQueryDto method setValueBasedOnAnnotation.
/**
* Finds the methods that are annotated with a {@link CamundaQueryParam} with a value that matches the key parameter.
* Before invoking these methods, the annotated {@link StringToTypeConverter} is used to convert the String value to the desired Java type.
* @param key
* @param value
*/
protected void setValueBasedOnAnnotation(String key, String value) {
List<Method> matchingMethods = findMatchingAnnotatedMethods(key);
for (Method method : matchingMethods) {
Class<? extends JacksonAwareStringToTypeConverter<?>> converterClass = findAnnotatedTypeConverter(method);
if (converterClass == null) {
continue;
}
JacksonAwareStringToTypeConverter<?> converter = null;
try {
converter = converterClass.newInstance();
converter.setObjectMapper(objectMapper);
Object convertedValue = converter.convertQueryParameterToType(value);
method.invoke(this, convertedValue);
} catch (InstantiationException e) {
throw new RestException(Status.INTERNAL_SERVER_ERROR, e, "Server error.");
} catch (IllegalAccessException e) {
throw new RestException(Status.INTERNAL_SERVER_ERROR, e, "Server error.");
} catch (InvocationTargetException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e, "Cannot set query parameter '" + key + "' to value '" + value + "'");
} catch (RestException e) {
throw new InvalidRequestException(e.getStatus(), e, "Cannot set query parameter '" + key + "' to value '" + value + "': " + e.getMessage());
}
}
}
Aggregations