Search in sources :

Example 1 with ConditionalEventDefinition

use of org.camunda.bpm.engine.impl.bpmn.parser.ConditionalEventDefinition in project camunda-bpm-platform by camunda.

the class DefaultConditionHandler method evaluateCondition.

protected boolean evaluateCondition(ConditionSet conditionSet, ActivityImpl activity) {
    ExecutionEntity temporaryExecution = new ExecutionEntity();
    if (conditionSet.getVariables() != null) {
        temporaryExecution.initializeVariableStore(conditionSet.getVariables());
    }
    temporaryExecution.setProcessDefinition(activity.getProcessDefinition());
    ConditionalEventDefinition conditionalEventDefinition = activity.getProperties().get(BpmnProperties.CONDITIONAL_EVENT_DEFINITION);
    if (conditionalEventDefinition.getVariableName() == null || conditionSet.getVariables().containsKey(conditionalEventDefinition.getVariableName())) {
        return conditionalEventDefinition.tryEvaluate(temporaryExecution);
    } else {
        return false;
    }
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ConditionalEventDefinition(org.camunda.bpm.engine.impl.bpmn.parser.ConditionalEventDefinition)

Example 2 with ConditionalEventDefinition

use of org.camunda.bpm.engine.impl.bpmn.parser.ConditionalEventDefinition in project camunda-bpm-platform by camunda.

the class EventBasedGatewayActivityBehavior method execute.

@Override
public void execute(ActivityExecution execution) throws Exception {
    // If conditional events exist after the event based gateway they should be evaluated.
    // If a condition is satisfied the event based gateway should be left,
    // otherwise the event based gateway is a wait state
    ActivityImpl eventBasedGateway = (ActivityImpl) execution.getActivity();
    for (ActivityImpl act : eventBasedGateway.getEventActivities()) {
        ActivityBehavior activityBehavior = act.getActivityBehavior();
        if (activityBehavior instanceof ConditionalEventBehavior) {
            ConditionalEventBehavior conditionalEventBehavior = (ConditionalEventBehavior) activityBehavior;
            ConditionalEventDefinition conditionalEventDefinition = conditionalEventBehavior.getConditionalEventDefinition();
            if (conditionalEventDefinition.tryEvaluate(execution)) {
                ((ExecutionEntity) execution).executeEventHandlerActivity(conditionalEventDefinition.getConditionalActivity());
                return;
            }
        }
    }
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior) ConditionalEventDefinition(org.camunda.bpm.engine.impl.bpmn.parser.ConditionalEventDefinition)

Aggregations

ConditionalEventDefinition (org.camunda.bpm.engine.impl.bpmn.parser.ConditionalEventDefinition)2 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)2 ActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)1 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)1