Search in sources :

Example 1 with PvmActivity

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

Example 2 with PvmActivity

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

Example 3 with PvmActivity

use of org.activiti.engine.impl.pvm.PvmActivity 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 4 with PvmActivity

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

the class ParallelGatewayActivityBehavior method execute.

public void execute(ActivityExecution execution) throws Exception {
    // Join
    PvmActivity activity = execution.getActivity();
    List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions();
    execution.inactivate();
    lockConcurrentRoot(execution);
    List<ActivityExecution> joinedExecutions = execution.findInactiveConcurrentExecutions(activity);
    int nbrOfExecutionsToJoin = execution.getActivity().getIncomingTransitions().size();
    int nbrOfExecutionsJoined = joinedExecutions.size();
    Context.getCommandContext().getHistoryManager().recordActivityEnd((ExecutionEntity) execution);
    if (nbrOfExecutionsJoined == nbrOfExecutionsToJoin) {
        // Fork
        if (log.isDebugEnabled()) {
            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);
    }
}
Also used : ActivityExecution(org.activiti.engine.impl.pvm.delegate.ActivityExecution) PvmActivity(org.activiti.engine.impl.pvm.PvmActivity) PvmTransition(org.activiti.engine.impl.pvm.PvmTransition)

Example 5 with PvmActivity

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

the class SubProcessActivityBehavior method execute.

public void execute(ActivityExecution execution) throws Exception {
    PvmActivity activity = execution.getActivity();
    ActivityImpl initialActivity = (ActivityImpl) activity.getProperty(BpmnParse.PROPERTYNAME_INITIAL);
    if (initialActivity == null) {
        throw new ActivitiException("No initial activity found for subprocess " + execution.getActivity().getId());
    }
    // initialize the template-defined data objects as variables
    initializeDataObjects(execution, activity);
    if (initialActivity.getActivityBehavior() != null && initialActivity.getActivityBehavior() instanceof NoneStartEventActivityBehavior) {
        // embedded subprocess: only none start allowed
        ((ExecutionEntity) execution).setActivity(initialActivity);
        Context.getCommandContext().getHistoryManager().recordActivityStart((ExecutionEntity) execution);
    }
    execution.executeActivity(initialActivity);
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) 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