use of org.activiti.engine.impl.pvm.process.ScopeImpl in project Activiti by Activiti.
the class ErrorEventDefinitionParseHandler method createBoundaryErrorEventDefinition.
public void createBoundaryErrorEventDefinition(ErrorEventDefinition errorEventDefinition, boolean interrupting, ActivityImpl activity, ActivityImpl nestedErrorEventActivity) {
nestedErrorEventActivity.setProperty("type", "boundaryError");
ScopeImpl catchingScope = nestedErrorEventActivity.getParent();
((ActivityImpl) catchingScope).setScope(true);
org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition definition = new org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition(nestedErrorEventActivity.getId());
definition.setErrorCode(errorEventDefinition.getErrorCode());
addErrorEventDefinition(definition, catchingScope);
}
use of org.activiti.engine.impl.pvm.process.ScopeImpl in project Activiti by Activiti.
the class ExecutionEntity method initialize.
// scopes ///////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
public void initialize() {
log.debug("initializing {}", this);
ScopeImpl scope = getScopeObject();
ensureParentInitialized();
// initialize the lists of referenced objects (prevents db queries)
variableInstances = new HashMap<String, VariableInstanceEntity>();
eventSubscriptions = new ArrayList<EventSubscriptionEntity>();
// Cached entity-state initialized to null, all bits are zero, indicating NO entities present
cachedEntityState = 0;
List<TimerDeclarationImpl> timerDeclarations = (List<TimerDeclarationImpl>) scope.getProperty(BpmnParse.PROPERTYNAME_TIMER_DECLARATION);
if (timerDeclarations != null) {
for (TimerDeclarationImpl timerDeclaration : timerDeclarations) {
TimerEntity timer = timerDeclaration.prepareTimerEntity(this);
if (timer != null) {
Context.getCommandContext().getJobEntityManager().schedule(timer);
}
}
}
// create event subscriptions for the current scope
List<EventSubscriptionDeclaration> eventSubscriptionDeclarations = (List<EventSubscriptionDeclaration>) scope.getProperty(BpmnParse.PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION);
if (eventSubscriptionDeclarations != null) {
for (EventSubscriptionDeclaration eventSubscriptionDeclaration : eventSubscriptionDeclarations) {
if (!eventSubscriptionDeclaration.isStartEvent()) {
EventSubscriptionEntity eventSubscriptionEntity = eventSubscriptionDeclaration.prepareEventSubscriptionEntity(this);
if (getTenantId() != null) {
eventSubscriptionEntity.setTenantId(getTenantId());
}
eventSubscriptionEntity.insert();
}
}
}
}
use of org.activiti.engine.impl.pvm.process.ScopeImpl in project Activiti by Activiti.
the class AddListenerUserTaskParseHandler method executeParse.
protected void executeParse(BpmnParse bpmnParse, UserTask userTask) {
super.executeParse(bpmnParse, userTask);
ScopeImpl scope = bpmnParse.getCurrentScope();
ProcessDefinitionImpl processDefinition = scope.getProcessDefinition();
ActivityImpl activity = processDefinition.findActivity(userTask.getId());
SimulatorParserUtils.setSimulationBehavior(scope, userTask);
UserTaskActivityBehavior userTaskActivity = (UserTaskActivityBehavior) activity.getActivityBehavior();
userTaskActivity.getTaskDefinition().addTaskListener(eventName, taskListener);
}
use of org.activiti.engine.impl.pvm.process.ScopeImpl in project Activiti by Activiti.
the class AtomicOperationTransitionDestroyScope method execute.
@SuppressWarnings("unchecked")
public void execute(InterpretableExecution execution) {
InterpretableExecution propagatingExecution = null;
ActivityImpl activity = (ActivityImpl) execution.getActivity();
// if this transition is crossing a scope boundary
if (activity.isScope()) {
InterpretableExecution parentScopeInstance = null;
// if this is a concurrent execution crossing a scope boundary
if (execution.isConcurrent() && !execution.isScope()) {
// first remove the execution from the current root
InterpretableExecution concurrentRoot = (InterpretableExecution) execution.getParent();
parentScopeInstance = (InterpretableExecution) execution.getParent().getParent();
log.debug("moving concurrent {} one scope up under {}", execution, parentScopeInstance);
List<InterpretableExecution> parentScopeInstanceExecutions = (List<InterpretableExecution>) parentScopeInstance.getExecutions();
List<InterpretableExecution> concurrentRootExecutions = (List<InterpretableExecution>) concurrentRoot.getExecutions();
// if the parent scope had only one single scope child
if (parentScopeInstanceExecutions.size() == 1) {
// it now becomes a concurrent execution
parentScopeInstanceExecutions.get(0).setConcurrent(true);
}
concurrentRootExecutions.remove(execution);
parentScopeInstanceExecutions.add(execution);
execution.setParent(parentScopeInstance);
execution.setActivity(activity);
propagatingExecution = execution;
// the concurrent root.
if (concurrentRootExecutions.size() == 1) {
InterpretableExecution lastConcurrent = concurrentRootExecutions.get(0);
if (lastConcurrent.isScope()) {
lastConcurrent.setConcurrent(false);
} else {
log.debug("merging last concurrent {} into concurrent root {}", lastConcurrent, concurrentRoot);
// We can't just merge the data of the lastConcurrent into the concurrentRoot.
// This is because the concurrent root might be in a takeAll-loop. So the
// concurrent execution is the one that will be receiving the take
concurrentRoot.setActivity((ActivityImpl) lastConcurrent.getActivity());
concurrentRoot.setActive(lastConcurrent.isActive());
lastConcurrent.setReplacedBy(concurrentRoot);
lastConcurrent.remove();
}
}
} else if (execution.isConcurrent() && execution.isScope()) {
log.debug("scoped concurrent {} becomes concurrent and remains under {}", execution, execution.getParent());
// TODO!
execution.destroy();
propagatingExecution = execution;
} else {
propagatingExecution = (InterpretableExecution) execution.getParent();
propagatingExecution.setActivity((ActivityImpl) execution.getActivity());
propagatingExecution.setTransition(execution.getTransition());
propagatingExecution.setActive(true);
log.debug("destroy scope: scoped {} continues as parent scope {}", execution, propagatingExecution);
execution.destroy();
execution.remove();
}
} else {
propagatingExecution = execution;
}
// if there is another scope element that is ended
ScopeImpl nextOuterScopeElement = activity.getParent();
TransitionImpl transition = propagatingExecution.getTransition();
ActivityImpl destination = transition.getDestination();
if (transitionLeavesNextOuterScope(nextOuterScopeElement, destination)) {
propagatingExecution.setActivity((ActivityImpl) nextOuterScopeElement);
propagatingExecution.performOperation(TRANSITION_NOTIFY_LISTENER_END);
} else {
propagatingExecution.performOperation(TRANSITION_NOTIFY_LISTENER_TAKE);
}
}
Aggregations