public static SearchAttribute GetSearchAttribute(SearchAttributeViewModel searchAttributeViewModel) { SearchAttribute sa = new SearchAttribute(); //names sa.displayName = searchAttributeViewModel.displayName; sa.sourceName = Regex.Replace(searchAttributeViewModel.displayName, "[^0-9a-zA-Z]+", ""); sa.metadataName = String.Join(",", searchAttributeViewModel.metadataNames.Where(x => !string.IsNullOrEmpty(x)).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); }
//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; } } }