Search in sources :

Example 31 with PvmExecutionImpl

use of org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl in project camunda-bpm-platform by camunda.

the class ProcessDefinitionImpl method createProcessInstanceForInitial.

/**
 * creates a process instance using the provided activity as initial
 */
public PvmProcessInstance createProcessInstanceForInitial(ActivityImpl initial) {
    ensureNotNull("Cannot start process instance, initial activity where the process instance should start is null", "initial", initial);
    PvmExecutionImpl processInstance = newProcessInstance();
    processInstance.setProcessDefinition(this);
    processInstance.setProcessInstance(processInstance);
    // always set the process instance to the initial activity, no matter how deeply it is nested;
    // this is required for firing history events (cf start activity) and persisting the initial activity
    // on async start
    processInstance.setActivity(initial);
    return processInstance;
}
Also used : PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)

Example 32 with PvmExecutionImpl

use of org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl in project camunda-bpm-platform by camunda.

the class FoxDeleteProcessInstanceCmd method execute.

public Void execute(CommandContext commandContext) {
    ensureNotNull("processInstanceId", processInstanceId);
    ExecutionEntity execution = commandContext.getExecutionManager().findExecutionById(processInstanceId);
    ensureNotNull("No process instance found for id '" + processInstanceId + "'", "execution", execution);
    commandContext.getTaskManager().deleteTasksByProcessInstanceId(processInstanceId, deleteReason, false, false);
    for (PvmExecutionImpl currentExecution : this.collectExecutionToDelete(execution)) {
        currentExecution.deleteCascade2(deleteReason);
    }
    return null;
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)

Example 33 with PvmExecutionImpl

use of org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl in project camunda-bpm-platform by camunda.

the class FoxDeleteProcessInstanceCmd method collectExecutionToDelete.

public List<PvmExecutionImpl> collectExecutionToDelete(PvmExecutionImpl execution) {
    List<PvmExecutionImpl> result = new ArrayList<PvmExecutionImpl>();
    for (PvmExecutionImpl currentExecution : execution.getExecutions()) {
        result.addAll(this.collectExecutionToDelete(currentExecution));
    }
    if (execution.getSubProcessInstance() != null) {
        result.addAll(this.collectExecutionToDelete(execution.getSubProcessInstance()));
    }
    result.add(execution);
    return result;
}
Also used : PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) ArrayList(java.util.ArrayList)

Example 34 with PvmExecutionImpl

use of org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl in project camunda-bpm-platform by camunda.

the class EventHandlerImpl method handleIntermediateEvent.

public void handleIntermediateEvent(EventSubscriptionEntity eventSubscription, Object payload, CommandContext commandContext) {
    PvmExecutionImpl execution = eventSubscription.getExecution();
    ActivityImpl activity = eventSubscription.getActivity();
    ensureNotNull("Error while sending signal for event subscription '" + eventSubscription.getId() + "': " + "no activity associated with event subscription", "activity", activity);
    if (payload instanceof Map) {
        execution.setVariables((Map<String, Object>) payload);
    }
    if (activity.equals(execution.getActivity())) {
        execution.signal("signal", null);
    } else {
        // and not the subprocess itself
        if (activity.getActivityBehavior() instanceof EventSubProcessStartEventActivityBehavior) {
            activity = (ActivityImpl) activity.getFlowScope();
        }
        execution.executeEventHandlerActivity(activity);
    }
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) EventSubProcessStartEventActivityBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.EventSubProcessStartEventActivityBehavior) Map(java.util.Map)

Example 35 with PvmExecutionImpl

use of org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl in project camunda-bpm-platform by camunda.

the class EventSubProcessStartConditionalEventActivityBehavior method leaveOnSatisfiedCondition.

@Override
public void leaveOnSatisfiedCondition(final EventSubscriptionEntity eventSubscription, final VariableEvent variableEvent) {
    PvmExecutionImpl execution = eventSubscription.getExecution();
    if (execution != null && !execution.isEnded() && execution.isScope() && conditionalEvent.tryEvaluate(variableEvent, execution)) {
        ActivityImpl activity = eventSubscription.getActivity();
        activity = (ActivityImpl) activity.getFlowScope();
        execution.executeEventHandlerActivity(activity);
    }
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)

Aggregations

PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)38 PvmActivity (org.camunda.bpm.engine.impl.pvm.PvmActivity)13 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)7 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)7 ArrayList (java.util.ArrayList)6 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 Map (java.util.Map)3 PvmTransition (org.camunda.bpm.engine.impl.pvm.PvmTransition)3 ActivityExecution (org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution)3 SubProcessActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.SubProcessActivityBehavior)3 HashMap (java.util.HashMap)2 TransferVariablesActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.TransferVariablesActivityBehavior)2 ActivityInstanceImpl (org.camunda.bpm.engine.impl.persistence.entity.ActivityInstanceImpl)2 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)2 ProcessDefinitionBuilder (org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder)2 PvmProcessDefinition (org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition)2 PvmProcessInstance (org.camunda.bpm.engine.impl.pvm.PvmProcessInstance)2 PvmScope (org.camunda.bpm.engine.impl.pvm.PvmScope)2 CompositeActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.CompositeActivityBehavior)2