protected internal override void InstantiateScopes(MigratingScopeInstance ancestorScopeInstance,
                                                           MigratingScopeInstanceBranch executionBranch, IList <ScopeImpl> scopesToInstantiate)
        {
            if (scopesToInstantiate.Count == 0)
            {
                return;
            }

            var ancestorScopeExecution = ancestorScopeInstance.ResolveRepresentativeExecution();

            var parentExecution = ancestorScopeExecution;

            foreach (var scope in scopesToInstantiate)
            {
                var compensationScopeExecution = parentExecution.CreateExecution();
                compensationScopeExecution.IsScope      = true;
                compensationScopeExecution.IsEventScope = true;

                //compensationScopeExecution.setActivity((IPvmActivity) scope);
                compensationScopeExecution.IsActive = false;
                //compensationScopeExecution.activityInstanceStarting();
                //compensationScopeExecution.enterActivityInstance();

                //EventSubscriptionEntity eventSubscription = EventSubscriptionEntity.createAndInsert(parentExecution,
                //    EventType.COMPENSATE, (ActivityImpl) scope);
                //eventSubscription.Configuration = compensationScopeExecution.Id;

                //executionBranch.visited(new MigratingEventScopeInstance(eventSubscription, compensationScopeExecution,
                //    scope));

                parentExecution = compensationScopeExecution;
            }
        }
        /// <summary>
        ///     Returns a list of flow scopes from the given scope until a scope is reached that is already present in the given
        ///     <seealso cref="MigratingScopeInstanceBranch" /> (exclusive). The order of the returned list is top-down, i.e. the
        ///     highest scope
        ///     is the first element of the list.
        /// </summary>
        //JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        //ORIGINAL LINE: protected java.Util.List<org.camunda.bpm.engine.impl.Pvm.Process.ScopeImpl> collectNonExistingFlowScopes(org.camunda.bpm.engine.impl.Pvm.Process.ScopeImpl scope, final MigratingScopeInstanceBranch migratingExecutionBranch)
        protected internal virtual IList <ScopeImpl> CollectNonExistingFlowScopes(ScopeImpl scope,
                                                                                  MigratingScopeInstanceBranch migratingExecutionBranch)
        {
            var walker = new FlowScopeWalker(scope);
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final java.Util.List<org.camunda.bpm.engine.impl.Pvm.Process.ScopeImpl> result = new java.Util.LinkedList<org.camunda.bpm.engine.impl.Pvm.Process.ScopeImpl>();
            IList <ScopeImpl> result = new List <ScopeImpl>();

            walker.AddPreVisitor(new TreeVisitorAnonymousInnerClass(this, result));

            //walker.walkWhile(new WalkConditionAnonymousInnerClass(this, migratingExecutionBranch));

            return(result);
        }
        protected internal virtual void MigrateProcessElementInstance(MigratingProcessElementInstance migratingInstance,
                                                                      MigratingScopeInstanceBranch migratingInstanceBranch)
        {
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final MigratingScopeInstance parentMigratingInstance = migratingInstance.Parent;
            var parentMigratingInstance = migratingInstance.Parent;

            var sourceScope     = migratingInstance.SourceScope;
            var targetScope     = migratingInstance.TargetScope;
            var targetFlowScope = targetScope.FlowScope;
            var parentActivityInstanceTargetScope = parentMigratingInstance != null
                ? parentMigratingInstance.TargetScope
                : null;

            if ((sourceScope != sourceScope.ProcessDefinition) && (targetFlowScope != parentActivityInstanceTargetScope))
            {
                // create intermediate scopes

                // 1. manipulate execution tree

                // determine the list of ancestor scopes (parent, grandparent, etc.) for which
                //     no executions exist yet
                var nonExistingScopes = CollectNonExistingFlowScopes(targetFlowScope, migratingInstanceBranch);

                // get the closest ancestor scope that is instantiated already
                var existingScope = nonExistingScopes.Count == 0 ? targetFlowScope : nonExistingScopes[0].FlowScope;

                // and its scope instance
                var ancestorScopeInstance = migratingInstanceBranch.GetInstance(existingScope);

                // Instantiate the scopes as children of the scope execution
                InstantiateScopes(ancestorScopeInstance, migratingInstanceBranch, nonExistingScopes);

                var targetFlowScopeInstance = migratingInstanceBranch.GetInstance(targetFlowScope);

                // 2. detach instance
                // The order of steps 1 and 2 avoids intermediate execution tree compaction
                // which in turn could overwrite some dependent instances (e.g. variables)
                migratingInstance.DetachState();

                // 3. attach to newly created activity instance
                migratingInstance.AttachState(targetFlowScopeInstance);
            }

            // 4. update state (e.g. activity id)
            migratingInstance.MigrateState();

            // 5. migrate instance state other than execution-tree structure
            migratingInstance.MigrateDependentEntities();
        }
