private void AddNode(IFsFeatureSpecification spec, FeatureTreeNode parentNode) { IFsFeatDefn defn = spec.FeatureRA; TreeNodeCollection col; if (parentNode == null) { col = Nodes; } else { col = parentNode.Nodes; } IFsClosedValue closed = spec as IFsClosedValue; if (closed != null) { foreach (FeatureTreeNode node in col) { if (defn.Hvo == node.Hvo) { // already there (which is to be expected); see if its value is, too AddNodeFromFS(closed.ValueRA, node); return; } } // did not find the node, so add it and its value (not to be expected, but we'd better deal with it) FeatureTreeNode newNode = new FeatureTreeNode(defn.Name.AnalysisDefaultWritingSystem, (int)ImageKind.feature, (int)ImageKind.feature, defn.Hvo, FeatureTreeNodeInfo.NodeKind.Closed); InsertNode(newNode, parentNode); IFsSymFeatVal val = closed.ValueRA; if (val != null) { FeatureTreeNode newValueNode = new FeatureTreeNode(val.Name.AnalysisDefaultWritingSystem, (int)ImageKind.radioSelected, (int)ImageKind.radioSelected, val.Hvo, FeatureTreeNodeInfo.NodeKind.SymFeatValue); newValueNode.Chosen = true; InsertNode(newValueNode, newNode); } } IFsComplexValue complex = spec as IFsComplexValue; if (complex != null) { foreach (FeatureTreeNode node in col) { if (defn.Hvo == node.Hvo) { // already there (which is to be expected); see if its value is, too AddNode((IFsFeatStruc)complex.ValueOA, node); return; } } // did not find the node, so add it and its value (not to be expected, but we'd better deal with it) FeatureTreeNode newNode = new FeatureTreeNode(defn.Name.AnalysisDefaultWritingSystem, (int)ImageKind.complex, (int)ImageKind.complex, defn.Hvo, FeatureTreeNodeInfo.NodeKind.Complex); InsertNode(newNode, parentNode); AddNode((IFsFeatStruc)complex.ValueOA, newNode); } }
/// <summary> /// Builds the feature structure based on the items chosen /// </summary> /// <returns></returns> private void BuildFeatureStructure(int hvoClosedFeature, int hvoValue, ref IFsFeatureSpecification val) { val = (IFsClosedValue)m_fs.FindOrCreateClosedValue(hvoClosedFeature); val.FeatureRAHvo = hvoClosedFeature; IFsClosedValue closed = val as IFsClosedValue; if (closed != null) { closed.ValueRAHvo = hvoValue; } }
/// <summary> /// Makes the feature structure reflect the values chosen /// </summary> /// <remarks>Is public for Unit Testing</remarks> public void UpdateFeatureStructure() { CheckDisposed(); List <int> featureHvos = m_bvList.AllItems; foreach (int hvoClosedFeature in featureHvos) { int hvoDummy = m_cache.GetObjProperty(hvoClosedFeature, m_flidDummyValue); if (hvoDummy > 0) { IFsFeatureSpecification val = null; BuildFeatureStructure(hvoClosedFeature, hvoDummy, ref val); } } }
/// <summary> /// Makes the feature structure reflect the values chosen in the treeview /// </summary> /// <remarks>Is public for Unit Testing</remarks> /// <param name="col">collection of nodes at this level</param> public void UpdateFeatureStructure(TreeNodeCollection col) { CheckDisposed(); foreach (FeatureTreeNode tn in col) { if (tn.Nodes.Count > 0) { UpdateFeatureStructure(tn.Nodes); } else if (tn.Chosen && (0 != tn.Hvo)) { var fs = m_fs; IFsFeatureSpecification val = null; // add any terminal nodes to db BuildFeatureStructure(tn, ref fs, ref val); } } }
private static XElement ExportFeatureSpecification(IFsFeatureSpecification featureSpec) { switch (featureSpec.ClassName) { default: // These are not supported as of 14 November 2009. // FsOpenValue // FsDisjunctiveValue // FsSharedValue throw new ArgumentException("Unrecognized feature specification"); case "FsClosedValue": var closedValue = (IFsClosedValue) featureSpec; return new XElement("FsClosedValue", new XAttribute("Id", closedValue.Hvo), CreateAttribute("Value", closedValue.ValueRA), CreateAttribute("Feature", closedValue.FeatureRA)); case "FsComplexValue": var complexValue = (IFsComplexValue)featureSpec; return new XElement("FsComplexValue", new XAttribute("Id", complexValue.Hvo), CreateAttribute("Feature", complexValue.FeatureRA), ExportFeatureStructure(complexValue.ValueOA)); case "FsNegatedValue": var negatedValue = (IFsNegatedValue)featureSpec; return new XElement("FsNegatedValue", new XAttribute("Id", negatedValue.Hvo), CreateAttribute("Value", negatedValue.ValueRA), CreateAttribute("Feature", negatedValue.FeatureRA)); } }
private void AddNode(IFsFeatureSpecification spec, FeatureTreeNode parentNode) { var defn = spec.FeatureRA; TreeNodeCollection col; if (parentNode == null) col = Nodes; else col = parentNode.Nodes; var closed = spec as IFsClosedValue; if (closed != null) { foreach (FeatureTreeNode node in col) { if (defn.Hvo == node.Hvo) { // already there (which is to be expected); see if its value is, too AddNodeFromFS(closed.ValueRA, node); return; } } // did not find the node, so add it and its value (not to be expected, but we'd better deal with it) FeatureTreeNode newNode = new FeatureTreeNode(defn.Name.AnalysisDefaultWritingSystem.Text, (int)ImageKind.feature, (int)ImageKind.feature, defn.Hvo, FeatureTreeNodeInfo.NodeKind.Closed); InsertNode(newNode, parentNode); var val = closed.ValueRA; if (val != null) { FeatureTreeNode newValueNode = new FeatureTreeNode(val.Name.AnalysisDefaultWritingSystem.Text, (int)ImageKind.radioSelected, (int)ImageKind.radioSelected, val.Hvo, FeatureTreeNodeInfo.NodeKind.SymFeatValue); newValueNode.Chosen = true; InsertNode(newValueNode, newNode); } } var complex = spec as IFsComplexValue; if (complex != null) { foreach (FeatureTreeNode node in col) { if (defn.Hvo == node.Hvo) { // already there (which is to be expected); see if its value is, too AddNode((IFsFeatStruc)complex.ValueOA, node); return; } } // did not find the node, so add it and its value (not to be expected, but we'd better deal with it) FeatureTreeNode newNode = new FeatureTreeNode(defn.Name.AnalysisDefaultWritingSystem.Text, (int)ImageKind.complex, (int)ImageKind.complex, defn.Hvo, FeatureTreeNodeInfo.NodeKind.Complex); InsertNode(newNode, parentNode); AddNode((IFsFeatStruc)complex.ValueOA, newNode); } }
/// <summary> /// Recursively builds the feature structure based on contents of treeview node path. /// It recurses back up the treeview node path to the top and then builds the feature structure /// as it goes back down. /// </summary> /// <param name="node"></param> /// <param name="fs"></param> /// <param name="val"></param> /// <returns></returns> private void BuildFeatureStructure(FeatureTreeNode node, ref IFsFeatStruc fs, ref IFsFeatureSpecification val) { if (node.Parent != null) BuildFeatureStructure((FeatureTreeNode)node.Parent, ref fs, ref val); switch (node.Kind) { case FeatureTreeNodeInfo.NodeKind.Complex: var complexFeat = m_cache.ServiceLocator.GetInstance<IFsComplexFeatureRepository>().GetObject(node.Hvo); var complex = fs.GetOrCreateValue(complexFeat); val = complex; val.FeatureRA = complexFeat; if (fs.TypeRA == null) fs.TypeRA = m_cache.LanguageProject.MsFeatureSystemOA.TypesOC.SingleOrDefault(type => type.FeaturesRS.Contains(complexFeat)); fs = (IFsFeatStruc)complex.ValueOA; if (fs.TypeRA == null) { // this is the type of what's being embedded in the fs var cf = val.FeatureRA as IFsComplexFeature; if (cf != null) { fs.TypeRA = cf.TypeRA; } } break; case FeatureTreeNodeInfo.NodeKind.Closed: var closedFeat = m_cache.ServiceLocator.GetInstance<IFsClosedFeatureRepository>().GetObject(node.Hvo); val = fs.GetOrCreateValue(closedFeat); val.FeatureRA = closedFeat; if (fs.TypeRA == null) { // SingleOrDefault() gave an exception if 2 complex features used the same feature (LT-12780) fs.TypeRA = m_cache.LanguageProject.MsFeatureSystemOA.TypesOC.FirstOrDefault(type => type.FeaturesRS.Contains(closedFeat)); } break; case FeatureTreeNodeInfo.NodeKind.SymFeatValue: var closed = val as IFsClosedValue; if (closed != null) closed.ValueRA = m_cache.ServiceLocator.GetInstance<IFsSymFeatValRepository>().GetObject(node.Hvo); break; } }
/// <summary> /// Recursively builds the feature structure based on contents of treeview node path. /// It recurses back up the treeview node path to the top and then builds the feature structure /// as it goes back down. /// </summary> /// <param name="node"></param> /// <param name="fs"></param> /// <param name="val"></param> /// <returns></returns> private void BuildFeatureStructure(FeatureTreeNode node, ref IFsFeatStruc fs, ref IFsFeatureSpecification val) { if (node.Parent != null) { BuildFeatureStructure((FeatureTreeNode)node.Parent, ref fs, ref val); } switch (node.Kind) { case FeatureTreeNodeInfo.NodeKind.Complex: var complexFeat = m_cache.ServiceLocator.GetInstance <IFsComplexFeatureRepository>().GetObject(node.Hvo); var complex = fs.GetOrCreateValue(complexFeat); val = complex; val.FeatureRA = complexFeat; if (fs.TypeRA == null) { fs.TypeRA = m_cache.LanguageProject.MsFeatureSystemOA.TypesOC.SingleOrDefault(type => type.FeaturesRS.Contains(complexFeat)); } fs = (IFsFeatStruc)complex.ValueOA; if (fs.TypeRA == null) { // this is the type of what's being embedded in the fs var cf = val.FeatureRA as IFsComplexFeature; if (cf != null) { fs.TypeRA = cf.TypeRA; } } break; case FeatureTreeNodeInfo.NodeKind.Closed: var closedFeat = m_cache.ServiceLocator.GetInstance <IFsClosedFeatureRepository>().GetObject(node.Hvo); val = fs.GetOrCreateValue(closedFeat); val.FeatureRA = closedFeat; if (fs.TypeRA == null) { // SingleOrDefault() gave an exception if 2 complex features used the same feature (LT-12780) fs.TypeRA = m_cache.LanguageProject.MsFeatureSystemOA.TypesOC.FirstOrDefault(type => type.FeaturesRS.Contains(closedFeat)); } break; case FeatureTreeNodeInfo.NodeKind.SymFeatValue: var closed = val as IFsClosedValue; if (closed != null) { closed.ValueRA = m_cache.ServiceLocator.GetInstance <IFsSymFeatValRepository>().GetObject(node.Hvo); } break; } }
/// <summary> /// True if the two are 'equivalent'. /// </summary> /// <param name="other"></param> /// <returns></returns> public override bool IsEquivalent(IFsFeatureSpecification other) { if (!base.IsEquivalent(other)) return false; return (other as IFsSharedValue).ValueRAHvo == this.ValueRAHvo; }
/// <summary> /// True if the two are 'equivalent'. /// </summary> /// <param name="other"></param> /// <returns></returns> public override bool IsEquivalent(IFsFeatureSpecification other) { if (!base.IsEquivalent(other)) return false; return (other as IFsDisjunctiveValue).ValueRC.IsEquivalent(ValueRC); }
/// <summary> /// True if the two are 'equivalent'. /// Since FdoOpenValue isn't used yet, this is something of a skeleton. We just check /// the analysis writing systems. /// </summary> /// <param name="other"></param> /// <returns></returns> public override bool IsEquivalent(IFsFeatureSpecification other) { if (!base.IsEquivalent(other)) return false; return this.Value.AnalysisDefaultWritingSystem == (other as IFsOpenValue).Value.AnalysisDefaultWritingSystem; }
/// <summary> /// True if the objects are considered equivalent. /// </summary> /// <param name="other"></param> /// <returns></returns> public override bool IsEquivalent(IFsFeatureSpecification other) { if (!base.IsEquivalent(other)) return false; IFsAbstractStructure otherValue = (other as IFsComplexValue).ValueOA; IFsAbstractStructure thisValue = ValueOA; if (otherValue == null && thisValue == null) return true; return otherValue.IsEquivalent(thisValue); }
/// <summary> /// True if the objects are considered equivalent. /// </summary> /// <param name="other"></param> /// <returns></returns> public virtual bool IsEquivalent(IFsFeatureSpecification other) { if (other == null) return false; if (other.GetType() != this.GetType()) return false; IFsFeatureSpecification fs = other as IFsFeatureSpecification; if (fs.RefNumber != this.RefNumber) return false; if (fs.ValueState != this.ValueState) return false; if (fs.FeatureRAHvo != this.FeatureRAHvo) return false; return true; }
/// <summary> /// Recursively builds the feature structure based on contents of treeview node path. /// It recurses back up the treeview node path to the top and then builds the feature structure /// as it goes back down. /// </summary> /// <param name="node"></param> /// <param name="fs"></param> /// <returns></returns> private void BuildFeatureStructure(FeatureTreeNode node, ref IFsFeatStruc fs, ref IFsFeatureSpecification val) { if (node.Parent != null) { BuildFeatureStructure((FeatureTreeNode)node.Parent, ref fs, ref val); } switch (node.Kind) { case FeatureTreeNodeInfo.NodeKind.Complex: IFsComplexValue complex = fs.FindOrCreateComplexValue(node.Hvo); val = complex as FsComplexValue; val.FeatureRAHvo = node.Hvo; if (fs.TypeRA == null) { // this is the type which contains the complex feature fs.TypeRAHvo = FsFeatureSystem.GetTypeFromFsComplexFeature(m_cache, node.Hvo); } fs = (IFsFeatStruc)complex.ValueOA; if (fs.TypeRA == null) { // this is the type of what's being embedded in the fs IFsComplexFeature cf = val.FeatureRA as IFsComplexFeature; if (cf != null) { fs.TypeRA = cf.TypeRA; } } break; case FeatureTreeNodeInfo.NodeKind.Closed: val = (IFsClosedValue)fs.FindOrCreateClosedValue(node.Hvo); val.FeatureRAHvo = node.Hvo; break; case FeatureTreeNodeInfo.NodeKind.SymFeatValue: IFsClosedValue closed = val as IFsClosedValue; if (closed != null) { closed.ValueRAHvo = node.Hvo; } break; default: break; // do nothing } }
/// <summary> /// Recursively builds the feature structure based on contents of treeview node path. /// It recurses back up the treeview node path to the top and then builds the feature structure /// as it goes back down. /// </summary> /// <param name="node"></param> /// <param name="fs"></param> /// <returns></returns> private void BuildFeatureStructure(FeatureTreeNode node, ref IFsFeatStruc fs, ref IFsFeatureSpecification val) { if (node.Parent != null) BuildFeatureStructure((FeatureTreeNode)node.Parent, ref fs, ref val); switch (node.Kind) { case FeatureTreeNodeInfo.NodeKind.Complex: IFsComplexValue complex = fs.FindOrCreateComplexValue(node.Hvo); val = complex as FsComplexValue; val.FeatureRAHvo = node.Hvo; if (fs.TypeRA == null) { // this is the type which contains the complex feature fs.TypeRAHvo = FsFeatureSystem.GetTypeFromFsComplexFeature(m_cache, node.Hvo); } fs = (IFsFeatStruc)complex.ValueOA; if (fs.TypeRA == null) { // this is the type of what's being embedded in the fs IFsComplexFeature cf = val.FeatureRA as IFsComplexFeature; if (cf != null) { fs.TypeRA = cf.TypeRA; } } break; case FeatureTreeNodeInfo.NodeKind.Closed: val = (IFsClosedValue)fs.FindOrCreateClosedValue(node.Hvo); val.FeatureRAHvo = node.Hvo; break; case FeatureTreeNodeInfo.NodeKind.SymFeatValue: IFsClosedValue closed = val as IFsClosedValue; if (closed != null) closed.ValueRAHvo = node.Hvo; break; default: break; // do nothing } }