use of org.camunda.bpm.engine.rest.dto.ConditionQueryParameterDto 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.dto.ConditionQueryParameterDto in project camunda-bpm-platform by camunda.
the class JobQueryDto method applyFilters.
@Override
protected void applyFilters(JobQuery query) {
if (activityId != null) {
query.activityId(activityId);
}
if (jobId != null) {
query.jobId(jobId);
}
if (executionId != null) {
query.executionId(executionId);
}
if (processInstanceId != null) {
query.processInstanceId(processInstanceId);
}
if (processDefinitionId != null) {
query.processDefinitionId(processDefinitionId);
}
if (processDefinitionKey != null) {
query.processDefinitionKey(processDefinitionKey);
}
if (TRUE.equals(withRetriesLeft)) {
query.withRetriesLeft();
}
if (TRUE.equals(executable)) {
query.executable();
}
if (TRUE.equals(timers)) {
if (messages != null && messages) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Parameter timers cannot be used together with parameter messages.");
}
query.timers();
}
if (TRUE.equals(messages)) {
if (timers != null && timers) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Parameter messages cannot be used together with parameter timers.");
}
query.messages();
}
if (TRUE.equals(withException)) {
query.withException();
}
if (exceptionMessage != null) {
query.exceptionMessage(exceptionMessage);
}
if (TRUE.equals(noRetriesLeft)) {
query.noRetriesLeft();
}
if (TRUE.equals(active)) {
query.active();
}
if (TRUE.equals(suspended)) {
query.suspended();
}
if (priorityHigherThanOrEquals != null) {
query.priorityHigherThanOrEquals(priorityHigherThanOrEquals);
}
if (priorityLowerThanOrEquals != null) {
query.priorityLowerThanOrEquals(priorityLowerThanOrEquals);
}
if (jobDefinitionId != null) {
query.jobDefinitionId(jobDefinitionId);
}
if (dueDates != null) {
DateConverter dateConverter = new DateConverter();
dateConverter.setObjectMapper(objectMapper);
for (ConditionQueryParameterDto conditionQueryParam : dueDates) {
String op = conditionQueryParam.getOperator();
Date dueDate = null;
try {
dueDate = dateConverter.convertQueryParameterToType((String) conditionQueryParam.getValue());
} catch (RestException e) {
throw new InvalidRequestException(e.getStatus(), e, "Invalid due date format: " + e.getMessage());
}
if (op.equals(ConditionQueryParameterDto.GREATER_THAN_OPERATOR_NAME)) {
query.duedateHigherThan(dueDate);
} else if (op.equals(ConditionQueryParameterDto.LESS_THAN_OPERATOR_NAME)) {
query.duedateLowerThan(dueDate);
} else {
throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid due date comparator specified: " + op);
}
}
}
if (tenantIds != null && !tenantIds.isEmpty()) {
query.tenantIdIn(tenantIds.toArray(new String[tenantIds.size()]));
}
if (TRUE.equals(withoutTenantId)) {
query.withoutTenantId();
}
if (TRUE.equals(includeJobsWithoutTenantId)) {
query.includeJobsWithoutTenantId();
}
}
Aggregations