use of org.activiti.engine.impl.pvm.PvmActivity in project Activiti by Activiti.
the class InclusiveGatewayActivityBehavior method execute.
public void execute(ActivityExecution execution) throws Exception {
execution.inactivate();
lockConcurrentRoot(execution);
PvmActivity activity = execution.getActivity();
if (!activeConcurrentExecutionsExist(execution)) {
if (log.isDebugEnabled()) {
log.debug("inclusive gateway '{}' activates", activity.getId());
}
List<ActivityExecution> joinedExecutions = execution.findInactiveConcurrentExecutions(activity);
String defaultSequenceFlow = (String) execution.getActivity().getProperty("default");
List<PvmTransition> transitionsToTake = new ArrayList<PvmTransition>();
for (PvmTransition outgoingTransition : execution.getActivity().getOutgoingTransitions()) {
Expression skipExpression = outgoingTransition.getSkipExpression();
if (!SkipExpressionUtil.isSkipExpressionEnabled(execution, skipExpression)) {
if (defaultSequenceFlow == null || !outgoingTransition.getId().equals(defaultSequenceFlow)) {
Condition condition = (Condition) outgoingTransition.getProperty(BpmnParse.PROPERTYNAME_CONDITION);
if (condition == null || condition.evaluate(outgoingTransition.getId(), execution)) {
transitionsToTake.add(outgoingTransition);
}
}
} else if (SkipExpressionUtil.shouldSkipFlowElement(execution, skipExpression)) {
transitionsToTake.add(outgoingTransition);
}
}
if (!transitionsToTake.isEmpty()) {
execution.takeAll(transitionsToTake, joinedExecutions);
} else {
if (defaultSequenceFlow != null) {
PvmTransition defaultTransition = execution.getActivity().findOutgoingTransition(defaultSequenceFlow);
if (defaultTransition != null) {
transitionsToTake.add(defaultTransition);
execution.takeAll(transitionsToTake, joinedExecutions);
} else {
throw new ActivitiException("Default sequence flow '" + defaultSequenceFlow + "' could not be not found");
}
} else {
// No sequence flow could be found, not even a default one
throw new ActivitiException("No outgoing sequence flow of the inclusive gateway '" + execution.getActivity().getId() + "' could be selected for continuing the process");
}
}
} else {
if (log.isDebugEnabled()) {
log.debug("Inclusive gateway '{}' does not activate", activity.getId());
}
}
}
use of org.activiti.engine.impl.pvm.PvmActivity in project Activiti by Activiti.
the class InclusiveGatewayActivityBehavior method isReachable.
protected boolean isReachable(PvmActivity srcActivity, PvmActivity targetActivity, Set<PvmActivity> visitedActivities) {
// if source has no outputs, it is the end of the process, and its parent process should be checked.
if (srcActivity.getOutgoingTransitions().isEmpty()) {
visitedActivities.add(srcActivity);
if (!(srcActivity.getParent() instanceof PvmActivity)) {
return false;
}
srcActivity = (PvmActivity) srcActivity.getParent();
}
if (srcActivity.equals(targetActivity)) {
return true;
}
// To avoid infinite looping, we must capture every node we visit
// and check before going further in the graph if we have already visitied
// the node.
visitedActivities.add(srcActivity);
List<PvmTransition> transitionList = srcActivity.getOutgoingTransitions();
if (transitionList != null && !transitionList.isEmpty()) {
for (PvmTransition pvmTransition : transitionList) {
PvmActivity destinationActivity = pvmTransition.getDestination();
if (destinationActivity != null && !visitedActivities.contains(destinationActivity)) {
boolean reachable = isReachable(destinationActivity, targetActivity, visitedActivities);
// result
if (reachable) {
return true;
}
}
}
}
return false;
}
use of org.activiti.engine.impl.pvm.PvmActivity in project Activiti by Activiti.
the class EventScopeCreatingSubprocess 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);
}
Aggregations