Search in sources :

Example 1 with InterpretableExecution

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

the class ExecutionEntity method destroyScope.

public void destroyScope(String reason) {
    if (log.isDebugEnabled()) {
        log.debug("performing destroy scope behavior for execution {}", this);
    }
    // remove all child executions and sub process instances:
    HistoryManager historyManager = Context.getCommandContext().getHistoryManager();
    List<InterpretableExecution> executions = new ArrayList<InterpretableExecution>(getExecutions());
    for (InterpretableExecution childExecution : executions) {
        if (childExecution.getSubProcessInstance() != null) {
            childExecution.getSubProcessInstance().deleteCascade(reason);
        }
        historyManager.recordActivityEnd((ExecutionEntity) childExecution);
        childExecution.deleteCascade(reason);
    }
    if (activityId != null) {
        historyManager.recordActivityEnd(this);
    }
    removeTasks(reason);
    removeJobs();
}
Also used : HistoryManager(org.activiti.engine.impl.history.HistoryManager) ArrayList(java.util.ArrayList) InterpretableExecution(org.activiti.engine.impl.pvm.runtime.InterpretableExecution)

Example 2 with InterpretableExecution

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

the class ProcessDefinitionImpl method createProcessInstanceForInitial.

/** creates a process instance using the provided activity as initial */
public PvmProcessInstance createProcessInstanceForInitial(ActivityImpl initial) {
    if (initial == null) {
        throw new ActivitiException("Cannot start process instance, initial activity where the process instance should start is null.");
    }
    InterpretableExecution processInstance = newProcessInstance(initial);
    processInstance.setProcessDefinition(this);
    processInstance.setProcessInstance(processInstance);
    processInstance.initialize();
    InterpretableExecution scopeInstance = processInstance;
    List<ActivityImpl> initialActivityStack = getInitialActivityStack(initial);
    for (ActivityImpl initialActivity : initialActivityStack) {
        if (initialActivity.isScope()) {
            scopeInstance = (InterpretableExecution) scopeInstance.createExecution();
            scopeInstance.setActivity(initialActivity);
            if (initialActivity.isScope()) {
                scopeInstance.initialize();
            }
        }
    }
    scopeInstance.setActivity(initial);
    return processInstance;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) InterpretableExecution(org.activiti.engine.impl.pvm.runtime.InterpretableExecution)

Example 3 with InterpretableExecution

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

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

the class AbstractBpmnActivityBehavior method signalCompensationDone.

protected void signalCompensationDone(ActivityExecution execution, Object signalData) {
    // join compensating executions    
    if (execution.getExecutions().isEmpty()) {
        if (execution.getParent() != null) {
            ActivityExecution parent = execution.getParent();
            ((InterpretableExecution) execution).remove();
            ((InterpretableExecution) parent).signal("compensationDone", signalData);
        }
    } else {
        ((ExecutionEntity) execution).forceUpdate();
    }
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivityExecution(org.activiti.engine.impl.pvm.delegate.ActivityExecution) InterpretableExecution(org.activiti.engine.impl.pvm.runtime.InterpretableExecution)

Example 5 with InterpretableExecution

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

the class CancelEndEventActivityBehavior method execute.

@Override
public void execute(ActivityExecution execution) throws Exception {
    // find cancel boundary event:
    ActivityImpl cancelBoundaryEvent = ScopeUtil.findInParentScopesByBehaviorType((ActivityImpl) execution.getActivity(), CancelBoundaryEventActivityBehavior.class);
    if (cancelBoundaryEvent == null) {
        throw new ActivitiException("Could not find cancel boundary event for cancel end event " + execution.getActivity());
    }
    ActivityExecution scopeExecution = ScopeUtil.findScopeExecutionForScope((ExecutionEntity) execution, cancelBoundaryEvent.getParentActivity());
    // end all executions and process instances in the scope of the transaction
    scopeExecution.destroyScope("cancel end event fired");
    // the scope execution executes the boundary event
    InterpretableExecution outgoingExecution = (InterpretableExecution) scopeExecution;
    outgoingExecution.setActivity(cancelBoundaryEvent);
    outgoingExecution.setActive(true);
    // execute the boundary
    cancelBoundaryEvent.getActivityBehavior().execute(outgoingExecution);
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ActivityExecution(org.activiti.engine.impl.pvm.delegate.ActivityExecution) InterpretableExecution(org.activiti.engine.impl.pvm.runtime.InterpretableExecution)

Aggregations

InterpretableExecution (org.activiti.engine.impl.pvm.runtime.InterpretableExecution)9 ActivityExecution (org.activiti.engine.impl.pvm.delegate.ActivityExecution)4 ArrayList (java.util.ArrayList)3 ActivitiException (org.activiti.engine.ActivitiException)3 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)2 PvmTransition (org.activiti.engine.impl.pvm.PvmTransition)2 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)2 Expression (org.activiti.engine.delegate.Expression)1 Condition (org.activiti.engine.impl.Condition)1 EventSubProcessStartEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.EventSubProcessStartEventActivityBehavior)1 HistoryManager (org.activiti.engine.impl.history.HistoryManager)1