Example #1
0
        protected internal virtual MigratingProcessElementInstance createMigratingEventScopeInstance(MigratingInstanceParseContext parseContext, EventSubscriptionEntity element)
        {
            ActivityImpl compensatingActivity = parseContext.SourceProcessDefinition.findActivity(element.ActivityId);

            MigrationInstruction migrationInstruction = getMigrationInstruction(parseContext, compensatingActivity);

            ActivityImpl eventSubscriptionTargetScope = null;

            if (migrationInstruction != null)
            {
                if (compensatingActivity.CompensationHandler)
                {
                    ActivityImpl targetEventScope = (ActivityImpl)parseContext.getTargetActivity(migrationInstruction).EventScope;
                    eventSubscriptionTargetScope = targetEventScope.findCompensationHandler();
                }
                else
                {
                    eventSubscriptionTargetScope = parseContext.getTargetActivity(migrationInstruction);
                }
            }

            ExecutionEntity      eventScopeExecution   = CompensationUtil.getCompensatingExecution(element);
            MigrationInstruction eventScopeInstruction = parseContext.findSingleMigrationInstruction(eventScopeExecution.ActivityId);
            ActivityImpl         targetScope           = parseContext.getTargetActivity(eventScopeInstruction);

            MigratingEventScopeInstance migratingCompensationInstance = parseContext.MigratingProcessInstance.addEventScopeInstance(eventScopeInstruction, eventScopeExecution, eventScopeExecution.getActivity(), targetScope, migrationInstruction, element, compensatingActivity, eventSubscriptionTargetScope);

            parseContext.consume(element);
            parseContext.submit(migratingCompensationInstance);

            parseDependentEntities(parseContext, migratingCompensationInstance);

            return(migratingCompensationInstance);
        }
Example #2
0
        protected internal virtual IList <EventSubscriptionEntity> CollectEventSubscriptions(IActivityExecution execution)
        {
            var activityRef = CompensateEventDefinition.ActivityRef;

            if (!ReferenceEquals(activityRef, null))
            {
                return(CompensationUtil.CollectCompensateEventSubscriptionsForActivity(execution, activityRef));
            }
            return(CompensationUtil.CollectCompensateEventSubscriptionsForScope(execution));
        }
        public virtual void HandleEvent(EventSubscriptionEntity eventSubscription, object payload,
                                        CommandContext commandContext)
        {
            eventSubscription.Delete();

            var configuration = eventSubscription.Configuration;

            EnsureUtil.EnsureNotNull(
                "Compensating execution not set for compensate event subscription with id " + eventSubscription.Id,
                "configuration", configuration);

            ExecutionEntity compensatingExecution = commandContext.ExecutionManager.FindExecutionById(configuration);

            ActivityImpl compensationHandler = eventSubscription.Activity;

            //activate execution
            compensatingExecution.IsActive = true;

            if (compensatingExecution.GetActivity().ActivityBehavior is ICompositeActivityBehavior)
            {
                compensatingExecution.Parent.ActivityInstanceId = compensatingExecution.ActivityInstanceId;
            }

            if (compensationHandler.IsScope && !compensationHandler.CompensationHandler)
            {
                // descend into scope:
                IList <EventSubscriptionEntity> eventsForThisScope = compensatingExecution.CompensateEventSubscriptions;
                CompensationUtil.ThrowCompensationEvent(eventsForThisScope, compensatingExecution, false);
            }
            else
            {
                try
                {
                    if (compensationHandler.SubProcessScope && compensationHandler.TriggeredByEvent)
                    {
                        compensatingExecution.ExecuteActivity(compensationHandler);
                    }
                    else
                    {
                        // since we already have a scope execution, we don't need to create another one
                        // for a simple scoped compensation handler
                        compensatingExecution.SetActivity(compensationHandler);
                        compensatingExecution.PerformOperation(PvmAtomicOperationFields.ActivityStart);
                    }
                }
                //TODO 暂时取消异常拦截
                //catch (Exception e)
                //{
                //    throw new ProcessEngineException("Error while handling compensation event " + eventSubscription, e);
                //}
                finally
                {
                }
            }
        }
Example #4
0
        protected internal override ICollection <EventSubscriptionEntity> NextElements()
        {
            var eventSubscriptionEntity = CurrentElement;
            var compensatingExecution   = CompensationUtil.GetCompensatingExecution(eventSubscriptionEntity);

            if (compensatingExecution != null)
            {
                //return compensatingExecution.CompensateEventSubscriptions;
            }
            return(null);
        }
Example #5
0
        public override void Execute(IActivityExecution execution)
        {
            var eventSubscriptions = CollectEventSubscriptions(execution);

            if (eventSubscriptions.Count == 0)
            {
                Leave(execution);
            }
            else
            {
                CompensationUtil.ThrowCompensationEvent(eventSubscriptions, execution, false);
            }
        }
