Esempio n. 1
0
 public virtual void parseTransitionInstances(MigratingInstanceParseContext parseContext, MigratingActivityInstance migratingInstance)
 {
     foreach (TransitionInstance transitionInstance in migratingInstance.ActivityInstance.ChildTransitionInstances)
     {
         parseContext.handleTransitionInstance(transitionInstance);
     }
 }
Esempio n. 2
0
        public virtual void handle(MigratingInstanceParseContext parseContext, EventSubscriptionEntity element)
        {
            MigratingProcessElementInstance migratingInstance;

            if (!string.ReferenceEquals(element.Configuration, null))
            {
                migratingInstance = createMigratingEventScopeInstance(parseContext, element);
            }
            else
            {
                migratingInstance = createMigratingEventSubscriptionInstance(parseContext, element);
            }


            ExecutionEntity        owningExecution = element.Execution;
            MigratingScopeInstance parentInstance  = null;

            if (owningExecution.EventScope)
            {
                parentInstance = parseContext.getMigratingCompensationInstanceByExecutionId(owningExecution.Id);
            }
            else
            {
                parentInstance = parseContext.getMigratingActivityInstanceById(owningExecution.ParentActivityInstanceId);
            }
            migratingInstance.Parent = parentInstance;
        }
Esempio n. 3
0
        public virtual void handle(MigratingInstanceParseContext parseContext, TransitionInstance transitionInstance)
        {
            if (!isAsyncTransitionInstance(transitionInstance))
            {
                return;
            }

            MigrationInstruction applyingInstruction = parseContext.getInstructionFor(transitionInstance.ActivityId);

            ScopeImpl sourceScope = parseContext.SourceProcessDefinition.findActivity(transitionInstance.ActivityId);
            ScopeImpl targetScope = null;

            if (applyingInstruction != null)
            {
                string activityId = applyingInstruction.TargetActivityId;
                targetScope = parseContext.TargetProcessDefinition.findActivity(activityId);
            }

            ExecutionEntity asyncExecution = Context.CommandContext.ExecutionManager.findExecutionById(transitionInstance.ExecutionId);

            MigratingTransitionInstance migratingTransitionInstance = parseContext.MigratingProcessInstance.addTransitionInstance(applyingInstruction, transitionInstance, sourceScope, targetScope, asyncExecution);

            MigratingActivityInstance parentInstance = parseContext.getMigratingActivityInstanceById(transitionInstance.ParentActivityInstanceId);

            migratingTransitionInstance.setParent(parentInstance);

            IList <JobEntity> jobs = asyncExecution.Jobs;

            parseContext.handleDependentTransitionInstanceJobs(migratingTransitionInstance, jobs);

            parseContext.handleDependentVariables(migratingTransitionInstance, collectTransitionInstanceVariables(migratingTransitionInstance));
        }
Esempio n. 4
0
        protected internal virtual void parseDependentEntities(MigratingInstanceParseContext parseContext, MigratingEventScopeInstance migratingInstance)
        {
            ExecutionEntity representativeExecution = migratingInstance.resolveRepresentativeExecution();

            IList <VariableInstanceEntity> variables = new List <VariableInstanceEntity>(representativeExecution.VariablesInternal);

            parseContext.handleDependentVariables(migratingInstance, variables);
        }
Esempio n. 5
0
 protected internal virtual void addEmergingTimerJobs(MigratingInstanceParseContext parseContext, MigratingActivityInstance activityInstance, IDictionary <string, TimerDeclarationImpl> sourceTimerDeclarationsInEventScope, IDictionary <string, TimerDeclarationImpl> targetTimerDeclarationsInEventScope)
 {
     foreach (TimerDeclarationImpl targetTimerDeclaration in targetTimerDeclarationsInEventScope.Values)
     {
         if (!isNonInterruptingTimerTriggeredAlready(parseContext, sourceTimerDeclarationsInEventScope, targetTimerDeclaration))
         {
             activityInstance.addEmergingDependentInstance(new EmergingJobInstance(targetTimerDeclaration));
         }
     }
 }
Esempio n. 6
0
        public virtual void handle(MigratingInstanceParseContext parseContext, MigratingProcessElementInstance owningInstance, IList <VariableInstanceEntity> variables)
        {
            ExecutionEntity representativeExecution = owningInstance.resolveRepresentativeExecution();

            foreach (VariableInstanceEntity variable in variables)
            {
                parseContext.consume(variable);
                bool isConcurrentLocalInParentScope = (variable.Execution == representativeExecution.Parent && variable.ConcurrentLocal) || representativeExecution.Concurrent;
                owningInstance.addMigratingDependentInstance(new MigratingVariableInstance(variable, isConcurrentLocalInParentScope));
            }
        }
Esempio n. 7
0
        protected internal virtual void handleIncident(MigratingInstanceParseContext parseContext, IncidentEntity incident)
        {
            MigratingActivityInstance owningInstance = parseContext.getMigratingActivityInstanceById(incident.Execution.ActivityInstanceId);

            if (owningInstance != null)
            {
                parseContext.consume(incident);
                MigratingIncident migratingIncident = new MigratingIncident(incident, owningInstance.TargetScope);
                owningInstance.addMigratingDependentInstance(migratingIncident);
            }
        }
