private void CombineLinkedSplitNodes() { List <SequenceFlow> sequenceFlows = trail.GetSequenceFlowsBetweenSplitNodes(); Queue <SequenceFlow> seqQueue = new Queue <SequenceFlow>(); sequenceFlows.ForEach(seqQueue.Enqueue); SequenceFlow curr = null; ExclusiveGateway firstEg = null; ExclusiveGateway secondEg = null; while (seqQueue.Count > 0) { curr = seqQueue.Dequeue(); firstEg = trail.GetExclusiveGateWay(curr.sourceRef); secondEg = trail.GetExclusiveGateWay(curr.targetRef); secondEg.outgoing.ForEach(x => { firstEg.outgoing.Add(x); trail.ChangeSourceRefOnSequenceFlow(x, firstEg.id); }); secondEg.outgoing.RemoveAll(x => true); trail.RemoveEventWithSequences(secondEg.id); } }
private BPMNTrail FixMergeGateLocationsInRepeatedSequences(List <string> repSeq, Tuple <int, List <int> > startLocs, List <string> trace, BPMNTrail workingTrail) { string idString = string.Empty; List <string> repSeqIds = new List <string>(); List <string> ids = new List <string>(); for (int i = 0; i < repSeq.Count + startLocs.Item1; i++) { idString += trace[i]; if (i >= startLocs.Item1) { repSeqIds.Add(idString); } } if (!(repSeqIds[0] + repSeqIds[0]).Equals(repSeqIds[1])) { foreach (int pos in startLocs.Item2) { idString = string.Empty; for (int i = 0; i < pos + repSeq.Count; i++) { idString += trace[i]; if (i >= pos) { ids.Add(idString); } } } Task current = workingTrail.GetTask(repSeqIds.Last <string>()); Task helperTask1 = null; Task helperTask2 = null; ExclusiveGateway eg = null; SequenceFlow seqFlow = null; int index = 0; string nextId = ids[0]; string helper = string.Empty; while (!current.id.Equals(ids.Last <string>())) { helper = workingTrail.GetSequenceFlow(current.outgoing[0]).targetRef; if (helper.Equals(nextId)) { if (!nextId.Equals(ids.Last <string>())) { nextId = ids[index += 1]; } current = workingTrail.GetTask(helper); } else if (workingTrail.ExclusiveGatewayExists(helper)) { eg = workingTrail.GetExclusiveGateWay(helper); foreach (string s in eg.outgoing) { helper = workingTrail.GetSequenceFlow(s).targetRef; if (helper.Equals(nextId)) { seqFlow = workingTrail.GetSequenceFlow(s); helperTask1 = workingTrail.GetTask(helper); helperTask2 = workingTrail.GetTaskByNameIfIdInList(helperTask1.name, repSeqIds); if (!repSeqIds.Contains(current.id)) { workingTrail.MoveMergeGate(eg.id, workingTrail.GetSequenceFlowByTargetRefId(helperTask2.id).sourceRef, helperTask1.id); } if (!nextId.Equals(ids.Last <string>())) { nextId = ids[index += 1]; } current = helperTask1; break; } } } } } return(workingTrail); }