use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution in project camunda-bpm-platform by camunda.
the class EventScopeCreatingSubprocess method complete.
/*
* Incoming execution is transformed into an event scope,
* new, non-concurrent execution leaves activity
*/
public void complete(ActivityExecution execution) {
ActivityExecution outgoingExecution = execution.getParent().createExecution();
outgoingExecution.setConcurrent(false);
outgoingExecution.setActivity(execution.getActivity());
// eventscope execution
execution.setConcurrent(false);
execution.setActive(false);
((PvmExecutionImpl) execution).setEventScope(true);
List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions();
if (outgoingTransitions.isEmpty()) {
outgoingExecution.end(true);
} else {
outgoingExecution.leaveActivityViaTransitions(outgoingTransitions, Collections.EMPTY_LIST);
}
}
use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution in project camunda-bpm-platform by camunda.
the class ParallelGateway method execute.
public void execute(ActivityExecution execution) {
PvmActivity activity = execution.getActivity();
List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions();
execution.inactivate();
List<ActivityExecution> joinedExecutions = execution.findInactiveConcurrentExecutions(activity);
int nbrOfExecutionsToJoin = execution.getActivity().getIncomingTransitions().size();
int nbrOfExecutionsJoined = joinedExecutions.size();
if (nbrOfExecutionsJoined == nbrOfExecutionsToJoin) {
LOG.debug("parallel gateway '" + activity.getId() + "' activates: " + nbrOfExecutionsJoined + " of " + nbrOfExecutionsToJoin + " joined");
execution.leaveActivityViaTransitions(outgoingTransitions, joinedExecutions);
} else {
LOG.debug("parallel gateway '" + activity.getId() + "' does not activate: " + nbrOfExecutionsJoined + " of " + nbrOfExecutionsToJoin + " joined");
}
}
use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution in project camunda-bpm-platform by camunda.
the class PvmAtomicOperationActivityInitStackNotifyListenerStart method eventNotificationsCompleted.
protected void eventNotificationsCompleted(PvmExecutionImpl execution) {
super.eventNotificationsCompleted(execution);
execution.activityInstanceStarted();
ExecutionStartContext startContext = execution.getExecutionStartContext();
InstantiationStack instantiationStack = startContext.getInstantiationStack();
PvmExecutionImpl propagatingExecution = execution;
ActivityImpl activity = execution.getActivity();
if (activity.getActivityBehavior() instanceof ModificationObserverBehavior) {
ModificationObserverBehavior behavior = (ModificationObserverBehavior) activity.getActivityBehavior();
List<ActivityExecution> concurrentExecutions = behavior.initializeScope(propagatingExecution, 1);
propagatingExecution = (PvmExecutionImpl) concurrentExecutions.get(0);
}
// if the stack has been instantiated
if (instantiationStack.getActivities().isEmpty() && instantiationStack.getTargetActivity() != null) {
// as if we are entering the target activity instance id via a transition
propagatingExecution.setActivityInstanceId(null);
// execute the target activity with this execution
startContext.applyVariables(propagatingExecution);
propagatingExecution.setActivity(instantiationStack.getTargetActivity());
propagatingExecution.performOperation(ACTIVITY_START_CREATE_SCOPE);
} else if (instantiationStack.getActivities().isEmpty() && instantiationStack.getTargetTransition() != null) {
// as if we are entering the target activity instance id via a transition
propagatingExecution.setActivityInstanceId(null);
// execute the target transition with this execution
PvmTransition transition = instantiationStack.getTargetTransition();
startContext.applyVariables(propagatingExecution);
propagatingExecution.setActivity(transition.getSource());
propagatingExecution.setTransition((TransitionImpl) transition);
propagatingExecution.performOperation(TRANSITION_START_NOTIFY_LISTENER_TAKE);
} else {
// else instantiate the activity stack further
propagatingExecution.setActivity(null);
propagatingExecution.performOperation(ACTIVITY_INIT_STACK);
}
}
use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution in project camunda-bpm-platform by camunda.
the class AbstractBpmnActivityBehavior method createCompensateEventSubscription.
protected void createCompensateEventSubscription(ActivityExecution execution, ActivityImpl compensationHandler) {
// the compensate event subscription is created at subprocess or miBody of the the current activity
PvmActivity currentActivity = execution.getActivity();
ActivityExecution scopeExecution = execution.findExecutionForFlowScope(currentActivity.getFlowScope());
EventSubscriptionEntity.createAndInsert((ExecutionEntity) scopeExecution, EventType.COMPENSATE, compensationHandler);
}
use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution in project camunda-bpm-platform by camunda.
the class InclusiveGatewayActivityBehavior method activatesGateway.
protected boolean activatesGateway(ActivityExecution execution, PvmActivity gatewayActivity) {
int numExecutionsGuaranteedToActivate = gatewayActivity.getIncomingTransitions().size();
ActivityExecution scopeExecution = execution.isScope() ? execution : execution.getParent();
List<ActivityExecution> executionsAtGateway = execution.findInactiveConcurrentExecutions(gatewayActivity);
if (executionsAtGateway.size() >= numExecutionsGuaranteedToActivate) {
return true;
} else {
Collection<ActivityExecution> executionsNotAtGateway = getLeafExecutions(scopeExecution);
executionsNotAtGateway.removeAll(executionsAtGateway);
for (ActivityExecution executionNotAtGateway : executionsNotAtGateway) {
if (canReachActivity(executionNotAtGateway, gatewayActivity)) {
return false;
}
}
// if no more token may arrive, then activate
return true;
}
}
Aggregations