Search in sources :

Example 11 with ScopeImpl

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);
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl)

Example 12 with ScopeImpl

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();
            }
        }
    }
}
Also used : TimerDeclarationImpl(org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl) List(java.util.List) ArrayList(java.util.ArrayList) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl) EventSubscriptionDeclaration(org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration)

Example 13 with ScopeImpl

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);
}
Also used : ProcessDefinitionImpl(org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) UserTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl)

Example 14 with ScopeImpl

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);
    }
}
Also used : TransitionImpl(org.activiti.engine.impl.pvm.process.TransitionImpl) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) List(java.util.List) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl)

Aggregations

ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)14 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)11 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)3 EventDefinition (org.activiti.bpmn.model.EventDefinition)3 List (java.util.List)2 ErrorEventDefinition (org.activiti.bpmn.model.ErrorEventDefinition)2 MessageEventDefinition (org.activiti.bpmn.model.MessageEventDefinition)2 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)2 StartEvent (org.activiti.bpmn.model.StartEvent)2 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)2 EventSubscriptionDeclaration (org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration)2 ProcessDefinitionImpl (org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)2 TransitionImpl (org.activiti.engine.impl.pvm.process.TransitionImpl)2 ArrayList (java.util.ArrayList)1 BpmnModel (org.activiti.bpmn.model.BpmnModel)1 CancelEventDefinition (org.activiti.bpmn.model.CancelEventDefinition)1 CompensateEventDefinition (org.activiti.bpmn.model.CompensateEventDefinition)1 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)1 Message (org.activiti.bpmn.model.Message)1 TerminateEventDefinition (org.activiti.bpmn.model.TerminateEventDefinition)1