using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BismNormalizer.TabularCompare.TabularMetadata { /// /// Represents a link in a relationship chain, used to detect ambiguity in relationship paths. /// public class RelationshipLink { private Table _beginTable; private Table _endTable; private bool _root; private bool _biDiInvoked; private string _tablePath; private bool _precedingPathBiDiInvoked; private Relationship _filteringRelationship; /// /// Initializes a new instance of the RelationshipLink class using multiple parameters. /// /// Table object representing begin table. /// Table object representing end table. /// Boolean indicating if the root link in a the relationship chain. /// Recursive path to the preceding table in the relationship chain. /// Relationship object for the relationship link. public RelationshipLink(Table beginTable, Table endTable, bool root, string precedingTablePath, bool precedingPathBiDiInvoked, Relationship filteringRelationship, bool biDiInvoked) { _beginTable = beginTable; _endTable = endTable; _root = root; _biDiInvoked = biDiInvoked; if (root) { //_tablePath = $"'{beginTable.Name}'->{(biDi ? "(BiDi)" : "")}'{endTable.Name}'"; _tablePath = $"'{beginTable.Name}'->'{endTable.Name}'"; } else { //_tablePath = $"{precedingTablePath}->{(biDi ? "(BiDi)" : "")}'{endTable.Name}'"; _tablePath = $"{precedingTablePath}->'{endTable.Name}'"; } _precedingPathBiDiInvoked = (precedingPathBiDiInvoked || biDiInvoked); _filteringRelationship = filteringRelationship; } /// /// BeginTable might be the From or the To table in TOM Relationship object; it depends on CrossFilterDirection and specific relationship direction. /// public Table BeginTable => _beginTable; /// /// EndTable might be the From or the To table in TOM Relationship object; it depends on CrossFilterDirection and specific relationship direction. /// public Table EndTable => _endTable; /// /// Boolean indicating if the root link in a the relationship chain. /// public bool Root => _root; /// /// Boolean indicating if the relationship is BiDi and traversing from the many to the one side. /// public bool BiDiInvoked => _biDiInvoked; /// /// Recursive path to the preceding table in the relationship chain. /// public string TablePath => _tablePath; /// /// Boolean indicating if the relationship is BiDi and traversing from the many to the one side. /// public bool PrecedingPathBiDiInvoked => _precedingPathBiDiInvoked; /// /// Relationship object for the relationship link. /// public Relationship FilteringRelationship => _filteringRelationship; public override string ToString() => _tablePath; } }