Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        protected internal virtual MigrationInstruction getMigrationInstruction(MigratingInstanceParseContext parseContext, ActivityImpl activity)
        {
            if (activity.CompensationHandler)
            {
                Properties   compensationHandlerProperties = activity.Properties;
                ActivityImpl eventTrigger = compensationHandlerProperties.get(BpmnProperties.COMPENSATION_BOUNDARY_EVENT);
                if (eventTrigger == null)
                {
                    eventTrigger = compensationHandlerProperties.get(BpmnProperties.INITIAL_ACTIVITY);
                }

                return(parseContext.findSingleMigrationInstruction(eventTrigger.ActivityId));
            }
            else
            {
                return(parseContext.findSingleMigrationInstruction(activity.ActivityId));
            }
        }
Ejemplo n.º 3
0
        protected internal virtual bool isNonInterruptingTimerTriggeredAlready(MigratingInstanceParseContext parseContext, IDictionary <string, TimerDeclarationImpl> sourceTimerDeclarationsInEventScope, TimerDeclarationImpl targetTimerDeclaration)
        {
            if (targetTimerDeclaration.InterruptingTimer || !string.ReferenceEquals(targetTimerDeclaration.JobHandlerType, TimerExecuteNestedActivityJobHandler.TYPE) || sourceTimerDeclarationsInEventScope.Values.Count == 0)
            {
                return(false);
            }
            foreach (TimerDeclarationImpl sourceTimerDeclaration in sourceTimerDeclarationsInEventScope.Values)
            {
                MigrationInstruction migrationInstruction = parseContext.findSingleMigrationInstruction(sourceTimerDeclaration.ActivityId);
                ActivityImpl         targetActivity       = parseContext.getTargetActivity(migrationInstruction);

                if (targetActivity != null && targetTimerDeclaration.ActivityId.Equals(targetActivity.ActivityId))
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 4
0
        public virtual void handle(MigratingInstanceParseContext parseContext, MigratingActivityInstance activityInstance, IList <JobEntity> elements)
        {
            IDictionary <string, TimerDeclarationImpl> sourceTimerDeclarationsInEventScope = getTimerDeclarationsByTriggeringActivity(activityInstance.SourceScope);
            IDictionary <string, TimerDeclarationImpl> targetTimerDeclarationsInEventScope = getTimerDeclarationsByTriggeringActivity(activityInstance.TargetScope);

            foreach (JobEntity job in elements)
            {
                if (!isTimerJob(job))
                {
                    // skip non timer jobs
                    continue;
                }

                MigrationInstruction migrationInstruction = parseContext.findSingleMigrationInstruction(job.ActivityId);
                ActivityImpl         targetActivity       = parseContext.getTargetActivity(migrationInstruction);

                if (targetActivity != null && activityInstance.migratesTo(targetActivity.EventScope))
                {
                    // the timer job is migrated
                    JobDefinitionEntity targetJobDefinitionEntity = parseContext.getTargetJobDefinition(targetActivity.ActivityId, job.JobHandlerType);

                    TimerDeclarationImpl targetTimerDeclaration = targetTimerDeclarationsInEventScope.Remove(targetActivity.Id);

                    MigratingJobInstance migratingTimerJobInstance = new MigratingTimerJobInstance(job, targetJobDefinitionEntity, targetActivity, migrationInstruction.UpdateEventTrigger, targetTimerDeclaration);
                    activityInstance.addMigratingDependentInstance(migratingTimerJobInstance);
                    parseContext.submit(migratingTimerJobInstance);
                }
                else
                {
                    // the timer job is removed
                    MigratingJobInstance removingJobInstance = new MigratingTimerJobInstance(job);
                    activityInstance.addRemovingDependentInstance(removingJobInstance);
                    parseContext.submit(removingJobInstance);
                }

                parseContext.consume(job);
            }

            if (activityInstance.migrates())
            {
                addEmergingTimerJobs(parseContext, activityInstance, sourceTimerDeclarationsInEventScope, targetTimerDeclarationsInEventScope);
            }
        }
Ejemplo n.º 5
0
        public virtual void handle(MigratingInstanceParseContext parseContext, MigratingActivityInstance owningInstance, IList <EventSubscriptionEntity> elements)
        {
            IDictionary <string, EventSubscriptionDeclaration> targetDeclarations = getDeclarationsByTriggeringActivity(owningInstance.TargetScope);

            foreach (EventSubscriptionEntity eventSubscription in elements)
            {
                if (!SupportedEventTypes.Contains(eventSubscription.EventType))
                {
                    // ignore unsupported event subscriptions
                    continue;
                }

                MigrationInstruction migrationInstruction = parseContext.findSingleMigrationInstruction(eventSubscription.ActivityId);
                ActivityImpl         targetActivity       = parseContext.getTargetActivity(migrationInstruction);

                if (targetActivity != null && owningInstance.migratesTo(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);
            }
        }