示例#1
0
 public OutgoingExecution(PvmExecutionImpl outgoingExecution, PvmTransition outgoingTransition)
 {
     this.outgoingExecution  = outgoingExecution;
     this.outgoingTransition = outgoingTransition;
     outgoingExecution.setTransition(outgoingTransition);
     outgoingExecution.ActivityInstanceId = null;
 }
示例#2
0
 public InstantiationStack(IList <PvmActivity> activities, PvmActivity targetActivity, PvmTransition targetTransition)
 {
     EnsureUtil.ensureOnlyOneNotNull("target must be either a transition or an activity", targetActivity, targetTransition);
     this.activities = activities;
     // TODO: make this a subclass that contains targetActivity and targetTransition?!
     this.targetActivity   = targetActivity;
     this.targetTransition = targetTransition;
 }
示例#3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void execute(org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution execution) throws Exception
        public virtual void execute(ActivityExecution execution)
        {
            execution.inactivate();
            lockConcurrentRoot(execution);

            PvmActivity activity = execution.Activity;

            if (activatesGateway(execution, activity))
            {
                LOG.activityActivation(activity.Id);

                IList <ActivityExecution> joinedExecutions = execution.findInactiveConcurrentExecutions(activity);
                string defaultSequenceFlow = (string)execution.Activity.getProperty("default");
                IList <PvmTransition> transitionsToTake = new List <PvmTransition>();

                // find matching non-default sequence flows
                foreach (PvmTransition outgoingTransition in execution.Activity.OutgoingTransitions)
                {
                    if (string.ReferenceEquals(defaultSequenceFlow, null) || !outgoingTransition.Id.Equals(defaultSequenceFlow))
                    {
                        Condition condition = (Condition)outgoingTransition.getProperty(BpmnParse.PROPERTYNAME_CONDITION);
                        if (condition == null || condition.evaluate(execution))
                        {
                            transitionsToTake.Add(outgoingTransition);
                        }
                    }
                }

                // if none found, add default flow
                if (transitionsToTake.Count == 0)
                {
                    if (!string.ReferenceEquals(defaultSequenceFlow, null))
                    {
                        PvmTransition defaultTransition = execution.Activity.findOutgoingTransition(defaultSequenceFlow);
                        if (defaultTransition == null)
                        {
                            throw LOG.missingDefaultFlowException(execution.Activity.Id, defaultSequenceFlow);
                        }

                        transitionsToTake.Add(defaultTransition);
                    }
                    else
                    {
                        // No sequence flow could be found, not even a default one
                        throw LOG.stuckExecutionException(execution.Activity.Id);
                    }
                }

                // take the flows found
                execution.leaveActivityViaTransitions(transitionsToTake, joinedExecutions);
            }
            else
            {
                LOG.noActivityActivation(activity.Id);
            }
        }
示例#4
0
        protected internal virtual bool canReachActivity(ActivityExecution execution, PvmActivity activity)
        {
            PvmTransition pvmTransition = execution.Transition;

            if (pvmTransition != null)
            {
                return(isReachable(pvmTransition.Destination, activity, new HashSet <PvmActivity>()));
            }
            else
            {
                return(isReachable(execution.Activity, activity, new HashSet <PvmActivity>()));
            }
        }
示例#5
0
        protected internal override void eventNotificationsCompleted(PvmExecutionImpl execution)
        {
            base.eventNotificationsCompleted(execution);

            execution.activityInstanceStarted();

            ExecutionStartContext startContext       = execution.ExecutionStartContext;
            InstantiationStack    instantiationStack = startContext.InstantiationStack;

            PvmExecutionImpl propagatingExecution = execution;
            ActivityImpl     activity             = execution.getActivity();

            if (activity.ActivityBehavior is ModificationObserverBehavior)
            {
                ModificationObserverBehavior behavior             = (ModificationObserverBehavior)activity.ActivityBehavior;
                IList <ActivityExecution>    concurrentExecutions = behavior.initializeScope(propagatingExecution, 1);
                propagatingExecution = (PvmExecutionImpl)concurrentExecutions[0];
            }

            // if the stack has been instantiated
            if (instantiationStack.Activities.Count == 0 && instantiationStack.TargetActivity != null)
            {
                // as if we are entering the target activity instance id via a transition
                propagatingExecution.ActivityInstanceId = null;

                // execute the target activity with this execution
                startContext.applyVariables(propagatingExecution);
                propagatingExecution.setActivity(instantiationStack.TargetActivity);
                propagatingExecution.performOperation(PvmAtomicOperation_Fields.ACTIVITY_START_CREATE_SCOPE);
            }
            else if (instantiationStack.Activities.Count == 0 && instantiationStack.TargetTransition != null)
            {
                // as if we are entering the target activity instance id via a transition
                propagatingExecution.ActivityInstanceId = null;

                // execute the target transition with this execution
                PvmTransition transition = instantiationStack.TargetTransition;
                startContext.applyVariables(propagatingExecution);
                propagatingExecution.setActivity(transition.Source);
                propagatingExecution.setTransition((TransitionImpl)transition);
                propagatingExecution.performOperation(PvmAtomicOperation_Fields.TRANSITION_START_NOTIFY_LISTENER_TAKE);
            }
            else
            {
                // else instantiate the activity stack further
                propagatingExecution.setActivity(null);
                propagatingExecution.performOperation(PvmAtomicOperation_Fields.ACTIVITY_INIT_STACK);
            }
        }
