Exemple #1
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);
            }
        }
Exemple #2
0
        public virtual void validate(MigratingActivityInstance migratingInstance, MigratingProcessInstance migratingProcessInstance, MigratingActivityInstanceValidationReportImpl instanceReport)
        {
            ScopeImpl sourceScope = migratingInstance.SourceScope;
            ScopeImpl targetScope = migratingInstance.TargetScope;

            if (migratingInstance.migrates())
            {
                bool becomesNonScope = sourceScope.Scope && !targetScope.Scope;
                if (becomesNonScope)
                {
                    IDictionary <string, IList <MigratingVariableInstance> > dependentVariablesByName = getMigratingVariableInstancesByName(migratingInstance);
                    foreach (string variableName in dependentVariablesByName.Keys)
                    {
                        if (dependentVariablesByName[variableName].Count > 1)
                        {
                            instanceReport.addFailure("The variable '" + variableName + "' exists in both, this scope and " + "concurrent local in the parent scope. " + "Migrating to a non-scope activity would overwrite one of them.");
                        }
                    }
                }
            }
        }
Exemple #3
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);
            }
        }