protected internal virtual void writeTree(StringWriter writer, string prefix, bool isTail) { writer.append(prefix); if (isTail) { writer.append("└── "); } else { writer.append("├── "); } writer.append(ActivityId + "=>" + Id + "\n"); for (int i = 0; i < childTransitionInstances.Length; i++) { TransitionInstance transitionInstance = childTransitionInstances[i]; bool transitionIsTail = (i == (childTransitionInstances.Length - 1)) && (childActivityInstances.Length == 0); writeTransition(transitionInstance, writer, prefix + (isTail ? " " : "│ "), transitionIsTail); } for (int i = 0; i < childActivityInstances.Length; i++) { ActivityInstanceImpl child = (ActivityInstanceImpl)childActivityInstances[i]; child.writeTree(writer, prefix + (isTail ? " " : "│ "), (i == (childActivityInstances.Length - 1))); } }
public MigratingTransitionInstance(TransitionInstance transitionInstance, MigrationInstruction migrationInstruction, ScopeImpl sourceScope, ScopeImpl targetScope, ExecutionEntity asyncExecution) { this.transitionInstance = transitionInstance; this.migrationInstruction = migrationInstruction; this.sourceScope = sourceScope; this.targetScope = targetScope; this.currentScope = sourceScope; this.representativeExecution = asyncExecution; this.activeState = representativeExecution.Active; }
public static TransitionInstanceDto fromTransitionInstance(TransitionInstance instance) { TransitionInstanceDto result = new TransitionInstanceDto(); result.id = instance.Id; result.parentActivityInstanceId = instance.ParentActivityInstanceId; result.activityId = instance.ActivityId; result.activityName = instance.ActivityName; result.activityType = instance.ActivityType; result.processInstanceId = instance.ProcessInstanceId; result.processDefinitionId = instance.ProcessDefinitionId; result.executionId = instance.ExecutionId; return(result); }
protected internal virtual void writeTransition(TransitionInstance transition, StringWriter writer, string prefix, bool isTail) { writer.append(prefix); if (isTail) { writer.append("└── "); } else { writer.append("├── "); } writer.append("transition to/from " + transition.ActivityId + ":" + transition.Id + "\n"); }
public void TransitionInstance_With_Zero_Duration_Is_Completed_On_First_Tick() { var clock = new TestClock(); int i = 0; var inst = new TransitionInstance(clock, TimeSpan.Zero, TimeSpan.Zero).Subscribe(nextValue => { switch (i++) { case 0: Assert.Equal(0, nextValue); break; case 1: Assert.Equal(1d, nextValue); break; } }); clock.Pulse(TimeSpan.FromMilliseconds(10)); }
protected internal virtual bool matchesRequestedTransitionInstance(TransitionInstance instance, string queryInstanceId) { bool match = instance.Id.Equals(queryInstanceId); // check if the execution queried for has been replaced by the given instance // => if yes, given instance is matched // this is a fix for CAM-4090 to tolerate inconsistent transition instance ids as described in CAM-4143 if (!match) { // note: execution id = transition instance id ExecutionEntity cachedExecution = Context.CommandContext.DbEntityManager.getCachedEntity(typeof(ExecutionEntity), queryInstanceId); // follow the links of execution replacement; // note: this can be at most two hops: // case 1: // the query execution is the scope execution // => tree may have expanded meanwhile // => scope execution references replacing execution directly (one hop) // // case 2: // the query execution is a concurrent execution // => tree may have compacted meanwhile // => concurrent execution references scope execution directly (one hop) // // case 3: // the query execution is a concurrent execution // => tree may have compacted/expanded/compacted/../expanded any number of times // => the concurrent execution has been removed and therefore references the scope execution (first hop) // => the scope execution may have been replaced itself again with another concurrent execution (second hop) // note that the scope execution may have a long "history" of replacements, but only the last replacement is relevant here if (cachedExecution != null) { ExecutionEntity replacingExecution = cachedExecution.resolveReplacedBy(); if (replacingExecution != null) { match = replacingExecution.Id.Equals(instance.Id); } } } return(match); }
public void TransitionInstance_With_Zero_Duration_Is_Completed_On_First_Tick() { var clock = new MockGlobalClock(); using (UnitTestApplication.Start(new TestServices(globalClock: clock))) { int i = 0; var inst = new TransitionInstance(clock, TimeSpan.Zero).Subscribe(nextValue => { switch (i++) { case 0: Assert.Equal(0, nextValue); break; case 1: Assert.Equal(1d, nextValue); break; } }); clock.Pulse(TimeSpan.FromMilliseconds(10)); } }
protected internal virtual TransitionInstance findTransitionInstance(ActivityInstance tree, string transitionInstanceId) { foreach (TransitionInstance childTransitionInstance in tree.ChildTransitionInstances) { if (matchesRequestedTransitionInstance(childTransitionInstance, transitionInstanceId)) { return(childTransitionInstance); } } foreach (ActivityInstance child in tree.ChildActivityInstances) { TransitionInstance matchingChildInstance = findTransitionInstance(child, transitionInstanceId); if (matchingChildInstance != null) { return(matchingChildInstance); } } return(null); }
public void TransitionInstance_Properly_Calculates_Delay_And_Duration_Values() { var clock = new TestClock(); int i = -1; var inst = new TransitionInstance(clock, TimeSpan.FromMilliseconds(30), TimeSpan.FromMilliseconds(70)).Subscribe(nextValue => { switch (i++) { case 0: Assert.Equal(0, nextValue); break; case 1: Assert.Equal(0, nextValue); break; case 2: Assert.Equal(0, nextValue); break; case 3: Assert.Equal(0, nextValue); break; case 4: Assert.Equal(Math.Round(10d / 70d, 4), Math.Round(nextValue, 4)); break; case 5: Assert.Equal(Math.Round(20d / 70d, 4), Math.Round(nextValue, 4)); break; case 6: Assert.Equal(Math.Round(30d / 70d, 4), Math.Round(nextValue, 4)); break; case 7: Assert.Equal(Math.Round(40d / 70d, 4), Math.Round(nextValue, 4)); break; case 8: Assert.Equal(Math.Round(50d / 70d, 4), Math.Round(nextValue, 4)); break; case 9: Assert.Equal(Math.Round(60d / 70d, 4), Math.Round(nextValue, 4)); break; case 10: Assert.Equal(1d, nextValue); break; } }); for (int z = 0; z <= 10; z++) { clock.Pulse(TimeSpan.FromMilliseconds(10)); } }
public virtual void handleTransitionInstance(TransitionInstance transitionInstance) { parser.TransitionInstanceHandler.handle(this, transitionInstance); }
public virtual MigratingTransitionInstance addTransitionInstance(MigrationInstruction migrationInstruction, TransitionInstance transitionInstance, ScopeImpl sourceScope, ScopeImpl targetScope, ExecutionEntity asyncExecution) { MigratingTransitionInstance migratingTransitionInstance = new MigratingTransitionInstance(transitionInstance, migrationInstruction, sourceScope, targetScope, asyncExecution); migratingTransitionInstances.Add(migratingTransitionInstance); return(migratingTransitionInstance); }
/// <summary> /// if anyone wants to improve this algorithm, feel welcome! </summary> protected internal virtual bool isTreeMatched(ActivityInstance expectedInstance, ActivityInstance actualInstance) { if (!expectedInstance.ActivityId.Equals(actualInstance.ActivityId) || (!string.ReferenceEquals(expectedInstance.Id, null) && !expectedInstance.Id.Equals(actualInstance.Id))) { return(false); } else { if (expectedInstance.ChildActivityInstances.Length != actualInstance.ChildActivityInstances.Length) { return(false); } else { IList <ActivityInstance> unmatchedInstances = new List <ActivityInstance>(Arrays.asList(expectedInstance.ChildActivityInstances)); foreach (ActivityInstance actualChild in actualInstance.ChildActivityInstances) { bool matchFound = false; foreach (ActivityInstance expectedChild in new List <ActivityInstance>(unmatchedInstances)) { if (isTreeMatched(expectedChild, actualChild)) { unmatchedInstances.Remove(actualChild); matchFound = true; break; } } if (!matchFound) { return(false); } } if (expectedInstance.ChildTransitionInstances.Length != actualInstance.ChildTransitionInstances.Length) { return(false); } IList <TransitionInstance> unmatchedTransitionInstances = new List <TransitionInstance>(Arrays.asList(expectedInstance.ChildTransitionInstances)); foreach (TransitionInstance child in actualInstance.ChildTransitionInstances) { IEnumerator <TransitionInstance> expectedTransitionInstanceIt = unmatchedTransitionInstances.GetEnumerator(); bool matchFound = false; while (expectedTransitionInstanceIt.MoveNext() && !matchFound) { TransitionInstance expectedChild = expectedTransitionInstanceIt.Current; if (expectedChild.ActivityId.Equals(child.ActivityId)) { matchFound = true; //JAVA TO C# CONVERTER TODO TASK: .NET enumerators are read-only: expectedTransitionInstanceIt.remove(); } } if (!matchFound) { return(false); } } } return(true); } }