Search in sources :

Example 6 with PvmActivity

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());
        }
    }
}
Also used : Condition(org.activiti.engine.impl.Condition) ActivitiException(org.activiti.engine.ActivitiException) Expression(org.activiti.engine.delegate.Expression) ArrayList(java.util.ArrayList) ActivityExecution(org.activiti.engine.impl.pvm.delegate.ActivityExecution) PvmActivity(org.activiti.engine.impl.pvm.PvmActivity) PvmTransition(org.activiti.engine.impl.pvm.PvmTransition)

Example 7 with PvmActivity

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;
}
Also used : PvmActivity(org.activiti.engine.impl.pvm.PvmActivity) PvmTransition(org.activiti.engine.impl.pvm.PvmTransition)

Example 8 with PvmActivity

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);
}
Also used : ActivityExecution(org.activiti.engine.impl.pvm.delegate.ActivityExecution) PvmActivity(org.activiti.engine.impl.pvm.PvmActivity)

Aggregations

PvmActivity (org.activiti.engine.impl.pvm.PvmActivity)8 ActivityExecution (org.activiti.engine.impl.pvm.delegate.ActivityExecution)6 PvmTransition (org.activiti.engine.impl.pvm.PvmTransition)5 ActivitiException (org.activiti.engine.ActivitiException)2 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Expression (org.activiti.engine.delegate.Expression)1 Condition (org.activiti.engine.impl.Condition)1 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)1