use of org.activiti.engine.impl.pvm.process.ActivityImpl 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);
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl 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);
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class AbstractBpmnActivityBehavior method createCompensateEventSubscription.
protected void createCompensateEventSubscription(ActivityExecution execution) {
String compensationHandlerId = (String) execution.getActivity().getProperty(BpmnParse.PROPERTYNAME_COMPENSATION_HANDLER_ID);
ExecutionEntity executionEntity = (ExecutionEntity) execution;
ActivityImpl compensationHandlder = executionEntity.getProcessDefinition().findActivity(compensationHandlerId);
PvmScope scopeActivitiy = compensationHandlder.getParent();
ExecutionEntity scopeExecution = ScopeUtil.findScopeExecutionForScope(executionEntity, scopeActivitiy);
CompensateEventSubscriptionEntity compensateEventSubscriptionEntity = CompensateEventSubscriptionEntity.createAndInsert(scopeExecution);
compensateEventSubscriptionEntity.setActivity(compensationHandlder);
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class BoundaryEventActivityBehavior method execute.
@SuppressWarnings("unchecked")
public void execute(ActivityExecution execution) throws Exception {
ExecutionEntity executionEntity = (ExecutionEntity) execution;
ActivityImpl boundaryActivity = executionEntity.getProcessDefinition().findActivity(activityId);
ActivityImpl interruptedActivity = executionEntity.getActivity();
List<PvmTransition> outgoingTransitions = boundaryActivity.getOutgoingTransitions();
List<ExecutionEntity> interruptedExecutions = null;
if (interrupting) {
// Call activity
if (executionEntity.getSubProcessInstance() != null) {
executionEntity.getSubProcessInstance().deleteCascade(executionEntity.getDeleteReason());
} else {
Context.getCommandContext().getHistoryManager().recordActivityEnd(executionEntity);
}
executionEntity.setActivity(boundaryActivity);
interruptedExecutions = new ArrayList<ExecutionEntity>(executionEntity.getExecutions());
for (ExecutionEntity interruptedExecution : interruptedExecutions) {
interruptedExecution.deleteCascade("interrupting boundary event '" + execution.getActivity().getId() + "' fired");
}
execution.takeAll(outgoingTransitions, (List) interruptedExecutions);
} else {
// non interrupting event, introduced with BPMN 2.0, we need to create a new execution in this case
// create a new execution and move it out from the timer activity
ExecutionEntity concurrentRoot = executionEntity.getParent().isConcurrent() ? executionEntity.getParent() : executionEntity;
ExecutionEntity outgoingExecution = concurrentRoot.createExecution();
outgoingExecution.setActive(true);
outgoingExecution.setScope(false);
outgoingExecution.setConcurrent(true);
outgoingExecution.takeAll(outgoingTransitions, Collections.EMPTY_LIST);
outgoingExecution.remove();
// now we have to move the execution back to the real activity
// since the execution stays there (non interrupting) and it was
// set to the boundary event before
executionEntity.setActivity(interruptedActivity);
}
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl 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);
}
Aggregations