protected internal virtual IMigrationInstruction GetMigrationInstruction(
            MigratingInstanceParseContext parseContext, ActivityImpl activity)
        {
            if (activity.CompensationHandler)
            {
                var compensationHandlerProperties = activity.Properties;
                var eventTrigger = compensationHandlerProperties.Get(BpmnProperties.CompensationBoundaryEvent);
                if (eventTrigger == null)
                {
                    eventTrigger = compensationHandlerProperties.Get(BpmnProperties.InitialActivity);
                }

                return(parseContext.FindSingleMigrationInstruction(eventTrigger.ActivityId));
            }
            return(parseContext.FindSingleMigrationInstruction(activity.ActivityId));
        }
        protected internal virtual MigratingProcessElementInstance CreateMigratingEventScopeInstance(
            MigratingInstanceParseContext parseContext, EventSubscriptionEntity element)
        {
            var compensatingActivity =
                (ActivityImpl)parseContext.SourceProcessDefinition.FindActivity(element.ActivityId);

            var migrationInstruction = GetMigrationInstruction(parseContext, compensatingActivity);

            ActivityImpl eventSubscriptionTargetScope = null;

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

            var eventScopeExecution   = CompensationUtil.GetCompensatingExecution(element);
            var eventScopeInstruction = parseContext.FindSingleMigrationInstruction(eventScopeExecution.ActivityId);
            var targetScope           = parseContext.GetTargetActivity(eventScopeInstruction);

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

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

            //parseDependentEntities(parseContext, migratingCompensationInstance);

            //return migratingCompensationInstance;
            return(null);
        }
Example #3
0
        public virtual void Handle(MigratingInstanceParseContext parseContext, MigratingActivityInstance owningInstance,
                                   IList <EventSubscriptionEntity> elements)
        {
            var targetDeclarations = GetDeclarationsByTriggeringActivity(owningInstance.TargetScope);

            foreach (var eventSubscription in elements)
            {
                if (!SupportedEventTypes.Contains(eventSubscription.EventType))
                {
                    continue;
                }

                var migrationInstruction = parseContext.FindSingleMigrationInstruction(eventSubscription.ActivityId);
                var targetActivity       = parseContext.GetTargetActivity(migrationInstruction);

                if ((targetActivity != null) && owningInstance.MigratesTo((ScopeImpl)targetActivity.EventScope))
                {
                    // the event subscription is migrated
                    //EventSubscriptionDeclaration targetDeclaration = targetDeclarations.Remove(targetActivity.Id);

                    //owningInstance.addMigratingDependentInstance(new MigratingEventSubscriptionInstance(eventSubscription, targetActivity, migrationInstruction.UpdateEventTrigger, targetDeclaration));
                }
                else
                {
                    // the event subscription will be removed
                    owningInstance.AddRemovingDependentInstance(new MigratingEventSubscriptionInstance(eventSubscription));
                }

                //parseContext.consume(eventSubscription);
            }

            if (owningInstance.Migrates())
            {
                AddEmergingEventSubscriptions(owningInstance, targetDeclarations.Values);
            }
        }