Search in sources :

Example 1 with ActivityBehavior

use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior in project camunda-bpm-platform by camunda.

the class ServiceTaskDelegateExpressionActivityBehavior method doSignal.

public void doSignal(final ActivityExecution execution, final String signalName, final Object signalData) throws Exception {
    Object delegate = expression.getValue(execution);
    applyFieldDeclaration(fieldDeclarations, delegate);
    final ActivityBehavior activityBehaviorInstance = getActivityBehaviorInstance(execution, delegate);
    if (activityBehaviorInstance instanceof CustomActivityBehavior) {
        CustomActivityBehavior behavior = (CustomActivityBehavior) activityBehaviorInstance;
        ActivityBehavior delegateActivityBehavior = behavior.getDelegateActivityBehavior();
        if (!(delegateActivityBehavior instanceof SignallableActivityBehavior)) {
            // legacy behavior: do nothing when it is not a signallable activity behavior
            return;
        }
    }
    executeWithErrorPropagation(execution, new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            ((SignallableActivityBehavior) activityBehaviorInstance).signal(execution, signalName, signalData);
            return null;
        }
    });
}
Also used : SignallableActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.SignallableActivityBehavior) SignallableActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.SignallableActivityBehavior) ActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)

Example 2 with ActivityBehavior

use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior in project camunda-bpm-platform by camunda.

the class BpmnParse method parseIntermediateThrowEvent.

public ActivityImpl parseIntermediateThrowEvent(Element intermediateEventElement, ScopeImpl scopeElement) {
    Element signalEventDefinitionElement = intermediateEventElement.element(SIGNAL_EVENT_DEFINITION);
    Element compensateEventDefinitionElement = intermediateEventElement.element(COMPENSATE_EVENT_DEFINITION);
    Element linkEventDefinitionElement = intermediateEventElement.element(LINK_EVENT_DEFINITION);
    Element messageEventDefinitionElement = intermediateEventElement.element(MESSAGE_EVENT_DEFINITION);
    Element escalationEventDefinition = intermediateEventElement.element(ESCALATION_EVENT_DEFINITION);
    // event (event target)
    if (linkEventDefinitionElement != null) {
        String linkName = linkEventDefinitionElement.attribute("name");
        String elementId = intermediateEventElement.attribute("id");
        // now we remember the link in order to replace the sequence flow later on
        eventLinkSources.put(elementId, linkName);
        // and done - no activity created
        return null;
    }
    ActivityImpl nestedActivityImpl = createActivityOnScope(intermediateEventElement, scopeElement);
    ActivityBehavior activityBehavior = null;
    parseAsynchronousContinuationForActivity(intermediateEventElement, nestedActivityImpl);
    if (signalEventDefinitionElement != null) {
        nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_SIGNAL_THROW);
        EventSubscriptionDeclaration signalDefinition = parseSignalEventDefinition(signalEventDefinitionElement, true);
        activityBehavior = new ThrowSignalEventActivityBehavior(signalDefinition);
    } else if (compensateEventDefinitionElement != null) {
        nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_COMPENSATION_THROW);
        CompensateEventDefinition compensateEventDefinition = parseThrowCompensateEventDefinition(compensateEventDefinitionElement, scopeElement);
        activityBehavior = new CompensationEventActivityBehavior(compensateEventDefinition);
        nestedActivityImpl.setProperty(PROPERTYNAME_THROWS_COMPENSATION, true);
        nestedActivityImpl.setScope(true);
    } else if (messageEventDefinitionElement != null) {
        if (isServiceTaskLike(messageEventDefinitionElement)) {
            // CAM-436 same behavior as service task
            nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_MESSAGE_THROW);
            activityBehavior = parseServiceTaskLike(ActivityTypes.INTERMEDIATE_EVENT_MESSAGE_THROW, messageEventDefinitionElement, scopeElement).getActivityBehavior();
        } else {
            // default to non behavior if no service task
            // properties have been specified
            nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_NONE_THROW);
            activityBehavior = new IntermediateThrowNoneEventActivityBehavior();
        }
    } else if (escalationEventDefinition != null) {
        nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_ESCALATION_THROW);
        Escalation escalation = findEscalationForEscalationEventDefinition(escalationEventDefinition);
        if (escalation != null && escalation.getEscalationCode() == null) {
            addError("throwing escalation event must have an 'escalationCode'", escalationEventDefinition);
        }
        activityBehavior = new ThrowEscalationEventActivityBehavior(escalation);
    } else {
        // None intermediate event
        nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_NONE_THROW);
        activityBehavior = new IntermediateThrowNoneEventActivityBehavior();
    }
    for (BpmnParseListener parseListener : parseListeners) {
        parseListener.parseIntermediateThrowEvent(intermediateEventElement, scopeElement, nestedActivityImpl);
    }
    nestedActivityImpl.setActivityBehavior(activityBehavior);
    parseExecutionListenersOnScope(intermediateEventElement, nestedActivityImpl);
    return nestedActivityImpl;
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element) ActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)

