Search in sources :

Example 1 with ConditionEvaluationBuilder

use of org.camunda.bpm.engine.runtime.ConditionEvaluationBuilder in project camunda-bpm-platform by camunda.

the class ConditionRestServiceImpl method createConditionEvaluationBuilder.

protected ConditionEvaluationBuilder createConditionEvaluationBuilder(EvaluationConditionDto conditionDto) {
    RuntimeService runtimeService = processEngine.getRuntimeService();
    ObjectMapper objectMapper = getObjectMapper();
    VariableMap variables = VariableValueDto.toMap(conditionDto.getVariables(), processEngine, objectMapper);
    ConditionEvaluationBuilder builder = runtimeService.createConditionEvaluation();
    if (variables != null && !variables.isEmpty()) {
        builder.setVariables(variables);
    }
    if (conditionDto.getBusinessKey() != null) {
        builder.processInstanceBusinessKey(conditionDto.getBusinessKey());
    }
    if (conditionDto.getProcessDefinitionId() != null) {
        builder.processDefinitionId(conditionDto.getProcessDefinitionId());
    }
    if (conditionDto.getTenantId() != null) {
        builder.tenantId(conditionDto.getTenantId());
    } else if (conditionDto.isWithoutTenantId()) {
        builder.withoutTenantId();
    }
    return builder;
}
Also used : RuntimeService(org.camunda.bpm.engine.RuntimeService) VariableMap(org.camunda.bpm.engine.variable.VariableMap) ConditionEvaluationBuilder(org.camunda.bpm.engine.runtime.ConditionEvaluationBuilder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with ConditionEvaluationBuilder

use of org.camunda.bpm.engine.runtime.ConditionEvaluationBuilder in project camunda-bpm-platform by camunda.

the class ConditionRestServiceImpl method evaluateCondition.

@Override
public List<ProcessInstanceDto> evaluateCondition(EvaluationConditionDto conditionDto) {
    if (conditionDto.getTenantId() != null && conditionDto.isWithoutTenantId()) {
        throw new InvalidRequestException(Status.BAD_REQUEST, "Parameter 'tenantId' cannot be used together with parameter 'withoutTenantId'.");
    }
    ConditionEvaluationBuilder builder = createConditionEvaluationBuilder(conditionDto);
    List<ProcessInstance> processInstances = builder.evaluateStartConditions();
    List<ProcessInstanceDto> result = new ArrayList<ProcessInstanceDto>();
    for (ProcessInstance processInstance : processInstances) {
        result.add(ProcessInstanceDto.fromProcessInstance(processInstance));
    }
    return result;
}
Also used : ProcessInstanceDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceDto) ConditionEvaluationBuilder(org.camunda.bpm.engine.runtime.ConditionEvaluationBuilder) ArrayList(java.util.ArrayList) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance)

Aggregations

ConditionEvaluationBuilder (org.camunda.bpm.engine.runtime.ConditionEvaluationBuilder)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayList (java.util.ArrayList)1 RuntimeService (org.camunda.bpm.engine.RuntimeService)1 ProcessInstanceDto (org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)1 VariableMap (org.camunda.bpm.engine.variable.VariableMap)1