示例#6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void execute(org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution execution) throws Exception
        public virtual void execute(ActivityExecution execution)
        {
            string var = (string)execution.getVariable("var");

            PvmTransition transition = null;

            try
            {
                executeLogic(var);
                transition = execution.Activity.findOutgoingTransition("no-exception");
            }
            catch (Exception)
            {
                transition = execution.Activity.findOutgoingTransition("exception");
            }
            execution.leaveActivityViaTransition(transition);
        }
示例#7
0
        /// <summary>
        /// The default behaviour of BPMN, taking every outgoing sequence flow
        /// (where the condition evaluates to true), is not valid for an exclusive
        /// gateway.
        ///
        /// Hence, this behaviour is overriden and replaced by the correct behavior:
        /// selecting the first sequence flow which condition evaluates to true
        /// (or which hasn't got a condition) and leaving the activity through that
        /// sequence flow.
        ///
        /// If no sequence flow is selected (ie all conditions evaluate to false),
        /// then the default sequence flow is taken (if defined).
        /// </summary>
        public override void doLeave(ActivityExecution execution)
        {
            LOG.leavingActivity(execution.Activity.Id);

            PvmTransition outgoingSeqFlow     = null;
            string        defaultSequenceFlow = (string)execution.Activity.getProperty("default");
            IEnumerator <PvmTransition> transitionIterator = execution.Activity.OutgoingTransitions.GetEnumerator();

            while (outgoingSeqFlow == null && transitionIterator.MoveNext())
            {
                PvmTransition seqFlow = transitionIterator.Current;

                Condition condition = (Condition)seqFlow.getProperty(BpmnParse.PROPERTYNAME_CONDITION);
                if ((condition == null && (string.ReferenceEquals(defaultSequenceFlow, null) || !defaultSequenceFlow.Equals(seqFlow.Id))) || (condition != null && condition.evaluate(execution)))
                {
                    LOG.outgoingSequenceFlowSelected(seqFlow.Id);
                    outgoingSeqFlow = seqFlow;
                }
            }

            if (outgoingSeqFlow != null)
            {
                execution.leaveActivityViaTransition(outgoingSeqFlow);
            }
            else
            {
                if (!string.ReferenceEquals(defaultSequenceFlow, null))
                {
                    PvmTransition defaultTransition = execution.Activity.findOutgoingTransition(defaultSequenceFlow);
                    if (defaultTransition != null)
                    {
                        execution.leaveActivityViaTransition(defaultTransition);
                    }
                    else
                    {
                        throw LOG.missingDefaultFlowException(execution.Activity.Id, defaultSequenceFlow);
                    }
                }
                else
                {
                    //No sequence flow could be found, not even a default one
                    throw LOG.stuckExecutionException(execution.Activity.Id);
                }
            }
        }
