use of org.activiti.engine.impl.pvm.runtime.InterpretableExecution in project Activiti by Activiti.
the class ExecutionEntity method removeEventScopes.
private void removeEventScopes() {
List<InterpretableExecution> childExecutions = new ArrayList<InterpretableExecution>(getExecutions());
for (InterpretableExecution childExecution : childExecutions) {
if (childExecution.isEventScope()) {
log.debug("removing eventScope {}", childExecution);
childExecution.destroy();
childExecution.remove();
}
}
}
use of org.activiti.engine.impl.pvm.runtime.InterpretableExecution in project Activiti by Activiti.
the class BpmnActivityBehavior method performOutgoingBehavior.
/**
* Actual implementation of leaving an activity.
*
* @param execution
* The current execution context
* @param checkConditions
* Whether or not to check conditions before determining whether or
* not to take a transition.
* @param throwExceptionIfExecutionStuck
* If true, an {@link ActivitiException} will be thrown in case no
* transition could be found to leave the activity.
*/
protected void performOutgoingBehavior(ActivityExecution execution, boolean checkConditions, boolean throwExceptionIfExecutionStuck, List<ActivityExecution> reusableExecutions) {
if (log.isDebugEnabled()) {
log.debug("Leaving activity '{}'", execution.getActivity().getId());
}
String defaultSequenceFlow = (String) execution.getActivity().getProperty("default");
List<PvmTransition> transitionsToTake = new ArrayList<PvmTransition>();
List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions();
for (PvmTransition outgoingTransition : outgoingTransitions) {
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 || !checkConditions || condition.evaluate(outgoingTransition.getId(), execution)) {
transitionsToTake.add(outgoingTransition);
}
}
} else if (SkipExpressionUtil.shouldSkipFlowElement(execution, skipExpression)) {
transitionsToTake.add(outgoingTransition);
}
}
if (transitionsToTake.size() == 1) {
execution.take(transitionsToTake.get(0));
} else if (transitionsToTake.size() >= 1) {
execution.inactivate();
if (reusableExecutions == null || reusableExecutions.isEmpty()) {
execution.takeAll(transitionsToTake, Arrays.asList(execution));
} else {
execution.takeAll(transitionsToTake, reusableExecutions);
}
} else {
if (defaultSequenceFlow != null) {
PvmTransition defaultTransition = execution.getActivity().findOutgoingTransition(defaultSequenceFlow);
if (defaultTransition != null) {
execution.take(defaultTransition);
} else {
throw new ActivitiException("Default sequence flow '" + defaultSequenceFlow + "' could not be not found");
}
} else {
Object isForCompensation = execution.getActivity().getProperty(BpmnParse.PROPERTYNAME_IS_FOR_COMPENSATION);
if (isForCompensation != null && (Boolean) isForCompensation) {
if (execution instanceof ExecutionEntity) {
Context.getCommandContext().getHistoryManager().recordActivityEnd((ExecutionEntity) execution);
}
InterpretableExecution parentExecution = (InterpretableExecution) execution.getParent();
((InterpretableExecution) execution).remove();
parentExecution.signal("compensationDone", null);
} else {
if (log.isDebugEnabled()) {
log.debug("No outgoing sequence flow found for {}. Ending execution.", execution.getActivity().getId());
}
execution.end();
if (throwExceptionIfExecutionStuck) {
throw new ActivitiException("No outgoing sequence flow of the inclusive gateway '" + execution.getActivity().getId() + "' could be selected for continuing the process");
}
}
}
}
}
use of org.activiti.engine.impl.pvm.runtime.InterpretableExecution in project Activiti by Activiti.
the class ErrorPropagation method executeEventHandler.
private static void executeEventHandler(ActivityImpl borderEventActivity, ActivityExecution leavingExecution, String errorCode) {
if (Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createErrorEvent(ActivitiEventType.ACTIVITY_ERROR_RECEIVED, borderEventActivity.getId(), errorCode, leavingExecution.getId(), leavingExecution.getProcessInstanceId(), leavingExecution.getProcessDefinitionId()));
}
// The current activity of the execution will be changed in the next lines.
// So we must make sure the activity is ended correctly here
// The other executions (for example when doing something parallel in a subprocess, will
// be destroyed by the destroy scope operation (but this execution will be used to do it and
// will have list the original activity by then)
Context.getCommandContext().getHistoryManager().recordActivityEnd((ExecutionEntity) leavingExecution);
if (borderEventActivity.getActivityBehavior() instanceof EventSubProcessStartEventActivityBehavior) {
InterpretableExecution execution = (InterpretableExecution) leavingExecution;
execution.setActivity(borderEventActivity.getParentActivity());
// make sure the listeners are invoked!
execution.performOperation(AtomicOperation.ACTIVITY_START);
} else {
leavingExecution.executeActivity(borderEventActivity);
}
}
use of org.activiti.engine.impl.pvm.runtime.InterpretableExecution in project Activiti by Activiti.
the class EventScopeCreatingSubprocess method lastExecutionEnded.
/*
* Incoming execution is transformed into an event scope,
* new, non-concurrent execution leaves activity
*/
@SuppressWarnings("unchecked")
public void lastExecutionEnded(ActivityExecution execution) {
ActivityExecution outgoingExecution = execution.getParent().createExecution();
outgoingExecution.setConcurrent(false);
((InterpretableExecution) outgoingExecution).setActivity((ActivityImpl) execution.getActivity());
// eventscope execution
execution.setConcurrent(false);
execution.setActive(false);
((InterpretableExecution) execution).setEventScope(true);
List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions();
if (outgoingTransitions.isEmpty()) {
outgoingExecution.end();
} else {
outgoingExecution.takeAll(outgoingTransitions, Collections.EMPTY_LIST);
}
}
Aggregations