Exemple #4
0
        protected internal override ICollection <MigrationContext> NextElements()
        {
            ICollection <MigrationContext> nextElements = new LinkedList <MigrationContext>();

            var currentElement = CurrentElement;

            // continue migration for non-leaf instances (i.e. scopes)
            if (currentElement.processElementInstance is MigratingScopeInstance)
            {
                // Child instances share the same scope instance branch;
                // This ensures "once-per-parent" instantiation semantics,
                // i.e. if a new parent scope is added to more than one child, all those children
                // will share the same new parent instance.
                // By changing the way how the branches are created here, it should be possible
                // to implement other strategies, e.g. "once-per-child" semantics
                var childrenScopeBranch             = currentElement.scopeInstanceBranch.Copy();
                var childrenCompensationScopeBranch = currentElement.scopeInstanceBranch.Copy();

                var scopeInstance = (MigratingScopeInstance)currentElement.processElementInstance;

                childrenScopeBranch.Visited(scopeInstance);
                childrenCompensationScopeBranch.Visited(scopeInstance);

                foreach (var child in scopeInstance.Children)
                {
                    MigratingScopeInstanceBranch instanceBranch = null;

                    // compensation and non-compensation scopes cannot share the same scope instance branch
                    // e.g. when adding a sub process, we want to create a new activity instance as well
                    // as a new event scope instance for that sub process
                    if (child is MigratingEventScopeInstance || child is MigratingCompensationEventSubscriptionInstance)
                    {
                        instanceBranch = childrenCompensationScopeBranch;
                    }
                    else
                    {
                        instanceBranch = childrenScopeBranch;
                    }
                    nextElements.Add(new MigrationContext(child, instanceBranch));
                }
            }

            return(nextElements);
        }
Exemple #5
0
        protected internal override void InstantiateScopes(MigratingScopeInstance ancestorScopeInstance,
                                                           MigratingScopeInstanceBranch executionBranch, IList <ScopeImpl> scopesToInstantiate)
        {
            if (scopesToInstantiate.Count == 0)
            {
                return;
            }

            // must always be an activity instance
            var ancestorActivityInstance = (MigratingActivityInstance)ancestorScopeInstance;

            var newParentExecution = ancestorActivityInstance.CreateAttachableExecution();

            //IDictionary<IPvmActivity, PvmExecutionImpl> createdExecutions =
            //    newParentExecution.instantiateScopes((IList) scopesToInstantiate, skipCustomListeners, skipIoMappings);

            //foreach (var scope in scopesToInstantiate)
            //{
            //    var createdExecution = (ExecutionEntity) createdExecutions[scope];
            //    createdExecution.setActivity(null);
            //    createdExecution.Active = false;
            //    executionBranch.visited(new MigratingActivityInstance(scope, createdExecution));
            //}
        }
Exemple #6
0
 public MigrationContext(MigratingProcessElementInstance processElementInstance,
                         MigratingScopeInstanceBranch scopeInstanceBranch)
 {
     this.processElementInstance = processElementInstance;
     this.scopeInstanceBranch    = scopeInstanceBranch;
 }
 protected internal abstract void InstantiateScopes(MigratingScopeInstance ancestorScopeInstance,
                                                    MigratingScopeInstanceBranch executionBranch, IList <ScopeImpl> scopesToInstantiate);