Search in sources :

Example 6 with ActivityExecution

use of org.activiti.engine.impl.pvm.delegate.ActivityExecution in project Activiti by Activiti.

the class EventSubProcessStartEventActivityBehavior method execute.

@Override
public void execute(ActivityExecution execution) throws Exception {
    InterpretableExecution interpretableExecution = (InterpretableExecution) execution;
    ActivityImpl activity = interpretableExecution.getProcessDefinition().findActivity(activityId);
    ActivityExecution outgoingExecution = execution;
    if (isInterrupting) {
        execution.destroyScope("Event subprocess triggered using activity " + activityId);
    } else {
        outgoingExecution = execution.createExecution();
        outgoingExecution.setActive(true);
        outgoingExecution.setScope(false);
        outgoingExecution.setConcurrent(true);
    }
    // set the outgoing execution to this activity
    ((InterpretableExecution) outgoingExecution).setActivity(activity);
    // continue execution
    outgoingExecution.takeAll(activity.getOutgoingTransitions(), Collections.EMPTY_LIST);
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ActivityExecution(org.activiti.engine.impl.pvm.delegate.ActivityExecution) InterpretableExecution(org.activiti.engine.impl.pvm.runtime.InterpretableExecution)

Example 7 with ActivityExecution

use of org.activiti.engine.impl.pvm.delegate.ActivityExecution in project Activiti by Activiti.

the class GatewayActivityBehavior method lockConcurrentRoot.

protected void lockConcurrentRoot(ActivityExecution execution) {
    ActivityExecution concurrentRoot = null;
    if (execution.isConcurrent()) {
        concurrentRoot = execution.getParent();
    } else {
        concurrentRoot = execution;
    }
    ((ExecutionEntity) concurrentRoot).forceUpdate();
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivityExecution(org.activiti.engine.impl.pvm.delegate.ActivityExecution)

Example 8 with ActivityExecution

use of org.activiti.engine.impl.pvm.delegate.ActivityExecution in project Activiti by Activiti.

the class InclusiveGatewayActivityBehavior method getLeaveExecutions.

List<? extends ActivityExecution> getLeaveExecutions(ActivityExecution parent) {
    List<ActivityExecution> executionlist = new ArrayList<ActivityExecution>();
    List<? extends ActivityExecution> subExecutions = parent.getExecutions();
    if (subExecutions.isEmpty()) {
        executionlist.add(parent);
    } else {
        for (ActivityExecution concurrentExecution : subExecutions) {
            executionlist.addAll(getLeaveExecutions(concurrentExecution));
        }
    }
    return executionlist;
}
Also used : ArrayList(java.util.ArrayList) ActivityExecution(org.activiti.engine.impl.pvm.delegate.ActivityExecution)

Example 9 with ActivityExecution

use of org.activiti.engine.impl.pvm.delegate.ActivityExecution in project Activiti by Activiti.

the class InclusiveGatewayActivityBehavior method activeConcurrentExecutionsExist.

public boolean activeConcurrentExecutionsExist(ActivityExecution execution) {
    PvmActivity activity = execution.getActivity();
    if (execution.isConcurrent()) {
        for (ActivityExecution concurrentExecution : getLeaveExecutions(execution.getParent())) {
            if (concurrentExecution.isActive() && concurrentExecution.getId().equals(execution.getId()) == false) {
                // TODO: when is transitionBeingTaken cleared? Should we clear it?
                boolean reachable = false;
                PvmTransition pvmTransition = ((ExecutionEntity) concurrentExecution).getTransitionBeingTaken();
                if (pvmTransition != null) {
                    reachable = isReachable(pvmTransition.getDestination(), activity, new HashSet<PvmActivity>());
                } else {
                    reachable = isReachable(concurrentExecution.getActivity(), activity, new HashSet<PvmActivity>());
                }
                if (reachable) {
                    if (log.isDebugEnabled()) {
                        log.debug("an active concurrent execution found: '{}'", concurrentExecution.getActivity());
                    }
                    return true;
                }
            }
        }
    } else if (execution.isActive()) {
        // is this ever true?
        if (log.isDebugEnabled()) {
            log.debug("an active concurrent execution found: '{}'", execution.getActivity());
        }
        return true;
    }
    return false;
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivityExecution(org.activiti.engine.impl.pvm.delegate.ActivityExecution) PvmActivity(org.activiti.engine.impl.pvm.PvmActivity) PvmTransition(org.activiti.engine.impl.pvm.PvmTransition) HashSet(java.util.HashSet)

Example 10 with ActivityExecution

use of org.activiti.engine.impl.pvm.delegate.ActivityExecution in project Activiti by Activiti.

the class MultiInstanceActivityBehavior method getLoopVariable.

protected Integer getLoopVariable(ActivityExecution execution, String variableName) {
    Object value = execution.getVariableLocal(variableName);
    ActivityExecution parent = execution.getParent();
    while (value == null && parent != null) {
        value = parent.getVariableLocal(variableName);
        parent = parent.getParent();
    }
    return (Integer) (value != null ? value : 0);
}
Also used : ActivityExecution(org.activiti.engine.impl.pvm.delegate.ActivityExecution)

Aggregations

ActivityExecution (org.activiti.engine.impl.pvm.delegate.ActivityExecution)23 ArrayList (java.util.ArrayList)8 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)8 PvmTransition (org.activiti.engine.impl.pvm.PvmTransition)7 PvmActivity (org.activiti.engine.impl.pvm.PvmActivity)6 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)6 InterpretableExecution (org.activiti.engine.impl.pvm.runtime.InterpretableExecution)4 List (java.util.List)3 ActivitiException (org.activiti.engine.ActivitiException)3 PvmException (org.activiti.engine.impl.pvm.PvmException)3 HashSet (java.util.HashSet)1 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)1 Expression (org.activiti.engine.delegate.Expression)1 Condition (org.activiti.engine.impl.Condition)1 PvmProcessDefinition (org.activiti.engine.impl.pvm.PvmProcessDefinition)1 ActivityBehavior (org.activiti.engine.impl.pvm.delegate.ActivityBehavior)1 CompositeActivityBehavior (org.activiti.engine.impl.pvm.delegate.CompositeActivityBehavior)1 ProcessDefinitionImpl (org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)1 ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)1 OutgoingExecution (org.activiti.engine.impl.pvm.runtime.OutgoingExecution)1