Search in sources :

Example 1 with ConditionalEventBehavior

use of org.camunda.bpm.engine.impl.bpmn.behavior.ConditionalEventBehavior in project camunda-bpm-platform by camunda.

the class ConditionalEventHandler method handleEvent.

@Override
public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, String businessKey, CommandContext commandContext) {
    VariableEvent variableEvent;
    if (payload == null || payload instanceof VariableEvent) {
        variableEvent = (VariableEvent) payload;
    } else {
        throw new ProcessEngineException("Payload have to be " + VariableEvent.class.getName() + ", to evaluate condition.");
    }
    ActivityImpl activity = eventSubscription.getActivity();
    ActivityBehavior activityBehavior = activity.getActivityBehavior();
    if (activityBehavior instanceof ConditionalEventBehavior) {
        ConditionalEventBehavior conditionalBehavior = (ConditionalEventBehavior) activityBehavior;
        conditionalBehavior.leaveOnSatisfiedCondition(eventSubscription, variableEvent);
    } else {
        throw new ProcessEngineException("Conditional Event has not correct behavior: " + activityBehavior);
    }
}
Also used : VariableEvent(org.camunda.bpm.engine.impl.core.variable.event.VariableEvent) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) ActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior) ConditionalEventBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.ConditionalEventBehavior) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 2 with ConditionalEventBehavior

use of org.camunda.bpm.engine.impl.bpmn.behavior.ConditionalEventBehavior in project camunda-bpm-platform by camunda.

the class DefaultMigrationInstructionGenerator method generateInstructionsForActivities.

protected List<ValidatingMigrationInstruction> generateInstructionsForActivities(Collection<ActivityImpl> sourceActivities, Collection<ActivityImpl> targetActivities, boolean updateEventTriggers, ValidatingMigrationInstructions existingInstructions) {
    List<ValidatingMigrationInstruction> generatedInstructions = new ArrayList<ValidatingMigrationInstruction>();
    for (ActivityImpl sourceActivity : sourceActivities) {
        if (!existingInstructions.containsInstructionForSourceScope(sourceActivity)) {
            for (ActivityImpl targetActivity : targetActivities) {
                if (isValidActivity(sourceActivity) && isValidActivity(targetActivity) && migrationActivityMatcher.matchActivities(sourceActivity, targetActivity)) {
                    // for conditional events the update event trigger must be set
                    boolean updateEventTriggersForInstruction = sourceActivity.getActivityBehavior() instanceof ConditionalEventBehavior || updateEventTriggers && UpdateEventTriggersValidator.definesPersistentEventTrigger(sourceActivity);
                    ValidatingMigrationInstruction generatedInstruction = new ValidatingMigrationInstructionImpl(sourceActivity, targetActivity, updateEventTriggersForInstruction);
                    generatedInstructions.add(generatedInstruction);
                }
            }
        }
    }
    return generatedInstructions;
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) ValidatingMigrationInstructionImpl(org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstructionImpl) ArrayList(java.util.ArrayList) ConditionalEventBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.ConditionalEventBehavior) ValidatingMigrationInstruction(org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstruction)

Aggregations

ConditionalEventBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.ConditionalEventBehavior)2 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)2 ArrayList (java.util.ArrayList)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 VariableEvent (org.camunda.bpm.engine.impl.core.variable.event.VariableEvent)1 ValidatingMigrationInstruction (org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstruction)1 ValidatingMigrationInstructionImpl (org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstructionImpl)1 ActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)1