use of org.activiti.engine.impl.pvm.delegate.ActivityExecution in project Activiti by Activiti.
the class ErrorPropagation method executeCatch.
private static void executeCatch(String errorHandlerId, ActivityExecution execution, String errorCode) {
ProcessDefinitionImpl processDefinition = ((ExecutionEntity) execution).getProcessDefinition();
ActivityImpl errorHandler = processDefinition.findActivity(errorHandlerId);
if (errorHandler == null) {
throw new ActivitiException(errorHandlerId + " not found in process definition");
}
boolean matchingParentFound = false;
ActivityExecution leavingExecution = execution;
ActivityImpl currentActivity = (ActivityImpl) execution.getActivity();
ScopeImpl catchingScope = errorHandler.getParent();
if (catchingScope instanceof ActivityImpl) {
ActivityImpl catchingScopeActivity = (ActivityImpl) catchingScope;
if (!catchingScopeActivity.isScope()) {
// event subprocesses
catchingScope = catchingScopeActivity.getParent();
}
}
if (catchingScope instanceof PvmProcessDefinition) {
executeEventHandler(errorHandler, ((ExecutionEntity) execution).getProcessInstance(), errorCode);
} else {
if (currentActivity.getId().equals(catchingScope.getId())) {
matchingParentFound = true;
} else {
currentActivity = (ActivityImpl) currentActivity.getParent();
// and matches the activity the boundary event is defined on
while (!matchingParentFound && leavingExecution != null && currentActivity != null) {
if (!leavingExecution.isConcurrent() && currentActivity.getId().equals(catchingScope.getId())) {
matchingParentFound = true;
} else if (leavingExecution.isConcurrent()) {
leavingExecution = leavingExecution.getParent();
} else {
currentActivity = currentActivity.getParentActivity();
leavingExecution = leavingExecution.getParent();
}
}
// Follow parents up until matching scope can't be found anymore (needed to support for multi-instance)
while (leavingExecution != null && leavingExecution.getParent() != null && leavingExecution.getParent().getActivity() != null && leavingExecution.getParent().getActivity().getId().equals(catchingScope.getId())) {
leavingExecution = leavingExecution.getParent();
}
}
if (matchingParentFound && leavingExecution != null) {
executeEventHandler(errorHandler, leavingExecution, errorCode);
} else {
throw new ActivitiException("No matching parent execution for activity " + errorHandlerId + " found");
}
}
}
use of org.activiti.engine.impl.pvm.delegate.ActivityExecution in project Activiti by Activiti.
the class ExecutionEntity method findInactiveConcurrentExecutions.
public List<ActivityExecution> findInactiveConcurrentExecutions(PvmActivity activity) {
List<ActivityExecution> inactiveConcurrentExecutionsInActivity = new ArrayList<ActivityExecution>();
List<ActivityExecution> otherConcurrentExecutions = new ArrayList<ActivityExecution>();
if (isConcurrent()) {
List<? extends ActivityExecution> concurrentExecutions = getParent().getAllChildExecutions();
for (ActivityExecution concurrentExecution : concurrentExecutions) {
if (concurrentExecution.getActivity() != null && concurrentExecution.getActivity().getId().equals(activity.getId())) {
if (!concurrentExecution.isActive()) {
inactiveConcurrentExecutionsInActivity.add(concurrentExecution);
}
} else {
otherConcurrentExecutions.add(concurrentExecution);
}
}
} else {
if (!isActive()) {
inactiveConcurrentExecutionsInActivity.add(this);
} else {
otherConcurrentExecutions.add(this);
}
}
if (log.isDebugEnabled()) {
log.debug("inactive concurrent executions in '{}': {}", activity, inactiveConcurrentExecutionsInActivity);
log.debug("other concurrent executions: {}", otherConcurrentExecutions);
}
return inactiveConcurrentExecutionsInActivity;
}
use of org.activiti.engine.impl.pvm.delegate.ActivityExecution in project Activiti by Activiti.
the class EmbeddedSubProcess method timerFires.
// used by timers
@SuppressWarnings("unchecked")
public void timerFires(ActivityExecution execution, String signalName, Object signalData) throws Exception {
PvmActivity timerActivity = execution.getActivity();
boolean isInterrupting = (Boolean) timerActivity.getProperty("isInterrupting");
List<ActivityExecution> recyclableExecutions;
if (isInterrupting) {
recyclableExecutions = removeAllExecutions(execution);
} else {
recyclableExecutions = Collections.EMPTY_LIST;
}
execution.takeAll(timerActivity.getOutgoingTransitions(), recyclableExecutions);
}
use of org.activiti.engine.impl.pvm.delegate.ActivityExecution in project Activiti by Activiti.
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 '{}' activates: {} of {} joined", activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin);
execution.takeAll(outgoingTransitions, joinedExecutions);
} else if (log.isDebugEnabled()) {
log.debug("parallel gateway '{}' does not activate: {} of {} joined", activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin);
}
}
use of org.activiti.engine.impl.pvm.delegate.ActivityExecution in project Activiti by Activiti.
the class TerminateEndEventActivityBehavior method execute.
public void execute(ActivityExecution execution) throws Exception {
ActivityImpl terminateEndEventActivity = (ActivityImpl) execution.getActivity();
if (terminateAll) {
ActivityExecution processInstanceExecution = findRootProcessInstanceExecution((ExecutionEntity) execution);
terminateProcessInstanceExecution(execution, terminateEndEventActivity, processInstanceExecution);
} else {
ActivityExecution scopeExecution = ScopeUtil.findScopeExecution(execution);
if (scopeExecution != null) {
terminateExecution(execution, terminateEndEventActivity, scopeExecution);
}
}
}
Aggregations