Example 3 with ActivityBehavior

use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior in project camunda-bpm-platform by camunda.

the class ClassDelegateActivityBehavior method doSignal.

protected void doSignal(final ActivityExecution execution, final String signalName, final Object signalData) throws Exception {
    final ActivityBehavior activityBehaviorInstance = getActivityBehaviorInstance(execution);
    if (activityBehaviorInstance instanceof CustomActivityBehavior) {
        CustomActivityBehavior behavior = (CustomActivityBehavior) activityBehaviorInstance;
        ActivityBehavior delegate = behavior.getDelegateActivityBehavior();
        if (!(delegate instanceof SignallableActivityBehavior)) {
            throw LOG.incorrectlyUsedSignalException(SignallableActivityBehavior.class.getName());
        }
    }
    executeWithErrorPropagation(execution, new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            ((SignallableActivityBehavior) activityBehaviorInstance).signal(execution, signalName, signalData);
            return null;
        }
    });
}
Also used : SignallableActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.SignallableActivityBehavior) SignallableActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.SignallableActivityBehavior) ActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)

Example 4 with ActivityBehavior

use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior 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 5 with ActivityBehavior

use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior in project camunda-bpm-platform by camunda.

the class LegacyBehavior method removeLegacySubscriptionOnParent.

/**
 * <p>Required for migrating active sequential MI receive tasks. These activities were formerly not scope,
 * but are now. This has the following implications:
 *
 * <p>Before migration:
 * <ul><li> the event subscription is attached to the miBody scope execution</ul>
 *
 * <p>After migration:
 * <ul><li> a new subscription is created for every instance
 * <li> the new subscription is attached to a dedicated scope execution as a child of the miBody scope
 *   execution</ul>
 *
 * <p>Thus, this method removes the subscription on the miBody scope
 */
public static void removeLegacySubscriptionOnParent(ExecutionEntity execution, EventSubscriptionEntity eventSubscription) {
    ActivityImpl activity = execution.getActivity();
    if (activity == null) {
        return;
    }
    ActivityBehavior behavior = activity.getActivityBehavior();
    ActivityBehavior parentBehavior = (ActivityBehavior) (activity.getFlowScope() != null ? activity.getFlowScope().getActivityBehavior() : null);
    if (behavior instanceof ReceiveTaskActivityBehavior && parentBehavior instanceof MultiInstanceActivityBehavior) {
        List<EventSubscriptionEntity> parentSubscriptions = execution.getParent().getEventSubscriptions();
        for (EventSubscriptionEntity subscription : parentSubscriptions) {
            // distinguish a boundary event on the mi body with the same message name from the receive task subscription
            if (areEqualEventSubscriptions(subscription, eventSubscription)) {
                subscription.delete();
            }
        }
    }
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) ReceiveTaskActivityBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.ReceiveTaskActivityBehavior) CancelBoundaryEventActivityBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.CancelBoundaryEventActivityBehavior) SubProcessActivityBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.SubProcessActivityBehavior) MultiInstanceActivityBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior) ReceiveTaskActivityBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.ReceiveTaskActivityBehavior) CompensationEventActivityBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.CompensationEventActivityBehavior) EventSubProcessActivityBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.EventSubProcessActivityBehavior) CompositeActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.CompositeActivityBehavior) SequentialMultiInstanceActivityBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.SequentialMultiInstanceActivityBehavior) ActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior) CancelEndEventActivityBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.CancelEndEventActivityBehavior) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity) MultiInstanceActivityBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior) SequentialMultiInstanceActivityBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.SequentialMultiInstanceActivityBehavior)

Aggregations

ActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)14 CompositeActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.CompositeActivityBehavior)4 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)4 CancelBoundaryEventActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.CancelBoundaryEventActivityBehavior)3 CancelEndEventActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.CancelEndEventActivityBehavior)3 CompensationEventActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.CompensationEventActivityBehavior)3 EventSubProcessActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.EventSubProcessActivityBehavior)3 MultiInstanceActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior)3 ReceiveTaskActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.ReceiveTaskActivityBehavior)3 SequentialMultiInstanceActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.SequentialMultiInstanceActivityBehavior)3 SubProcessActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.SubProcessActivityBehavior)3 PvmActivity (org.camunda.bpm.engine.impl.pvm.PvmActivity)3 SignallableActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.SignallableActivityBehavior)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)2 Element (org.camunda.bpm.engine.impl.util.xml.Element)2 Callable (java.util.concurrent.Callable)1 JavaDelegate (org.camunda.bpm.engine.delegate.JavaDelegate)1 ConditionalEventBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.ConditionalEventBehavior)1 FlowNodeActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.FlowNodeActivityBehavior)1