Esempio n. 8
0
        protected internal virtual void handleExternalTaskIncident(MigratingInstanceParseContext parseContext, IncidentEntity incident)
        {
            MigratingExternalTaskInstance owningInstance = parseContext.getMigratingExternalTaskInstanceById(incident.Configuration);

            if (owningInstance != null)
            {
                parseContext.consume(incident);
                MigratingIncident migratingIncident = new MigratingIncident(incident, owningInstance.TargetScope);
                owningInstance.addMigratingDependentInstance(migratingIncident);
            }
        }
Esempio n. 9
0
        public virtual void handle(MigratingInstanceParseContext parseContext, ActivityInstance element)
        {
            MigratingActivityInstance migratingInstance = null;

            MigrationInstruction applyingInstruction     = parseContext.getInstructionFor(element.ActivityId);
            ScopeImpl            sourceScope             = null;
            ScopeImpl            targetScope             = null;
            ExecutionEntity      representativeExecution = parseContext.Mapping.getExecution(element);

            if (element.Id.Equals(element.ProcessInstanceId))
            {
                sourceScope = parseContext.SourceProcessDefinition;
                targetScope = parseContext.TargetProcessDefinition;
            }
            else
            {
                sourceScope = parseContext.SourceProcessDefinition.findActivity(element.ActivityId);

                if (applyingInstruction != null)
                {
                    string activityId = applyingInstruction.TargetActivityId;
                    targetScope = parseContext.TargetProcessDefinition.findActivity(activityId);
                }
            }

            migratingInstance = parseContext.MigratingProcessInstance.addActivityInstance(applyingInstruction, element, sourceScope, targetScope, representativeExecution);

            MigratingActivityInstance parentInstance = parseContext.getMigratingActivityInstanceById(element.ParentActivityInstanceId);

            if (parentInstance != null)
            {
                migratingInstance.setParent(parentInstance);
            }

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.camunda.bpm.engine.impl.core.delegate.CoreActivityBehavior<?> sourceActivityBehavior = sourceScope.getActivityBehavior();
            CoreActivityBehavior <object> sourceActivityBehavior = sourceScope.ActivityBehavior;

            if (sourceActivityBehavior is MigrationObserverBehavior)
            {
                ((MigrationObserverBehavior)sourceActivityBehavior).onParseMigratingInstance(parseContext, migratingInstance);
            }

            parseContext.submit(migratingInstance);

            parseTransitionInstances(parseContext, migratingInstance);

            parseDependentInstances(parseContext, migratingInstance);
        }
Esempio n. 10
0
 public virtual void handle(MigratingInstanceParseContext parseContext, IncidentEntity incident)
 {
     if (!string.ReferenceEquals(incident.Configuration, null) && isFailedJobIncident(incident))
     {
         handleFailedJobIncident(parseContext, incident);
     }
     else if (!string.ReferenceEquals(incident.Configuration, null) && isExternalTaskIncident(incident))
     {
         handleExternalTaskIncident(parseContext, incident);
     }
     else
     {
         handleIncident(parseContext, incident);
     }
 }
Esempio n. 11
0
        public virtual MigratingProcessInstance parse(string processInstanceId, MigrationPlan migrationPlan, MigratingProcessInstanceValidationReportImpl processInstanceReport)
        {
            CommandContext commandContext = Context.CommandContext;
            IList <EventSubscriptionEntity> eventSubscriptions = fetchEventSubscriptions(commandContext, processInstanceId);
            IList <ExecutionEntity>         executions         = fetchExecutions(commandContext, processInstanceId);
            IList <ExternalTaskEntity>      externalTasks      = fetchExternalTasks(commandContext, processInstanceId);
            IList <IncidentEntity>          incidents          = fetchIncidents(commandContext, processInstanceId);
            IList <JobEntity>              jobs      = fetchJobs(commandContext, processInstanceId);
            IList <TaskEntity>             tasks     = fetchTasks(commandContext, processInstanceId);
            IList <VariableInstanceEntity> variables = fetchVariables(commandContext, processInstanceId);

            ExecutionEntity processInstance = commandContext.ExecutionManager.findExecutionById(processInstanceId);

            processInstance.restoreProcessInstance(executions, eventSubscriptions, variables, tasks, jobs, incidents, externalTasks);

            ProcessDefinitionEntity     targetProcessDefinition = Context.ProcessEngineConfiguration.DeploymentCache.findDeployedProcessDefinitionById(migrationPlan.TargetProcessDefinitionId);
            IList <JobDefinitionEntity> targetJobDefinitions    = fetchJobDefinitions(commandContext, targetProcessDefinition.Id);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final MigratingInstanceParseContext parseContext = new MigratingInstanceParseContext(this, migrationPlan, processInstance, targetProcessDefinition).eventSubscriptions(eventSubscriptions).externalTasks(externalTasks).incidents(incidents).jobs(jobs).tasks(tasks).targetJobDefinitions(targetJobDefinitions).variables(variables);
            MigratingInstanceParseContext parseContext = (new MigratingInstanceParseContext(this, migrationPlan, processInstance, targetProcessDefinition)).eventSubscriptions(eventSubscriptions).externalTasks(externalTasks).incidents(incidents).jobs(jobs).tasks(tasks).targetJobDefinitions(targetJobDefinitions).variables(variables);

            ActivityInstance activityInstance = engine.RuntimeService.getActivityInstance(processInstanceId);

            ActivityInstanceWalker activityInstanceWalker = new ActivityInstanceWalker(activityInstance);

            activityInstanceWalker.addPreVisitor(new TreeVisitorAnonymousInnerClass(this, parseContext));

            activityInstanceWalker.walkWhile();

            CompensationEventSubscriptionWalker compensateSubscriptionsWalker = new CompensationEventSubscriptionWalker(parseContext.MigratingActivityInstances);

            compensateSubscriptionsWalker.addPreVisitor(new TreeVisitorAnonymousInnerClass2(this, parseContext));

            compensateSubscriptionsWalker.walkWhile();

            foreach (IncidentEntity incidentEntity in incidents)
            {
                incidentHandler.handle(parseContext, incidentEntity);
            }

            parseContext.validateNoEntitiesLeft(processInstanceReport);

            return(parseContext.MigratingProcessInstance);
        }