Example #6
0
        protected internal override ICollection <EventSubscriptionEntity> nextElements()
        {
            EventSubscriptionEntity eventSubscriptionEntity = CurrentElement;
            ExecutionEntity         compensatingExecution   = CompensationUtil.getCompensatingExecution(eventSubscriptionEntity);

            if (compensatingExecution != null)
            {
                return(compensatingExecution.CompensateEventSubscriptions);
            }
            else
            {
                return(Collections.emptyList());
            }
        }
Example #7
0
        protected internal virtual IList <EventSubscriptionEntity> collectEventSubscriptions(ActivityExecution execution)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String activityRef = compensateEventDefinition.getActivityRef();
            string activityRef = compensateEventDefinition.ActivityRef;

            if (!string.ReferenceEquals(activityRef, null))
            {
                return(CompensationUtil.collectCompensateEventSubscriptionsForActivity(execution, activityRef));
            }
            else
            {
                return(CompensationUtil.collectCompensateEventSubscriptionsForScope(execution));
            }
        }
Example #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void execute(org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution execution) throws Exception
        public virtual void execute(ActivityExecution execution)
        {
            EnsureUtil.ensureNotNull("Could not find cancel boundary event for cancel end event " + execution.Activity, "cancelBoundaryEvent", cancelBoundaryEvent);

            IList <EventSubscriptionEntity> compensateEventSubscriptions = CompensationUtil.collectCompensateEventSubscriptionsForScope(execution);

            if (compensateEventSubscriptions.Count == 0)
            {
                leave(execution);
            }
            else
            {
                CompensationUtil.throwCompensationEvent(compensateEventSubscriptions, execution, false);
            }
        }
Example #9
0
        public virtual void handleEvent(EventSubscriptionEntity eventSubscription, object payload, object localPayload, string businessKey, CommandContext commandContext)
        {
            eventSubscription.delete();

            string configuration = eventSubscription.Configuration;

            ensureNotNull("Compensating execution not set for compensate event subscription with id " + eventSubscription.Id, "configuration", configuration);

            ExecutionEntity compensatingExecution = commandContext.ExecutionManager.findExecutionById(configuration);

            ActivityImpl compensationHandler = eventSubscription.Activity;

            // activate execution
            compensatingExecution.Active = true;

            if (compensatingExecution.getActivity().ActivityBehavior is CompositeActivityBehavior)
            {
                compensatingExecution.Parent.ActivityInstanceId = compensatingExecution.ActivityInstanceId;
            }

            if (compensationHandler.Scope && !compensationHandler.CompensationHandler)
            {
                // descend into scope:
                IList <EventSubscriptionEntity> eventsForThisScope = compensatingExecution.CompensateEventSubscriptions;
                CompensationUtil.throwCompensationEvent(eventsForThisScope, compensatingExecution, false);
            }
            else
            {
                try
                {
                    if (compensationHandler.SubProcessScope && compensationHandler.TriggeredByEvent)
                    {
                        compensatingExecution.executeActivity(compensationHandler);
                    }
                    else
                    {
                        // since we already have a scope execution, we don't need to create another one
                        // for a simple scoped compensation handler
                        compensatingExecution.setActivity(compensationHandler);
                        compensatingExecution.performOperation(org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation_Fields.ACTIVITY_START);
                    }
                }
                catch (Exception e)
                {
                    throw new ProcessEngineException("Error while handling compensation event " + eventSubscription, e);
                }
            }
        }
Example #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void execute(org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution execution) throws Exception
        public virtual void execute(ActivityExecution execution)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity> eventSubscriptions = collectEventSubscriptions(execution);
            IList <EventSubscriptionEntity> eventSubscriptions = collectEventSubscriptions(execution);

            if (eventSubscriptions.Count == 0)
            {
                leave(execution);
            }
            else
            {
                // async (waitForCompletion=false in bpmn) is not supported
                CompensationUtil.throwCompensationEvent(eventSubscriptions, execution, false);
            }
        }
Example #11
0
        public override void Execute(IActivityExecution execution)
        {
            EnsureUtil.EnsureNotNull("Could not find cancel boundary event for cancel end event " + execution.Activity,
                                     "cancelBoundaryEvent", cancelBoundaryEvent);

            var compensateEventSubscriptions = CompensationUtil.CollectCompensateEventSubscriptionsForScope(execution);

            if (compensateEventSubscriptions.Count == 0)
            {
                Leave(execution);
            }
            else
            {
                CompensationUtil.ThrowCompensationEvent(compensateEventSubscriptions, execution, false);
            }
        }
Example #12
0
        public override void DoLeave(IActivityExecution execution)
        {
            CompensationUtil.CreateEventScopeExecution((ExecutionEntity)execution);

            base.DoLeave(execution);
        }