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();
        }
Example #2
0
 public MigrationContext(MigratingProcessElementInstance processElementInstance,
                         MigratingScopeInstanceBranch scopeInstanceBranch)
 {
     this.processElementInstance = processElementInstance;
     this.scopeInstanceBranch    = scopeInstanceBranch;
 }
 protected internal override bool CanMigrate(MigratingProcessElementInstance instance)
 {
     return(instance is MigratingEventScopeInstance || instance is MigratingCompensationEventSubscriptionInstance);
 }
Example #4
0
 protected internal override bool CanMigrate(MigratingProcessElementInstance instance)
 {
     return(instance is MigratingActivityInstance || instance is MigratingTransitionInstance);
 }
 protected internal abstract bool CanMigrate(MigratingProcessElementInstance instance);