Esempio n. 12
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);
        }
Esempio n. 13
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));
            }
        }
Esempio n. 14
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);
            }
        }
Esempio n. 15
0
        protected internal virtual void handleFailedJobIncident(MigratingInstanceParseContext parseContext, IncidentEntity incident)
        {
            MigratingJobInstance owningInstance = parseContext.getMigratingJobInstanceById(incident.Configuration);

            if (owningInstance != null)
            {
                parseContext.consume(incident);
                if (owningInstance.migrates())
                {
                    MigratingIncident   migratingIncident         = new MigratingIncident(incident, owningInstance.TargetScope);
                    JobDefinitionEntity targetJobDefinitionEntity = owningInstance.TargetJobDefinitionEntity;
                    if (targetJobDefinitionEntity != null)
                    {
                        migratingIncident.TargetJobDefinitionId = targetJobDefinitionEntity.Id;
                    }
                    owningInstance.addMigratingDependentInstance(migratingIncident);
                }
            }
        }
Esempio n. 16
0
        public virtual void handle(MigratingInstanceParseContext parseContext, MigratingTransitionInstance transitionInstance, IList <JobEntity> elements)
        {
            foreach (JobEntity job in elements)
            {
                if (!isAsyncContinuation(job))
                {
                    continue;
                }

                ScopeImpl targetScope = transitionInstance.TargetScope;
                if (targetScope != null)
                {
                    JobDefinitionEntity targetJobDefinitionEntity = parseContext.getTargetJobDefinition(transitionInstance.TargetScope.Id, job.JobHandlerType);

                    MigratingAsyncJobInstance migratingJobInstance = new MigratingAsyncJobInstance(job, targetJobDefinitionEntity, transitionInstance.TargetScope);

                    transitionInstance.DependentJobInstance = migratingJobInstance;
                    parseContext.submit(migratingJobInstance);
                }

                parseContext.consume(job);
            }
        }
Esempio n. 17
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);
            }
        }
Esempio n. 18
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);
        }
Esempio n. 19
0
        protected internal virtual MigratingProcessElementInstance createMigratingEventSubscriptionInstance(MigratingInstanceParseContext parseContext, EventSubscriptionEntity element)
        {
            ActivityImpl compensationHandler = parseContext.SourceProcessDefinition.findActivity(element.ActivityId);

            MigrationInstruction migrationInstruction = getMigrationInstruction(parseContext, compensationHandler);

            ActivityImpl targetScope = null;

            if (migrationInstruction != null)
            {
                ActivityImpl targetEventScope = (ActivityImpl)parseContext.getTargetActivity(migrationInstruction).EventScope;
                targetScope = targetEventScope.findCompensationHandler();
            }

            MigratingCompensationEventSubscriptionInstance migratingCompensationInstance = parseContext.MigratingProcessInstance.addCompensationSubscriptionInstance(migrationInstruction, element, compensationHandler, targetScope);

            parseContext.consume(element);

            return(migratingCompensationInstance);
        }
Esempio n. 20
0
 public virtual void parseDependentInstances(MigratingInstanceParseContext parseContext, MigratingActivityInstance migratingInstance)
 {
     parseContext.handleDependentVariables(migratingInstance, collectActivityInstanceVariables(migratingInstance));
     parseContext.handleDependentActivityInstanceJobs(migratingInstance, collectActivityInstanceJobs(migratingInstance));
     parseContext.handleDependentEventSubscriptions(migratingInstance, collectActivityInstanceEventSubscriptions(migratingInstance));
 }