private XmlElement SetAttributesToNode(XmlElement xmlElement, SearchAttribute sa) { // names XmlAttribute xa = this._configXML.CreateAttribute("display_name"); xa.Value = sa.displayName; xmlElement.Attributes.Append(xa); xa = this._configXML.CreateAttribute("lucene_name"); xa.Value = sa.sourceName; xmlElement.Attributes.Append(xa); xa = this._configXML.CreateAttribute("metadata_name"); xa.Value = sa.metadataName; xmlElement.Attributes.Append(xa); //types xa = this._configXML.CreateAttribute("type"); xa.Value = SearchAttribute.GetSearchTypeAsString(sa.searchType); xmlElement.Attributes.Append(xa); xa = this._configXML.CreateAttribute("primitive_type"); xa.Value = SearchAttribute.GetDataTypeAsString(sa.dataType); xmlElement.Attributes.Append(xa); // parameter for index xa = this._configXML.CreateAttribute("store"); xa.Value = SearchAttribute.GetBooleanAsString(sa.store); xmlElement.Attributes.Append(xa); xa = this._configXML.CreateAttribute("multivalued"); xa.Value = SearchAttribute.GetBooleanAsString(sa.multiValue); xmlElement.Attributes.Append(xa); xa = this._configXML.CreateAttribute("analysed"); xa.Value = SearchAttribute.GetBooleanAsString(sa.analysed); xmlElement.Attributes.Append(xa); xa = this._configXML.CreateAttribute("norm"); xa.Value = SearchAttribute.GetBooleanAsString(sa.norm); xmlElement.Attributes.Append(xa); //boost xa = this._configXML.CreateAttribute("boost"); xa.Value = sa.boost.ToString(); xmlElement.Attributes.Append(xa); // ResultView xa = this._configXML.CreateAttribute("header_item"); xa.Value = SearchAttribute.GetBooleanAsString(sa.headerItem); xmlElement.Attributes.Append(xa); xa = this._configXML.CreateAttribute("default_visible_item"); xa.Value = SearchAttribute.GetBooleanAsString(sa.defaultHeaderItem); xmlElement.Attributes.Append(xa); // properties if (sa.searchType.Equals(SearchComponentBaseType.Property)) { xa = this._configXML.CreateAttribute("direction"); xa.Value = SearchAttribute.GetDirectionAsString(sa.direction); xmlElement.Attributes.Append(xa); xa = this._configXML.CreateAttribute("uiComponent"); xa.Value = SearchAttribute.GetUIComponentAsString(sa.uiComponent); xmlElement.Attributes.Append(xa); xa = this._configXML.CreateAttribute("aggregationType"); xa.Value = SearchAttribute.GetAggregationTypeAsString(sa.aggregationType); xmlElement.Attributes.Append(xa); xa = this._configXML.CreateAttribute("date_format"); xa.Value = sa.dateFormat; xmlElement.Attributes.Append(xa); } return xmlElement; }
public static SearchAttributeViewModel GetSearchAttributeViewModel(SearchAttribute searchAttribute) { SearchAttributeViewModel sa = new SearchAttributeViewModel(); sa.id = searchAttribute.id; //names sa.displayName = searchAttribute.displayName; sa.sourceName = searchAttribute.sourceName; sa.metadataNames.AddRange(searchAttribute.metadataName.Split(',')); //types sa.dataType = SearchAttribute.GetDataTypeAsDisplayString(searchAttribute.dataType); sa.searchType = SearchAttribute.GetSearchTypeAsDisplayString(searchAttribute.searchType); // parameter for index sa.store = searchAttribute.store; sa.multiValue = searchAttribute.multiValue; sa.analysed = searchAttribute.analysed; sa.norm = searchAttribute.norm; sa.boost = searchAttribute.boost; // resultview sa.headerItem = searchAttribute.headerItem; sa.defaultHeaderItem = searchAttribute.defaultHeaderItem; // properties sa.direction = SearchAttribute.GetDirectionAsString(searchAttribute.direction); sa.uiComponent = SearchAttribute.GetUIComponentAsString(searchAttribute.uiComponent); sa.aggregationType = SearchAttribute.GetAggregationTypeAsString(searchAttribute.aggregationType); //sa.dateFormat = searchAttribute.dateFormat; return sa; }
//read xml config file private void Load() { this._configXML = new XmlDocument(); this._configXML.Load(FileHelper.ConfigFilePath); XmlNodeList fieldProperties = this._configXML.GetElementsByTagName("field"); int index = 0; foreach (XmlNode fieldProperty in fieldProperties) { if (!fieldProperty.Attributes.GetNamedItem("lucene_name").Value.Equals("Primarydata")) { SearchAttribute sa = new SearchAttribute(); sa.id = index; //Names if (fieldProperty.Attributes.GetNamedItem("display_name") != null) sa.displayName = fieldProperty.Attributes.GetNamedItem("display_name").Value; if (fieldProperty.Attributes.GetNamedItem("lucene_name") != null) sa.sourceName = fieldProperty.Attributes.GetNamedItem("lucene_name").Value; if (fieldProperty.Attributes.GetNamedItem("metadata_name") != null) sa.metadataName = fieldProperty.Attributes.GetNamedItem("metadata_name").Value; //types if (fieldProperty.Attributes.GetNamedItem("type") != null) sa.searchType = SearchAttribute.GetSearchType(fieldProperty.Attributes.GetNamedItem("type").Value); if (fieldProperty.Attributes.GetNamedItem("primitive_type") != null) sa.dataType = SearchAttribute.GetDataType(fieldProperty.Attributes.GetNamedItem("primitive_type").Value); //// parameter for index if (fieldProperty.Attributes.GetNamedItem("store") != null) sa.store = SearchAttribute.GetBoolean(fieldProperty.Attributes.GetNamedItem("store").Value); if (fieldProperty.Attributes.GetNamedItem("multivalued") != null) sa.multiValue = SearchAttribute.GetBoolean(fieldProperty.Attributes.GetNamedItem("multivalued").Value); if (fieldProperty.Attributes.GetNamedItem("analyzed") != null) sa.analysed = SearchAttribute.GetBoolean(fieldProperty.Attributes.GetNamedItem("analyzed").Value); if (fieldProperty.Attributes.GetNamedItem("norm") != null) sa.norm = SearchAttribute.GetBoolean(fieldProperty.Attributes.GetNamedItem("norm").Value); if (fieldProperty.Attributes.GetNamedItem("boost") != null) sa.boost = Convert.ToDouble(fieldProperty.Attributes.GetNamedItem("boost").Value); // Resultview if (fieldProperty.Attributes.GetNamedItem("header_item") != null) sa.headerItem = SearchAttribute.GetBoolean(fieldProperty.Attributes.GetNamedItem("header_item").Value); if (fieldProperty.Attributes.GetNamedItem("default_visible_item") != null) sa.defaultHeaderItem = SearchAttribute.GetBoolean(fieldProperty.Attributes.GetNamedItem("default_visible_item").Value); if (fieldProperty.Attributes.GetNamedItem("direction") != null) sa.direction = SearchAttribute.GetDirection(fieldProperty.Attributes.GetNamedItem("direction").Value); if (fieldProperty.Attributes.GetNamedItem("uiComponent") != null) sa.uiComponent = SearchAttribute.GetUIComponent(fieldProperty.Attributes.GetNamedItem("uiComponent").Value); if (fieldProperty.Attributes.GetNamedItem("aggregationType") != null) sa.aggregationType = SearchAttribute.GetAggregationType(fieldProperty.Attributes.GetNamedItem("aggregationType").Value); if (fieldProperty.Attributes.GetNamedItem("date_format") != null) sa.dateFormat = fieldProperty.Attributes.GetNamedItem("date_format").Value; this._searchAttributeList.Add(sa); index++; } else { this._includePrimaryData = true; } } }
public static SearchAttribute GetSearchAttribute(SearchAttributeViewModel searchAttributeViewModel) { SearchAttribute sa = new SearchAttribute(); //names sa.displayName = searchAttributeViewModel.displayName; sa.sourceName = searchAttributeViewModel.sourceName; sa.metadataName = String.Join(",", searchAttributeViewModel.metadataNames.ToArray()); //types sa.dataType = SearchAttribute.GetDataType(searchAttributeViewModel.dataType); sa.searchType = SearchAttribute.GetSearchType(searchAttributeViewModel.searchType); // parameter for index sa.store = searchAttributeViewModel.store; sa.multiValue = searchAttributeViewModel.multiValue; sa.analysed = searchAttributeViewModel.analysed; sa.norm = searchAttributeViewModel.norm; sa.boost = searchAttributeViewModel.boost; // resultview sa.headerItem = searchAttributeViewModel.headerItem; sa.defaultHeaderItem = searchAttributeViewModel.defaultHeaderItem; // properties sa.direction = SearchAttribute.GetDirection(searchAttributeViewModel.direction); sa.uiComponent = SearchAttribute.GetUIComponent(searchAttributeViewModel.uiComponent); sa.aggregationType = SearchAttribute.GetAggregationType(searchAttributeViewModel.aggregationType); //sa.dateFormat = searchAttributeViewModel.dateFormat; return sa; }