public SobekCM_Search_Object( ) { // Set the default links First_Link = SobekCM_Link_Enum.AND; Second_Link = SobekCM_Link_Enum.AND; Third_Link = SobekCM_Link_Enum.AND; // Set the default terms First_Term = new SobekCM_Term_Enum(); //Settings.SMaRT_UserSettings.Discovery_Panel_Search_Term1; Second_Term = new SobekCM_Term_Enum(); //Settings.SMaRT_UserSettings.Discovery_Panel_Search_Term2; Third_Term = new SobekCM_Term_Enum(); //Settings.SMaRT_UserSettings.Discovery_Panel_Search_Term3; Fourth_Term = new SobekCM_Term_Enum(); //Settings.SMaRT_UserSettings.Discovery_Panel_Search_Term4; // Set the default values First_Value = String.Empty; Second_Value = String.Empty; Third_Value = String.Empty; Fourth_Value = String.Empty; // Set the default aggregation and institutions Aggregation = String.Empty; Institution = String.Empty; // Set default search precision Search_Precision = Search_Precision_Type_Enum.Inflectional_Form; }
/// <summary> Constructor for a new instance of the SobekCM_Item_Discovery_Panel user control </summary> public SobekCM_Item_Discovery_Panel( ) { InitializeComponent(); // Get the list of all terms Array termEnumValues = Enum.GetValues(typeof(SobekCM_Search_Object.SobekCM_Term_Enum)); object[] terms = new object[termEnumValues.Length]; for (int i = 0; i < termEnumValues.Length; i++) { terms[i] = termEnumValues.GetValue(i).ToString().Replace("_", " "); } // Get the list of all links Array linkEnumValues = Enum.GetValues(typeof(SobekCM_Search_Object.SobekCM_Link_Enum)); object[] links = new object[linkEnumValues.Length]; for (int i = 0; i < linkEnumValues.Length; i++) { links[i] = linkEnumValues.GetValue(i).ToString().Replace("_", " ").ToLower(); } // Populate all the terms termComboBox1.Items.AddRange(terms); termComboBox2.Items.AddRange(terms); termComboBox3.Items.AddRange(terms); termComboBox4.Items.AddRange(terms); // Populate all the links linkComboBox2.Items.AddRange(links); linkComboBox3.Items.AddRange(links); linkComboBox4.Items.AddRange(links); searchPrecision = Search_Precision_Type_Enum.Inflectional_Form; Current_Search = new SobekCM_Search_Object(Settings.SMaRT_UserSettings.Discovery_Panel_Search_Term1, Settings.SMaRT_UserSettings.Discovery_Panel_Search_Term2, Settings.SMaRT_UserSettings.Discovery_Panel_Search_Term3, Settings.SMaRT_UserSettings.Discovery_Panel_Search_Term4); if (!Windows_Appearance_Checker.is_XP_Theme) { institutionRadioButton.FlatStyle = FlatStyle.Flat; allRadioButton.FlatStyle = FlatStyle.Flat; collectionRadioButton.FlatStyle = FlatStyle.Flat; institutionComboBox.FlatStyle = FlatStyle.Flat; collectionComboBox.FlatStyle = FlatStyle.Flat; linkComboBox2.FlatStyle = FlatStyle.Flat; linkComboBox3.FlatStyle = FlatStyle.Flat; linkComboBox4.FlatStyle = FlatStyle.Flat; termComboBox1.FlatStyle = FlatStyle.Flat; termComboBox2.FlatStyle = FlatStyle.Flat; termComboBox3.FlatStyle = FlatStyle.Flat; termComboBox4.FlatStyle = FlatStyle.Flat; searchTextBox1.BorderStyle = BorderStyle.FixedSingle; searchTextBox2.BorderStyle = BorderStyle.FixedSingle; searchTextBox3.BorderStyle = BorderStyle.FixedSingle; searchTextBox4.BorderStyle = BorderStyle.FixedSingle; isXp = true; } else { isXp = false; } }
/// <summary> Takes the search string and search fields from the URL and parses them, according to the search type, /// into a collection of terms and a collection of fields. Stop words are also suppressed here </summary> /// <param name="Search_String">Search string from the SobekCM search results URL </param> /// <param name="Search_Fields">Search fields from the SobekCM search results URL </param> /// <param name="Search_Type"> Type of search currently being performed (sets how it is parsed and default index)</param> /// <param name="Output_Terms"> List takes the results of the parsing of the actual search terms </param> /// <param name="Output_Fields"> List takes the results of the parsing of the actual (and implied) search fields </param> /// <param name="Search_Stop_Words"> List of all stop words ignored during metadata searching (such as 'The', 'A', etc..) </param> /// <param name="Search_Precision"> Search precision for this search ( i.e., exact, contains, stemmed, thesaurus lookup )</param> /// <param name="Delimiter_Character"> Character used as delimiter between different components of an advanced search</param> public static void Split_Clean_Search_Terms_Fields(string Search_String, string Search_Fields, Search_Type_Enum Search_Type, List<string> Output_Terms, List<string> Output_Fields, List<string> Search_Stop_Words, Search_Precision_Type_Enum Search_Precision, char Delimiter_Character) { // Find default index string default_index = "ZZ"; if (Search_Type == Search_Type_Enum.Full_Text) default_index = "TX"; // Split the parts string[] fieldSplitTemp = Search_Fields.Split( new[] { Delimiter_Character }); List<string> fieldSplit = new List<string>(); List<string> searchSplit = new List<string>(); int first_index = 0; int second_index = 0; int field_index = 0; bool in_quotes = false; while (second_index < Search_String.Length) { if (in_quotes) { if (Search_String[second_index] == '"') { in_quotes = false; } } else { if (Search_String[second_index] == '"') { in_quotes = true; } else { if (Search_String[second_index] == Delimiter_Character) { if (first_index < second_index) { string possible_add = Search_String.Substring(first_index, second_index - first_index); if (possible_add.Trim().Length > 0) { searchSplit.Add(possible_add); fieldSplit.Add(field_index < fieldSplitTemp.Length ? fieldSplitTemp[field_index] : default_index); } } first_index = second_index + 1; field_index++; } else if (Search_String[second_index] == ' ') { if (first_index < second_index) { string possible_add = Search_String.Substring(first_index, second_index - first_index); if (possible_add.Trim().Length > 0) { searchSplit.Add(possible_add); fieldSplit.Add(field_index < fieldSplitTemp.Length ? fieldSplitTemp[field_index] : default_index); } } first_index = second_index + 1; } } } second_index++; } if ( second_index > first_index ) { searchSplit.Add(Search_String.Substring(first_index)); fieldSplit.Add(field_index < fieldSplitTemp.Length ? fieldSplitTemp[field_index] : default_index); } // If this is basic, do some other preparation if ( Search_Type == Search_Type_Enum.Full_Text ) { Solr_Documents_Searcher.Split_Multi_Terms(Search_String, default_index, Output_Terms, Output_Fields); } else { // For advanced, just add all the terms Output_Terms.AddRange(searchSplit.Select(thisTerm => thisTerm.Trim().Replace("\"", "").Replace("+", " "))); Output_Fields.AddRange(fieldSplit.Select(thisField => thisField.Trim())); } // Some special work for basic searches here if (Search_Type == Search_Type_Enum.Basic) { while (Output_Fields.Count < Output_Terms.Count) { Output_Fields.Add("ZZ"); } } // Now, remove any stop words by themselves if (Search_Stop_Words != null) { int index = 0; while ((index < Output_Terms.Count) && (index < Output_Fields.Count)) { if ((Output_Terms[index].Length == 0) || (Search_Stop_Words.Contains(Output_Terms[index].ToLower()))) { Output_Terms.RemoveAt(index); Output_Fields.RemoveAt(index); } else { if (Search_Precision != Search_Precision_Type_Enum.Exact_Match) { Output_Terms[index] = Output_Terms[index].Replace("\"", "").Replace("+", " ").Replace("&", " ").Replace("&", ""); } if (Output_Fields[index].Length == 0) Output_Fields[index] = default_index; index++; } } } }
/// <summary> Constructor for a new instance of the SobekCM_Item_Discovery_Panel user control </summary> public SobekCM_Item_Discovery_Panel( ) { InitializeComponent(); // Get the list of all terms Array termEnumValues = Enum.GetValues(typeof(SobekCM_Search_Object.SobekCM_Term_Enum)); object[] terms = new object[termEnumValues.Length]; for (int i = 0; i < termEnumValues.Length; i++) { terms[i] = termEnumValues.GetValue(i).ToString().Replace("_"," "); } // Get the list of all links Array linkEnumValues = Enum.GetValues(typeof(SobekCM_Search_Object.SobekCM_Link_Enum)); object[] links = new object[linkEnumValues.Length]; for (int i = 0; i < linkEnumValues.Length; i++) { links[i] = linkEnumValues.GetValue(i).ToString().Replace("_", " ").ToLower(); } // Populate all the terms termComboBox1.Items.AddRange(terms); termComboBox2.Items.AddRange(terms); termComboBox3.Items.AddRange(terms); termComboBox4.Items.AddRange(terms); // Populate all the links linkComboBox2.Items.AddRange(links); linkComboBox3.Items.AddRange(links); linkComboBox4.Items.AddRange(links); searchPrecision = Search_Precision_Type_Enum.Inflectional_Form; Current_Search = new SobekCM_Search_Object(Settings.SMaRT_UserSettings.Discovery_Panel_Search_Term1, Settings.SMaRT_UserSettings.Discovery_Panel_Search_Term2, Settings.SMaRT_UserSettings.Discovery_Panel_Search_Term3, Settings.SMaRT_UserSettings.Discovery_Panel_Search_Term4); if (!Windows_Appearance_Checker.is_XP_Theme) { institutionRadioButton.FlatStyle = FlatStyle.Flat; allRadioButton.FlatStyle = FlatStyle.Flat; collectionRadioButton.FlatStyle = FlatStyle.Flat; institutionComboBox.FlatStyle = FlatStyle.Flat; collectionComboBox.FlatStyle = FlatStyle.Flat; linkComboBox2.FlatStyle = FlatStyle.Flat; linkComboBox3.FlatStyle = FlatStyle.Flat; linkComboBox4.FlatStyle = FlatStyle.Flat; termComboBox1.FlatStyle = FlatStyle.Flat; termComboBox2.FlatStyle = FlatStyle.Flat; termComboBox3.FlatStyle = FlatStyle.Flat; termComboBox4.FlatStyle = FlatStyle.Flat; searchTextBox1.BorderStyle = BorderStyle.FixedSingle; searchTextBox2.BorderStyle = BorderStyle.FixedSingle; searchTextBox3.BorderStyle = BorderStyle.FixedSingle; searchTextBox4.BorderStyle = BorderStyle.FixedSingle; isXp = true; } else isXp = false; }