public override void RemoveParent(TermNode Parent) { if (!(Parent is TermNodeWithGuid)) { throw new NotSupportedException(); } Parents.Remove((Parent as TermNodeWithGuid).GUID); }
public bool Equals(TermNode tn) { if (tn == null) { return(false); } return(GetContent().Equals(tn.GetContent())); }
public override bool IsChildOf(TermNode AnotherTermNode) { if (!(AnotherTermNode is TermNodeWithGuid)) { return(GetSubject().IsSubsetOf(AnotherTermNode.GetSubject())); } else { return(this.Parents.Contains(((TermNodeWithGuid)AnotherTermNode).GUID)); } }
public override bool Overlaps(TermNode AnotherTermNode) { if (this.Parents.Overlaps(((TermNodeWithGuid)AnotherTermNode).Parents)) { return(true); } return(base.Overlaps(AnotherTermNode)); // DISABLING THE FOLLOWING DUE TO CHICKEN AND EGG PROBLEM //if (!(AnotherTermNode is TermNodeWithGuid)) // return GetSubject().Overlaps(AnotherTermNode.GetSubject()); //else // return this.Parents.Overlaps(((TermNodeWithGuid)AnotherTermNode).Parents); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj.GetType() != typeof(TermNode)) { return(false); } TermNode tn = obj as TermNode; return(this.Equals(tn)); }
public bool Add(ITerm <Value> Term, Dictionary <long, RiskItemCharacteristicIDAttributes> CoverageIdAttrMap, Dictionary <string, HashSet <long> > ResolvedSchedule, bool CheckForPerRisk = true) { Subject NodeIdentity = Term.GetSubject(); bool IsAddSuccessful = true; if (NodeIdentity == null) { NodeIdentity = EMPTYSUBJECTCONSTRAINT; } TermCollection TermCollection = (IdentityMap.ContainsKey(NodeIdentity) ? IdentityMap[NodeIdentity].GetContent() : new TermCollection(NodeIdentity)); // Switching off the following check intentionally, in order to allow redundant terms //if (TermCollection.Contains(Term)) // throw new ArgumentException("A term node with the same identity (i.e. subject) already contains this term in its collection!"); IsAddSuccessful = TermCollection.Add(Term); if (IsAddSuccessful && !IdentityMap.ContainsKey(NodeIdentity)) { TermNode _TermNode = new TermNode(TermCollection); IsAddSuccessful &= base.Add(_TermNode); if (IsAddSuccessful) { IdentityMap.Add(NodeIdentity, _TermNode); // A newly added term node (i.e. with no parent or child links) is both a root and a leaf, trivially. IsAddSuccessful &= RootNodes.Add(_TermNode); ExecutionState.RegisterModificationInGraphTopology(); } } return(IsAddSuccessful); }
public override bool OverlapsWithoutInclusion(TermNode AnotherTermNode) { if (!this.Parents.IsSubsetOf(((TermNodeWithGuid)AnotherTermNode).Parents) && !((TermNodeWithGuid)AnotherTermNode).Parents.IsSubsetOf(this.Parents) && this.Parents.Overlaps(((TermNodeWithGuid)AnotherTermNode).Parents)) { return(true); } return(base.OverlapsWithoutInclusion(AnotherTermNode)); // DISABLING THE FOLLOWING DUE TO CHICKEN AND EGG PROBLEM //if (!(AnotherTermNode is TermNodeWithGuid)) // return GetSubject().OverlapsWithoutInclusion(AnotherTermNode.GetSubject()); //else //{ // if (this.IsChildOf(((TermNodeWithGuid)AnotherTermNode))) // return false; // if (((TermNodeWithGuid)AnotherTermNode).IsChildOf(this)) // return false; // return this.Overlaps(AnotherTermNode); //} }
private void SetDistinctPerRiskNodes() { for (int i = 0; i < OriginalPerRiskNodes.Count(); i++) { TermNode TermNodeI = OriginalPerRiskNodes[i]; Subject sI = TermNodeI.GetContent().GetSubject(); #region Compare to original per risk nodes for (int j = i + 1; j < OriginalPerRiskNodes.Count(); j++) { TermNode TermNodeJ = OriginalPerRiskNodes[j]; Subject sJ = TermNodeJ.GetContent().GetSubject(); if (OriginalSubjectRelationshipMatrix[sI.ID, sJ.ID] == SubjectComparisonOutcome.Equal) { TermNodeJ.GetContent().UnionWith(TermNodeI.GetContent()); DistinctPerRiskNodes.Remove(TermNodeI); } else if (CompareSubjectDimensions(sI.CausesOfLoss, sJ.CausesOfLoss) == SubjectComparisonOutcome.Equal && CompareSubjectDimensions(sI.ResolvedExposureTypes, sJ.ResolvedExposureTypes) == SubjectComparisonOutcome.Equal) { if (OriginalSubjectRelationshipMatrix[sI.ID, sJ.ID] == SubjectComparisonOutcome.Child) { //foreach (RITE rite in s2.Schedule.ScheduleList) //{ // RiteDedsAddition[s1.ID].Add(rite, tNode2.Deductibles); // RiteLimitsAddition[s1.ID].Add(rite, tNode2.Limits); //} DistinctPerRiskNodes.Remove(TermNodeJ); } else if (OriginalSubjectRelationshipMatrix[sI.ID, sJ.ID] == SubjectComparisonOutcome.Parent) { //foreach (RITE rite in s1.Schedule.ScheduleList) //{ // RiteDedsAddition[s2.ID].Add(rite, tNode1.Deductibles); // RiteLimitsAddition[s2.ID].Add(rite, tNode1.Limits); //} DistinctPerRiskNodes.Remove(TermNodeI); } else if (OriginalSubjectRelationshipMatrix[sI.ID, sJ.ID] == SubjectComparisonOutcome.Overlap_Child || OriginalSubjectRelationshipMatrix[sI.ID, sJ.ID] == SubjectComparisonOutcome.Overlap_Parent) { } else { ; // TODO : ?????? } } } #endregion Compare to original per risk nodes #region Get RITE singleton original non per risk nodes List <TermNode> OriginalSingletonNonPerRiskNodes = new List <TermNode>(); foreach (TermNode OriginalNonPerRiskNode in OriginalNonPerRiskNodes) { Subject subject = OriginalNonPerRiskNode.GetContent().GetSubject(); if (subject.RITEIds.Count == 1) { OriginalSingletonNonPerRiskNodes.Add(OriginalNonPerRiskNode); } } #endregion #region Compare to singleton non per risk nodes foreach (TermNode OriginalSingletonNonPerRiskNode in OriginalSingletonNonPerRiskNodes) { Subject OriginalSingletonNonPerRiskNodesSubject = OriginalSingletonNonPerRiskNode.GetContent().GetSubject(); if (CompareSubjectDimensions(sI.CausesOfLoss, OriginalSingletonNonPerRiskNodesSubject.CausesOfLoss) == SubjectComparisonOutcome.Equal && CompareSubjectDimensions(sI.ResolvedExposureTypes, OriginalSingletonNonPerRiskNodesSubject.ResolvedExposureTypes) == SubjectComparisonOutcome.Equal) { if (sI.RITEIds.Contains(OriginalSingletonNonPerRiskNodesSubject.RITEIds.First())) { OriginalNonPerRiskNodes.Remove(OriginalSingletonNonPerRiskNode); FinalNodes.Remove(OriginalSingletonNonPerRiskNode); //RiteDedsAddition[s1.ID].Add(s3.Schedule.ScheduleList.First(), tNode3.Deductibles); //RiteLimitsAddition[s1.ID].Add(s3.Schedule.ScheduleList.First(), tNode3.Limits); } } } #endregion Compare to singleton non per risk nodes } }
public TermNodeWithGuid(TermNode TermNode) : base(TermNode) { Init(); }
public virtual void RemoveParent(TermNode Parent) { throw new NotSupportedException(); }
public virtual bool OverlapsWithoutInclusion(TermNode AnotherTermNode) { return(GetSubject().OverlapsWithoutInclusion(AnotherTermNode.GetSubject())); }
public virtual bool Overlaps(TermNode AnotherTermNode) { return(GetSubject().Overlaps(AnotherTermNode.GetSubject())); }
public virtual bool IsChildOf(TermNode AnotherTermNode) { return(GetSubject().IsSubsetOf(AnotherTermNode.GetSubject())); }
public TermNode(TermNode TermNode) : this(TermNode.GetContent()) { IsItMultiBuildingPerRisk = TermNode.IsMultiBuildingPerRisk(); }