示例#8
0
        /// <summary>
        /// Actual implementation of leaving an activity.
        /// </summary>
        /// <param name="execution">
        ///          The current execution context </param>
        /// <param name="checkConditions">
        ///          Whether or not to check conditions before determining whether or
        ///          not to take a transition. </param>
        protected internal virtual void performOutgoingBehavior(ActivityExecution execution, bool checkConditions, IList <ActivityExecution> reusableExecutions)
        {
            LOG.leavingActivity(execution.Activity.Id);

            string defaultSequenceFlow = (string)execution.Activity.getProperty("default");
            IList <PvmTransition> transitionsToTake = new List <PvmTransition>();

            IList <PvmTransition> outgoingTransitions = execution.Activity.OutgoingTransitions;

            foreach (PvmTransition outgoingTransition in outgoingTransitions)
            {
                if (string.ReferenceEquals(defaultSequenceFlow, null) || !outgoingTransition.Id.Equals(defaultSequenceFlow))
                {
                    Condition condition = (Condition)outgoingTransition.getProperty(BpmnParse.PROPERTYNAME_CONDITION);
                    if (condition == null || !checkConditions || condition.evaluate(execution))
                    {
                        transitionsToTake.Add(outgoingTransition);
                    }
                }
            }

            if (transitionsToTake.Count == 1)
            {
                execution.leaveActivityViaTransition(transitionsToTake[0]);
            }
            else if (transitionsToTake.Count >= 1)
            {
                if (reusableExecutions == null || reusableExecutions.Count == 0)
                {
                    execution.leaveActivityViaTransitions(transitionsToTake, Arrays.asList(execution));
                }
                else
                {
                    execution.leaveActivityViaTransitions(transitionsToTake, reusableExecutions);
                }
            }
            else
            {
                if (!string.ReferenceEquals(defaultSequenceFlow, null))
                {
                    PvmTransition defaultTransition = execution.Activity.findOutgoingTransition(defaultSequenceFlow);
                    if (defaultTransition != null)
                    {
                        execution.leaveActivityViaTransition(defaultTransition);
                    }
                    else
                    {
                        throw LOG.missingDefaultFlowException(execution.Activity.Id, defaultSequenceFlow);
                    }
                }
                else if (outgoingTransitions.Count > 0)
                {
                    throw LOG.missingConditionalFlowException(execution.Activity.Id);
                }
                else
                {
                    if (((ActivityImpl)execution.Activity).CompensationHandler && isAncestorCompensationThrowing(execution))
                    {
                        execution.endCompensation();
                    }
                    else
                    {
                        LOG.missingOutgoingSequenceFlow(execution.Activity.Id);
                        execution.end(true);
                    }
                }
            }
        }
示例#9
0
 public virtual void notTakingTranistion(PvmTransition outgoingTransition)
 {
     logDebug("001", "Not taking transition '{}', outgoing execution has ended.", outgoingTransition);
 }
示例#10
0
        public virtual void execute(PvmExecutionImpl execution)
        {
            // calculate the propagating execution
            PvmExecutionImpl propagatingExecution = execution;

            PvmActivity           activity          = execution.getActivity();
            IList <PvmTransition> transitionsToTake = execution.TransitionsToTake;

            execution.TransitionsToTake = null;

            // check whether the current scope needs to be destroyed
            if (execution.Scope && activity.Scope)
            {
                if (!LegacyBehavior.destroySecondNonScope(execution))
                {
                    if (execution.Concurrent)
                    {
                        // legacy behavior
                        LegacyBehavior.destroyConcurrentScope(execution);
                    }
                    else
                    {
                        propagatingExecution = execution.Parent;
                        LOG.debugDestroyScope(execution, propagatingExecution);
                        execution.destroy();
                        propagatingExecution.setActivity(execution.getActivity());
                        propagatingExecution.setTransition(execution.getTransition());
                        propagatingExecution.Active = true;
                        execution.remove();
                    }
                }
            }
            else
            {
                // activity is not scope => nothing to do
                propagatingExecution = execution;
            }

            // take the specified transitions
            if (transitionsToTake.Count == 0)
            {
                throw new ProcessEngineException(execution.ToString() + ": No outgoing transitions from " + "activity " + activity);
            }
            else if (transitionsToTake.Count == 1)
            {
                propagatingExecution.setTransition(transitionsToTake[0]);
                propagatingExecution.take();
            }
            else
            {
                propagatingExecution.inactivate();

                IList <OutgoingExecution> outgoingExecutions = new List <OutgoingExecution>();

                for (int i = 0; i < transitionsToTake.Count; i++)
                {
                    PvmTransition transition = transitionsToTake[i];

                    PvmExecutionImpl scopeExecution = propagatingExecution.Scope ? propagatingExecution : propagatingExecution.Parent;

                    // reuse concurrent, propagating execution for first transition
                    PvmExecutionImpl concurrentExecution = null;
                    if (i == 0)
                    {
                        concurrentExecution = propagatingExecution;
                    }
                    else
                    {
                        concurrentExecution = scopeExecution.createConcurrentExecution();

                        if (i == 1 && !propagatingExecution.Concurrent)
                        {
                            outgoingExecutions.RemoveAt(0);
                            // get a hold of the concurrent execution that replaced the scope propagating execution
                            PvmExecutionImpl replacingExecution = null;
                            foreach (PvmExecutionImpl concurrentChild in scopeExecution.NonEventScopeExecutions)
                            {
                                if (!(concurrentChild == propagatingExecution))
                                {
                                    replacingExecution = concurrentChild;
                                    break;
                                }
                            }

                            outgoingExecutions.Add(new OutgoingExecution(replacingExecution, transitionsToTake[0]));
                        }
                    }

                    outgoingExecutions.Add(new OutgoingExecution(concurrentExecution, transition));
                }

                // start executions in reverse order (order will be reversed again in command context with the effect that they are
                // actually be started in correct order :) )
                outgoingExecutions.Reverse();

                foreach (OutgoingExecution outgoingExecution in outgoingExecutions)
                {
                    outgoingExecution.take();
                }
            }
        }