/// <summary> Constructor for a new instance of the Xml_MainWriter class </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Current_Item"> Current item to display </param> /// <param name="Current_Page"> Current page within the item</param> public Xml_MainWriter(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Hierarchy_Object, Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Item_Aggregation_Browse_Info Browse_Object, SobekCM_Item Current_Item, Page_TreeNode Current_Page) : base(Current_Mode, Hierarchy_Object, Results_Statistics, Paged_Results, Browse_Object, Current_Item, Current_Page, null) { }
/// <summary> Constructor for a new instance of the DataProvider_MainWriter class </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Current_Item"> Current item to display </param> /// <param name="Current_Page"> Current page within the item</param> public DataProvider_MainWriter(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Hierarchy_Object, Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Item_Aggregation_Child_Page Browse_Object, SobekCM_Item Current_Item, Page_TreeNode Current_Page) : base(Current_Mode, Hierarchy_Object, Results_Statistics, Paged_Results, Browse_Object, Current_Item, Current_Page, null) { // All work done in base class }
/// <summary> Constructor for a new instance of the Text_MainWriter class </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Current_Item"> Current item to display </param> /// <param name="Current_Page"> Current page within the item</param> /// <param name="Static_Web_Content"> HTML content-based browse, info, or imple CMS-style web content objects. These are objects which are read from a static HTML file and much of the head information must be maintained </param> public Text_MainWriter(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Hierarchy_Object, Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Item_Aggregation_Browse_Info Browse_Object, SobekCM_Item Current_Item, Page_TreeNode Current_Page, HTML_Based_Content Static_Web_Content) : base(Current_Mode, Hierarchy_Object, Results_Statistics, Paged_Results, Browse_Object, Current_Item, Current_Page, Static_Web_Content) { // All work done in base class }
/// <summary> Constructor for a new instance of the AggregationViewBag class </summary> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Results_Statistics"> Information about the entire set of results for a browse </param> /// <param name="Paged_Results"> Single page of results for a browse, within the entire set </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Static_Web_Content"> HTML content-based aggregation browse or info. These are objects which are read from a static HTML file and much of the head information must be maintained </param> public AggregationViewBag(Item_Aggregation Hierarchy_Object, Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Item_Aggregation_Child_Page Browse_Object, HTML_Based_Content Static_Web_Content) { this.Hierarchy_Object = Hierarchy_Object; this.Results_Statistics = Results_Statistics; this.Paged_Results = Paged_Results; this.Browse_Object = Browse_Object; this.Static_Web_Content = Static_Web_Content; }
/// <summary> Constructor for a new instance of the Search_Results_HtmlSubwriter class </summary> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Current_User"> Currently logged on user </param> public Search_Results_HtmlSubwriter(Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Aggregation_Code_Manager Code_Manager, Language_Support_Info Translator, Item_Lookup_Object All_Items_Lookup, User_Object Current_User) { currentUser = Current_User; pagedResults = Paged_Results; resultsStatistics = Results_Statistics; translations = Translator; codeManager = Code_Manager; allItemsTable = All_Items_Lookup; }
/// <summary> Constructor for a new instance of the abstract_ResultsViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="ResultsStats"> Statistics about the results to display including the facets </param> /// <param name="PagedResults"> Actual pages of results </param> protected abstract_ResultsViewer(RequestCache RequestSpecificValues, Search_Results_Statistics ResultsStats, List <iSearch_Title_Result> PagedResults) { this.RequestSpecificValues = RequestSpecificValues; this.ResultsStats = ResultsStats; this.PagedResults = PagedResults; // Determine the current user mask CurrentUserMask = 0; if ((HttpContext.Current != null) && (HttpContext.Current.Session["IP_Range_Membership"] != null)) { CurrentUserMask = (int)HttpContext.Current.Session["IP_Range_Membership"]; } }
/// <summary> Constructor for a new instance of the DataSet_Browse_Info_AggregationViewer class </summary> /// <param name="Browse_Object"> Browse or information object to be displayed </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Code_Manager"> Code manager object maintains mapping between SobekCM codes and greenstone codes (used by result_dataset_html_subwriter)</param> /// <param name="Item_List"> Object for pulling additional information about each item during display </param> /// <param name="Current_User"> Currently logged on user, or NULL </param> public DataSet_Browse_Info_AggregationViewer(Item_Aggregation_Child_Page Browse_Object, Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object Item_List, User_Object Current_User) : base(null, null) { browseObject = Browse_Object; codeManager = Code_Manager; itemList = Item_List; currentUser = Current_User; resultsStatistics = Results_Statistics; pagedResults = Paged_Results; }
/// <summary> Constructor for a new instance of the Json_MainWriter class </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Current_Item"> Current item to display </param> /// <param name="Current_Page"> Current page within the item</param> /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Current_Image_Root"> Current root directory to pull images and metadata for digital resources </param> public Json_MainWriter(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Hierarchy_Object, Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Item_Aggregation_Child_Page Browse_Object, SobekCM_Item Current_Item, Page_TreeNode Current_Page, Item_Lookup_Object All_Items_Lookup, string Current_Image_Root) : base(Current_Mode, Hierarchy_Object, Results_Statistics, Paged_Results, Browse_Object, Current_Item, Current_Page, null) { allItems = All_Items_Lookup; currentGreenstoneImageRoot = Current_Image_Root; }
/// <summary> Constructor for a new instance of the RequestCache class </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="Public_Folder"> Object contains the information about the public folder to display </param> /// <param name="Top_Collection"> Item aggregation for the top-level collection, which is used in a number of places, for example /// showing the correct banner, even when it is not the "current" aggregation </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public RequestCache(Navigation_Object Current_Mode, Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, User_Object Current_User, Public_User_Folder Public_Folder, Item_Aggregation Top_Collection, Custom_Tracer Tracer) { this.Current_Mode = Current_Mode; this.Results_Statistics = Results_Statistics; this.Paged_Results = Paged_Results; this.Current_User = Current_User; this.Public_Folder = Public_Folder; this.Top_Collection = Top_Collection; this.Tracer = Tracer; Flags = new RequestCache_RequestFlags(); }
/// <summary> Constructor for a new instance of the abstractMainWriter abstract class </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Current_Item"> Current item to display </param> /// <param name="Current_Page"> Current page within the item</param> /// <param name="Static_Web_Content"> HTML content-based browse, info, or imple CMS-style web content objects. These are objects which are read from a static HTML file and much of the head information must be maintained </param> protected abstractMainWriter(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Hierarchy_Object, Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Item_Aggregation_Browse_Info Browse_Object, SobekCM_Item Current_Item, Page_TreeNode Current_Page, HTML_Based_Content Static_Web_Content) { currentMode = Current_Mode; hierarchyObject = Hierarchy_Object; results_statistics = Results_Statistics; paged_results = Paged_Results; thisBrowseObject = Browse_Object; currentItem = Current_Item; currentPage = Current_Page; htmlBasedContent = Static_Web_Content; }
/// <summary> Constructor for a new instance of the Full_ResultsViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="ResultsStats"> Statistics about the results to display including the facets </param> /// <param name="PagedResults"> Actual pages of results </param> public Google_Map_ResultsViewer_Beta(RequestCache RequestSpecificValues, Search_Results_Statistics ResultsStats, List<iSearch_Title_Result> PagedResults) : base(RequestSpecificValues, ResultsStats, PagedResults) { //holds actions from page string payload = HttpContext.Current.Request.Form["payload"] ?? String.Empty; // See if there were hidden requests if (!String.IsNullOrEmpty(payload)) { //if (action == "action") Perform_Callback_Action(payload, RequestSpecificValues.Tracer); } else { //do a search for all the items in this agg string temp_AggregationId = RequestSpecificValues.Current_Mode.Aggregation; string[] temp_AggregationList = temp_AggregationId.Split(' '); Perform_Aggregation_Search(temp_AggregationList, RequestSpecificValues.Tracer); } }
public static System.String getMetadata(iSearch_Title_Result titleResult, Search_Results_Statistics ResultsStats, string fieldname) { int i = 0; string msg = ""; msg = "getMetadata for [" + fieldname + "].\r\n"; if (debug) { logme(msg); } for (i = 0; i < titleResult.Metadata_Display_Values.Length; i++) { if (ResultsStats.Metadata_Labels[i].Equals(fieldname)) { msg = "getMetadata: Found [" + fieldname + "] at [" + i + "], returning [" + titleResult.Metadata_Display_Values[i].ToString().Trim() + "].\r\n"; if (debug) { logme(msg); } return(titleResult.Metadata_Display_Values[i].ToString().Trim()); } else { //msg = "\tOther found at " + i + ". [" + ResultsStats.Metadata_Labels[i] + "]=[" + titleResult.Metadata_Display_Values[i].ToString().Trim() + "].\r\n"; //if (debug) logme(msg); } } msg = "getMetadata: Done, fell through, couldn't find [" + fieldname + "].\r\n"; if (debug) { logme(msg); } return(fieldname + " is N/A"); }
/// <summary> Constructor for a new instance of the Export_ResultsViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="ResultsStats"> Statistics about the results to display including the facets </param> /// <param name="PagedResults"> Actual pages of results </param> public Export_ResultsViewer(RequestCache RequestSpecificValues, Search_Results_Statistics ResultsStats, List <iSearch_Title_Result> PagedResults) : base(RequestSpecificValues, ResultsStats, PagedResults) { Results_Per_Page = 1000; }
/// <summary> Gets the indicated results viewer, by results viewer code, usually from the URL </summary> /// <param name="ViewerCode"> Code which indicates which results viewer </param> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="ResultsStats"> Statistics about the results to display including the facets </param> /// <param name="PagedResults"> Actual pages of results </param> /// <returns> Either the results vieweer, or NULL </returns> public static iResultsViewer Get_Results_Viewer(string ViewerCode, RequestCache RequestSpecificValues, Search_Results_Statistics ResultsStats, List <iSearch_Title_Result> PagedResults) { // Get the match by viewer code ResultsSubViewerConfig config = UI_ApplicationCache_Gateway.Configuration.UI.WriterViewers.Results.GetViewerByCode(ViewerCode); // If no match, just try by viewer type then if (config == null) { config = UI_ApplicationCache_Gateway.Configuration.UI.WriterViewers.Results.GetViewerByType(ViewerCode); } // If still null, return NULL if (config == null) { return(null); } // Was an assembly indicated if (String.IsNullOrEmpty(config.Assembly)) { // Return a standard class switch (config.Class) { case "SobekCM.Library.ResultsViewer.Bookshelf_ResultsViewer": return(new Bookshelf_View_ResultsViewer(RequestSpecificValues, ResultsStats, PagedResults)); case "SobekCM.Library.ResultsViewer.Brief_ResultsViewer": return(new Brief_ResultsViewer(RequestSpecificValues, ResultsStats, PagedResults)); case "SobekCM.Library.ResultsViewer.Export_ResultsViewer": return(new Export_ResultsViewer(RequestSpecificValues, ResultsStats, PagedResults)); case "SobekCM.Library.ResultsViewer.Google_Map_ResultsViewer": return(new Google_Map_ResultsViewer(RequestSpecificValues, ResultsStats, PagedResults)); case "SobekCM.Library.ResultsViewer.Table_ResultsViewer": return(new Table_ResultsViewer(RequestSpecificValues, ResultsStats, PagedResults)); case "SobekCM.Library.ResultsViewer.Thumbnail_ResultsViewer": return(new Thumbnail_ResultsViewer(RequestSpecificValues, ResultsStats, PagedResults)); case "SobekCM.Library.ResultsViewer.No_Results_ResultsViewer": return(new No_Results_ResultsViewer(RequestSpecificValues, ResultsStats, PagedResults)); } // If it made it here, there is no assembly, but it is an unexpected type. // Just create it from the same assembly then try { Assembly dllAssembly = Assembly.GetCallingAssembly(); Type prototyperType = dllAssembly.GetType(config.Class); iResultsViewer returnObj = (iResultsViewer)Activator.CreateInstance(prototyperType); return(returnObj); } catch (Exception) { // Not sure exactly what to do here, honestly return(null); } } // An assembly was indicated try { // Try to find the file/path for this assembly then Assembly dllAssembly = null; string assemblyFilePath = UI_ApplicationCache_Gateway.Configuration.Extensions.Get_Assembly(config.Assembly); if (assemblyFilePath != null) { dllAssembly = Assembly.LoadFrom(assemblyFilePath); } Type prototyperType = dllAssembly.GetType(config.Class); iResultsViewer returnObj = (iResultsViewer)Activator.CreateInstance(prototyperType); return(returnObj); } catch (Exception ee) { // Not sure exactly what to do here, honestly if (ee.Message.Length > 0) { return(null); } return(null); } }
/// <summary> Run a solr query against the solr document index </summary> /// <param name="QueryString"> Solr query string </param> /// <param name="SearchOptions"> Options related to this search, like the page, results per page, facets, fields, etc.. </param> /// <param name="UserMembership"> User-specific membership information, related to a search, which can be used to determine which items this user can discover</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="Complete_Result_Set_Info"> [OUT] Information about the entire set of results </param> /// <param name="Paged_Results"> [OUT] List of search results for the requested page of results </param> /// <returns> Page search result object with all relevant result information </returns> public static bool Run_Query(string QueryString, Search_Options_Info SearchOptions, Search_User_Membership_Info UserMembership, Custom_Tracer Tracer, out Search_Results_Statistics Complete_Result_Set_Info, out List <iSearch_Title_Result> Paged_Results) { // If the query string is empty, then set it back to *:* if (QueryString.Trim().Length == 0) { QueryString = "*:*"; } // Set output initially to null Paged_Results = new List <iSearch_Title_Result>(); Complete_Result_Set_Info = null; try { // Ensure page is not erroneously set to zero or negative int pageNumber = SearchOptions.Page; if (pageNumber <= 0) { pageNumber = 1; } // Get and clean the solr document url string solrDocumentUrl = Engine_ApplicationCache_Gateway.Settings.Servers.Document_Solr_Index_URL; if ((!String.IsNullOrEmpty(solrDocumentUrl)) && (solrDocumentUrl[solrDocumentUrl.Length - 1] == '/')) { solrDocumentUrl = solrDocumentUrl.Substring(0, solrDocumentUrl.Length - 1); } // Create the solr worker to query the document index var solrWorker = Solr_Operations_Cache <v5_SolrDocument> .GetSolrOperations(solrDocumentUrl); // Get the list of fields List <string> fields = new List <string> { "did", "mainthumb", "title" }; fields.AddRange(SearchOptions.Fields.Select(MetadataField => MetadataField.SolrCode)); // Create the query options QueryOptions options = new QueryOptions { Rows = SearchOptions.ResultsPerPage, Start = (pageNumber - 1) * SearchOptions.ResultsPerPage, Fields = fields }; // Was there full text search in that? if ((QueryString.Contains("(fulltext:")) && (SearchOptions.IncludeFullTextSnippets)) { options.Highlight = new HighlightingParameters { Fields = new[] { "fulltext" }, Fragsize = 255 }; options.ExtraParams = new Dictionary <string, string> { { "hl.useFastVectorHighlighter", "true" }, { "wt", "xml" } }; } else { // We still need to instruct SOLR to return the results as XML for solr to parse it options.ExtraParams = new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("wt", "xml") }; } // If the search stats are needed, let's get the facets if ((SearchOptions.Facets != null) && (SearchOptions.Facets.Count > 0)) { // Create the query facters options.Facet = new FacetParameters(); foreach (Complete_Item_Aggregation_Metadata_Type facet in SearchOptions.Facets) { options.Facet.Queries.Add(new SolrFacetFieldQuery(facet.SolrCode) { MinCount = 1, Limit = 100 }); } } // Set the sort value if (SearchOptions.Sort != 0) { options.OrderBy.Clear(); switch (SearchOptions.Sort) { case 1: options.OrderBy.Add(new SortOrder("title.sort", Order.ASC)); break; case 2: options.OrderBy.Add(new SortOrder("bibid", Order.ASC)); break; case 3: options.OrderBy.Add(new SortOrder("bibid", Order.DESC)); break; case 10: options.OrderBy.Add(new SortOrder("date.gregorian", Order.ASC)); break; case 11: options.OrderBy.Add(new SortOrder("date.gregorian", Order.DESC)); break; case 12: options.OrderBy.Add(new SortOrder("timeline_date", Order.ASC)); // If sorting by this, only get records with timeline date QueryString = "(" + QueryString + ") AND timeline_date:[* TO *]"; break; } } // Should this be grouped? bool grouped_results = false; if ((SearchOptions.GroupItemsByTitle) && (SearchOptions.Sort < 10) && (QueryString.IndexOf("fulltext") < 0)) { if (Tracer != null) { Tracer.Add_Trace("v5_Solr_Documents_Searcher.Run_Query", "Grouping search request by bibid"); } grouped_results = true; GroupingParameters groupingParams = new GroupingParameters { Fields = new[] { "bibid" }, Format = GroupingFormat.Grouped, Limit = 10, Ngroups = true }; options.Grouping = groupingParams; } // Log the search term if (Tracer != null) { Tracer.Add_Trace("v5_Solr_Documents_Searcher.Run_Query", "Solr Query: " + QueryString); } if (Tracer != null) { Tracer.Add_Trace("v5_Solr_Documents_Searcher.Run_Query", "Perform the search"); } // Perform this search SolrQueryResults <v5_SolrDocument> results = solrWorker.Query(QueryString, options); if (Tracer != null) { Tracer.Add_Trace("v5_Solr_Documents_Searcher.Run_Query", "Build the results object"); } // Create the search statistcs (this part assumes no grouping, and then we fix the count shortly) List <string> metadataLabels = SearchOptions.Fields.Select(MetadataType => MetadataType.DisplayTerm).ToList(); Complete_Result_Set_Info = new Search_Results_Statistics(metadataLabels) { Total_Titles = results.NumFound, Total_Items = results.NumFound, QueryTime = results.Header.QTime }; // If the search stats were needed, get the facets out if ((SearchOptions.Facets != null) && (SearchOptions.Facets.Count > 0)) { // Copy over all the facets foreach (Complete_Item_Aggregation_Metadata_Type facetTerm in SearchOptions.Facets) { // Create the collection and and assifn the metadata type id Search_Facet_Collection thisCollection = new Search_Facet_Collection(facetTerm.ID); // Add each value foreach (var facet in results.FacetFields[facetTerm.SolrCode]) { thisCollection.Facets.Add(new Search_Facet(facet.Key, facet.Value)); } // If there was an id and facets added, save this to the search statistics if ((thisCollection.MetadataTypeID > 0) && (thisCollection.Facets.Count > 0)) { Complete_Result_Set_Info.Facet_Collections.Add(thisCollection); } } } // Build the results mapper object v5_SolrDocument_Results_Mapper mapper = new v5_SolrDocument_Results_Mapper(); // Build the results differently, depending on whether they were grouped or not if (grouped_results) { // Get the grouped results (only grouped by bibid) GroupedResults <v5_SolrDocument> title_groupings = results.Grouping["bibid"]; // Now step through each group (i.e., titles/bibs) in the groups foreach (Group <v5_SolrDocument> grouping in title_groupings.Groups) { // Convert the grouping to the new result v5_Solr_Title_Result newResult = mapper.Map_To_Result(grouping, SearchOptions.Fields); Paged_Results.Add(newResult); } // Now, fix the stats as well Complete_Result_Set_Info.Total_Items = title_groupings.Matches; Complete_Result_Set_Info.Total_Titles = title_groupings.Ngroups.Value; } else { // Pass all the results into the List and add the highlighted text to each result as well foreach (v5_SolrDocument thisResult in results) { // Convert to the new result v5_Solr_Title_Result newResult = mapper.Map_To_Result(thisResult, SearchOptions.Fields); // Add the highlight snippet, if applicable if ((results.Highlights != null) && (results.Highlights.ContainsKey(thisResult.DID)) && (results.Highlights[thisResult.DID].Count > 0) && (results.Highlights[thisResult.DID].ElementAt(0).Value.Count > 0)) { newResult.Snippet = results.Highlights[thisResult.DID].ElementAt(0).Value.ElementAt(0); } Paged_Results.Add(newResult); } } return(true); } catch (Exception ee) { return(false); } }
/// <summary> Return the list of newly added items within a single aggregation (or ALL aggregations) </summary> /// <param name="SearchOptions"> Options related to this search, like the page, results per page, facets, fields, etc.. </param> /// <param name="UserMembership"> User-specific membership information, related to a search, which can be used to determine which items this user can discover</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="Complete_Result_Set_Info"> [OUT] Information about the entire set of results </param> /// <param name="Paged_Results"> [OUT] List of search results for the requested page of results </param> /// <returns> Page search result object with all relevant result information</returns> public static bool New_Browse(Search_Options_Info SearchOptions, Search_User_Membership_Info UserMembership, Custom_Tracer Tracer, out Search_Results_Statistics Complete_Result_Set_Info, out List <iSearch_Title_Result> Paged_Results) { // Computer the datetime for this DateTime two_weeks_ago = DateTime.Now.Subtract(new TimeSpan(14, 0, 0, 0)); string date_string = two_weeks_ago.Year + "-" + two_weeks_ago.Month.ToString().PadLeft(2, '0') + "-" + two_weeks_ago.Day.ToString().PadLeft(2, '0') + "T00:00:00Z"; // Get the query string value string queryString = null; // Exclude hidden, if not an admin (later we will deal with user/groups and IP restrictions) if ((UserMembership == null) || (!UserMembership.LoggedIn) || (!UserMembership.Admin)) { queryString = "(hidden:0) AND (discover_ips:0) AND ( made_public_date:[" + date_string + " TO *] )"; } else { queryString = "( made_public_date:[" + date_string + " TO *] )"; } // If there was an aggregation code included, put that at the beginning of the search if ((!String.IsNullOrEmpty(SearchOptions.AggregationCode)) && (SearchOptions.AggregationCode.ToUpper() != "ALL")) { if (!String.IsNullOrEmpty(queryString)) { queryString = "(aggregations:" + SearchOptions.AggregationCode + ") AND " + queryString; } else { queryString = "(aggregations:" + SearchOptions.AggregationCode + ")"; } } // Set output initially to null return(Run_Query(queryString, SearchOptions, UserMembership, Tracer, out Complete_Result_Set_Info, out Paged_Results)); }
/// <summary> Constructor for a new instance of the MySobek_HtmlSubwriter class </summary> /// <param name="Results_Statistics"> Information about the entire set of results for a browse of a user's bookshelf folder </param> /// <param name="Paged_Results"> Single page of results for a browse of a user's bookshelf folder, within the entire set </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item">Current item to edit, if the user is requesting to edit an item</param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations </param> /// <param name="Web_Skin_Collection"> Collection of all the web skins </param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="IP_Restrictions"> List of all IP Restriction ranges in use by this digital library </param> /// <param name="URL_Portals"> List of all web portals into this system </param> /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </param> /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public MySobek_HtmlSubwriter(Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object All_Items_Lookup, Item_Aggregation Hierarchy_Object, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Dictionary <string, string> Aggregation_Aliases, SobekCM_Skin_Collection Web_Skin_Collection, User_Object Current_User, IP_Restriction_Ranges IP_Restrictions, Dictionary <string, Wordmark_Icon> Icon_Table, Portal_List URL_Portals, Statistics_Dates Stats_Date_Range, List <Thematic_Heading> Thematic_Headings, Custom_Tracer Tracer) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Saving values and geting user object back from the session"); resultsStatistics = Results_Statistics; pagedResults = Paged_Results; codeManager = Code_Manager; itemList = All_Items_Lookup; htmlSkin = HTML_Skin; translator = Translator; currentCollection = Hierarchy_Object; currentItem = Current_Item; user = Current_User; ipRestrictions = IP_Restrictions; iconTable = Icon_Table; statsDates = Stats_Date_Range; if (Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Log_Out) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Performing logout"); HttpContext.Current.Session["user"] = null; HttpContext.Current.Response.Redirect("?"); } if ((Current_Mode.My_Sobek_Type != My_Sobek_Type_Enum.Logon) && (user != null) && (user.Is_Temporary_Password)) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.New_Password; } if (Current_Mode.Logon_Required) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Logon; } Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Building the my sobek viewer object"); switch (Current_Mode.My_Sobek_Type) { case My_Sobek_Type_Enum.Home: mySobekViewer = new Home_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.New_Item: mySobekViewer = new New_Group_And_Item_MySobekViewer(user, Current_Mode, itemList, codeManager, iconTable, htmlSkin, translator, Tracer); break; case My_Sobek_Type_Enum.Folder_Management: mySobekViewer = new Folder_Mgmt_MySobekViewer(user, resultsStatistics, pagedResults, codeManager, itemList, currentCollection, htmlSkin, translator, Current_Mode, Tracer); break; case My_Sobek_Type_Enum.Saved_Searches: mySobekViewer = new Saved_Searches_MySobekViewer(user, translator, Current_Mode, Tracer); break; case My_Sobek_Type_Enum.Preferences: mySobekViewer = new Preferences_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.Logon: mySobekViewer = new Logon_MySobekViewer(Current_Mode, Tracer); break; case My_Sobek_Type_Enum.New_Password: mySobekViewer = new NewPassword_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.Delete_Item: mySobekViewer = new Delete_Item_MySobekViewer(user, Current_Mode, All_Items_Lookup, Tracer); break; case My_Sobek_Type_Enum.Edit_Item_Behaviors: mySobekViewer = new Edit_Item_Behaviors_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer); break; case My_Sobek_Type_Enum.Edit_Item_Metadata: mySobekViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, currentItem, codeManager, iconTable, htmlSkin, Tracer); break; case My_Sobek_Type_Enum.File_Management: mySobekViewer = new File_Management_MySobekViewer(user, Current_Mode, Current_Item, itemList, codeManager, iconTable, htmlSkin, translator, Tracer); break; case My_Sobek_Type_Enum.Edit_Group_Behaviors: mySobekViewer = new Edit_Group_Behaviors_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer); break; case My_Sobek_Type_Enum.Edit_Group_Serial_Hierarchy: mySobekViewer = new Edit_Serial_Hierarchy_MySobekViewer(user); break; case My_Sobek_Type_Enum.Group_Add_Volume: // Pull the list of items tied to this group SobekCM_Items_In_Title itemsInTitle = Cached_Data_Manager.Retrieve_Items_In_Title(currentItem.BibID, Tracer); if (itemsInTitle == null) { // Get list of information about this item group and save the item list DataSet itemDetails = SobekCM_Database.Get_Item_Group_Details(currentItem.BibID, Tracer); itemsInTitle = new SobekCM_Items_In_Title(itemDetails.Tables[1]); // Store in cache if retrieved Cached_Data_Manager.Store_Items_In_Title(currentItem.BibID, itemsInTitle, Tracer); } mySobekViewer = new Group_Add_Volume_MySobekViewer(user, Current_Mode, itemList, currentItem, codeManager, iconTable, htmlSkin, itemsInTitle, translator, Tracer); break; case My_Sobek_Type_Enum.Group_AutoFill_Volumes: mySobekViewer = new Group_AutoFill_Volume_MySobekViewer(user); break; case My_Sobek_Type_Enum.Group_Mass_Update_Items: mySobekViewer = new Mass_Update_Items_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer); break; case My_Sobek_Type_Enum.User_Tags: mySobekViewer = new User_Tags_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.User_Usage_Stats: mySobekViewer = new User_Usage_Stats_MySobekViewer(user, Current_Mode, statsDates, Tracer); break; } // Pass in the navigation and translator information mySobekViewer.CurrentMode = Current_Mode; mySobekViewer.Translator = translator; }
/// <summary> Constructor for a new instance of the No_Results_ResultsViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="ResultsStats"> Statistics about the results to display including the facets </param> /// <param name="PagedResults"> Actual pages of results </param> public No_Results_ResultsViewer(RequestCache RequestSpecificValues, Search_Results_Statistics ResultsStats, List <iSearch_Title_Result> PagedResults) : base(RequestSpecificValues, ResultsStats, PagedResults) { // Do nothing }
/// <summary> Gets the indicated results viewer, by results viewer code, usually from the URL </summary> /// <param name="ViewerCode"> Code which indicates which results viewer </param> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="ResultsStats"> Statistics about the results to display including the facets </param> /// <param name="PagedResults"> Actual pages of results </param> /// <returns> Either the results vieweer, or NULL </returns> public static iResultsViewer Get_Results_Viewer(string ViewerCode, RequestCache RequestSpecificValues, Search_Results_Statistics ResultsStats, List <iSearch_Title_Result> PagedResults) { // Determine the actual viewercode string viewerCode = ViewerCode; if (RequestSpecificValues.Current_Mode.Mode == Display_Mode_Enum.My_Sobek) { if (!String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.ViewerCode)) { viewerCode = RequestSpecificValues.Current_Mode.ViewerCode; } else { viewerCode = "brief"; } } // Get the match by viewer code ResultsSubViewerConfig config = UI_ApplicationCache_Gateway.Configuration.UI.WriterViewers.Results.GetViewerByCode(viewerCode); // If no match, just try by viewer type then if (config == null) { config = UI_ApplicationCache_Gateway.Configuration.UI.WriterViewers.Results.GetViewerByType(viewerCode); } // If this is still NULL, just try to get the brief view if (config == null) { config = UI_ApplicationCache_Gateway.Configuration.UI.WriterViewers.Results.GetViewerByCode("brief"); } // If still null, return NULL if (config == null) { return(null); } // Was an assembly indicated if (String.IsNullOrEmpty(config.Assembly)) { iResultsViewer returnValue = null; // Return a standard class switch (config.Class) { case "SobekCM.Library.ResultsViewer.Bookshelf_ResultsViewer": returnValue = new Bookshelf_View_ResultsViewer(); break; case "SobekCM.Library.ResultsViewer.Brief_ResultsViewer": returnValue = new Brief_ResultsViewer(); break; case "SobekCM.Library.ResultsViewer.Export_ResultsViewer": returnValue = new Export_ResultsViewer(); break; case "SobekCM.Library.ResultsViewer.Google_Map_ResultsViewer": returnValue = new Google_Map_ResultsViewer(); break; case "SobekCM.Library.ResultsViewer.Table_ResultsViewer": returnValue = new Table_ResultsViewer(); break; case "SobekCM.Library.ResultsViewer.Thumbnail_ResultsViewer": returnValue = new Thumbnail_ResultsViewer(); break; case "SobekCM.Library.ResultsViewer.No_Results_ResultsViewer": returnValue = new No_Results_ResultsViewer(); break; } if (returnValue == null) { // If it made it here, there is no assembly, but it is an unexpected type. // Just create it from the same assembly then try { Assembly dllAssembly = Assembly.GetCallingAssembly(); Type prototyperType = dllAssembly.GetType(config.Class); returnValue = (iResultsViewer)Activator.CreateInstance(prototyperType); } catch (Exception ee) { RequestSpecificValues.Tracer.Add_Trace("ResultsViewer_Factory", "Exception when creating a results viewer from the current assembly via reflection"); RequestSpecificValues.Tracer.Add_Trace("ResultsViewer_Factory", ee.Message); // Not sure exactly what to do here, honestly return(null); } } // If a results viewer was created, finish the construction and return it if (returnValue != null) { returnValue.RequestSpecificValues = RequestSpecificValues; returnValue.ResultsStats = ResultsStats; returnValue.PagedResults = PagedResults; return(returnValue); } // Return value must be NULL RequestSpecificValues.Tracer.Add_Trace("ResultsViewer_Factory", "NULL value when creating a results viewer from the current assembly (via reflection)"); return(null); } // An assembly was indicated try { // Try to find the file/path for this assembly then Assembly dllAssembly = null; string assemblyFilePath = UI_ApplicationCache_Gateway.Configuration.Extensions.Get_Assembly(config.Assembly); if (assemblyFilePath != null) { dllAssembly = Assembly.LoadFrom(assemblyFilePath); } Type prototyperType = dllAssembly.GetType(config.Class); iResultsViewer returnObj = (iResultsViewer)Activator.CreateInstance(prototyperType); // If a results viewer was created, finish the construction and return it if (returnObj != null) { returnObj.RequestSpecificValues = RequestSpecificValues; returnObj.ResultsStats = ResultsStats; returnObj.PagedResults = PagedResults; return(returnObj); } // Return value must be NULL RequestSpecificValues.Tracer.Add_Trace("ResultsViewer_Factory", "NULL value when creating a results viewer from a separate assembly via reflection"); return(null); } catch (Exception ee) { RequestSpecificValues.Tracer.Add_Trace("ResultsViewer_Factory", "Exception when creating a results viewer from a separate assembly via reflection"); RequestSpecificValues.Tracer.Add_Trace("ResultsViewer_Factory", ee.Message); return(null); } }
/// <summary> Perform an search for documents with matching parameters </summary> /// <param name="Terms"> List of the search terms which define this search </param> /// <param name="Web_Fields"> List of the web fields associate with the search terms </param> /// <param name="StartDate"> Starting date, if this search includes a limitation by time </param> /// <param name="EndDate"> Ending date, if this search includes a limitation by time </param> /// <param name="SearchOptions"> Options related to this search, like the page, results per page, facets, fields, etc.. </param> /// <param name="UserMembership"> User-specific membership information, related to a search, which can be used to determine which items this user can discover</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="Complete_Result_Set_Info"> [OUT] Information about the entire set of results </param> /// <param name="Paged_Results"> [OUT] List of search results for the requested page of results </param> /// <returns> Page search result object with all relevant result information </returns> public static bool Search(List <string> Terms, List <string> Web_Fields, Nullable <DateTime> StartDate, Nullable <DateTime> EndDate, Search_Options_Info SearchOptions, Search_User_Membership_Info UserMembership, Custom_Tracer Tracer, out Search_Results_Statistics Complete_Result_Set_Info, out List <iSearch_Title_Result> Paged_Results) { if (Tracer != null) { Tracer.Add_Trace("v5_Solr_Documents_Searcher.Search", String.Empty); } // Get the query string string queryString = Create_Query_String(Terms, Web_Fields, StartDate, EndDate, Tracer); // Exclude hidden, if not an admin (later we will deal with user/groups and IP restrictions) if ((UserMembership == null) || (!UserMembership.LoggedIn) || (!UserMembership.Admin)) { queryString = "(hidden:0) AND (discover_ips:0) AND (" + queryString + ")"; } // If there was an aggregation code included, put that at the beginning of the search if ((!String.IsNullOrEmpty(SearchOptions.AggregationCode)) && (SearchOptions.AggregationCode.ToUpper() != "ALL")) { if (!String.IsNullOrEmpty(queryString)) { queryString = "(aggregations:" + SearchOptions.AggregationCode + ") AND " + queryString; } else { queryString = "(aggregations:" + SearchOptions.AggregationCode + ")"; } } // Set output initially to null return(Run_Query(queryString, SearchOptions, UserMembership, Tracer, out Complete_Result_Set_Info, out Paged_Results)); }
/// <summary> Return the list of all items within a single aggregation (or ALL aggregations) </summary> /// <param name="SearchOptions"> Options related to this search, like the page, results per page, facets, fields, etc.. </param> /// <param name="UserMembership"> User-specific membership information, related to a search, which can be used to determine which items this user can discover</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="Complete_Result_Set_Info"> [OUT] Information about the entire set of results </param> /// <param name="Paged_Results"> [OUT] List of search results for the requested page of results </param> /// <returns> Page search result object with all relevant result information</returns> public static bool All_Browse(Search_Options_Info SearchOptions, Search_User_Membership_Info UserMembership, Custom_Tracer Tracer, out Search_Results_Statistics Complete_Result_Set_Info, out List <iSearch_Title_Result> Paged_Results) { // Get the query string value string queryString = String.Empty; // Exclude hidden, if not an admin (later we will deal with user/groups and IP restrictions) if ((UserMembership == null) || (!UserMembership.LoggedIn) || (!UserMembership.Admin)) { queryString = "(hidden:0) AND (discover_ips:0)"; } // If there was an aggregation code included, put that at the beginning of the search if ((!String.IsNullOrEmpty(SearchOptions.AggregationCode)) && (SearchOptions.AggregationCode.ToUpper() != "ALL")) { if (!String.IsNullOrEmpty(queryString)) { queryString = "(aggregations:" + SearchOptions.AggregationCode + ") AND " + queryString; } else { queryString = "(aggregations:" + SearchOptions.AggregationCode + ")"; } } // Set output initially to null return(Run_Query(queryString, SearchOptions, UserMembership, Tracer, out Complete_Result_Set_Info, out Paged_Results)); }
/// <summary> Perform an search for documents with matching parameters </summary> /// <param name="AggregationCode"> Aggregation code within which to search </param> /// <param name="Terms"> List of the search terms </param> /// <param name="Web_Fields"> List of the web fields associate with the search terms </param> /// <param name="ResultsPerPage"> Number of results to display per a "page" of results </param> /// <param name="Page_Number"> Which page of results to return ( one-based, so the first page is page number of one )</param> /// <param name="Sort"> Sort to apply before returning the results of the search </param> /// <param name="Need_Search_Statistics"> Flag indicates if the search statistics are needed </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="Complete_Result_Set_Info"> [OUT] Information about the entire set of results </param> /// <param name="Paged_Results"> [OUT] List of search results for the requested page of results </param> /// <returns> Page search result object with all relevant result information </returns> public static bool Search(string AggregationCode, List <string> Terms, List <string> Web_Fields, int ResultsPerPage, int Page_Number, ushort Sort, bool Need_Search_Statistics, Custom_Tracer Tracer, out Search_Results_Statistics Complete_Result_Set_Info, out List <iSearch_Title_Result> Paged_Results) { if (Tracer != null) { Tracer.Add_Trace("Legacy_Solr_Documents_Searcher.Search", "Build the Solr query"); } // Step through all the terms and fields StringBuilder queryStringBuilder = new StringBuilder(); for (int i = 0; i < Math.Min(Terms.Count, Web_Fields.Count); i++) { string web_field = Web_Fields[i]; string searchTerm = Terms[i]; string solr_field; if (i == 0) { // Skip any joiner for the very first field indicated if ((web_field[0] == '+') || (web_field[0] == '=') || (web_field[0] == '-')) { web_field = web_field.Substring(1); } // Try to get the solr field if (web_field == "TX") { solr_field = "fulltext:"; } else { Metadata_Search_Field field = Engine_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Code(web_field.ToUpper()); if (field != null) { solr_field = field.Legacy_Solr_Code + ":"; } else { solr_field = String.Empty; } } // Add the solr search string if (searchTerm.IndexOf(" ") > 0) { queryStringBuilder.Append("(" + solr_field + "\"" + searchTerm.Replace(":", "") + "\")"); } else { queryStringBuilder.Append("(" + solr_field + searchTerm.Replace(":", "") + ")"); } } else { // Add the joiner for this subsequent terms if ((web_field[0] == '+') || (web_field[0] == '=') || (web_field[0] == '-')) { switch (web_field[0]) { case '=': queryStringBuilder.Append(" OR "); break; case '+': queryStringBuilder.Append(" AND "); break; case '-': queryStringBuilder.Append(" NOT "); break; default: queryStringBuilder.Append(" AND "); break; } web_field = web_field.Substring(1); } else { queryStringBuilder.Append(" AND "); } // Try to get the solr field if (web_field == "TX") { solr_field = "fulltext:"; } else { Metadata_Search_Field field = Engine_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Code(web_field.ToUpper()); if (field != null) { solr_field = field.Legacy_Solr_Code + ":"; } else { solr_field = String.Empty; } } // Add the solr search string if (searchTerm.IndexOf(" ") > 0) { queryStringBuilder.Append("(" + solr_field + "\"" + searchTerm.Replace(":", "") + "\")"); } else { queryStringBuilder.Append("(" + solr_field + searchTerm.Replace(":", "") + ")"); } } } if (Tracer != null) { Tracer.Add_Trace("Legacy_Solr_Documents_Searcher.Search", "Perform the search"); } // Get the query string value string queryString = queryStringBuilder.ToString(); // Set output initially to null Paged_Results = new List <iSearch_Title_Result>(); Complete_Result_Set_Info = null; try { // Ensure page is not erroneously set to zero or negative if (Page_Number <= 0) { Page_Number = 1; } // Create the solr worker to query the document index var solrWorker = Solr_Operations_Cache <Legacy_Solr_Document_Result> .GetSolrOperations(Engine_ApplicationCache_Gateway.Settings.Servers.Document_Solr_Legacy_URL); // Create the query options QueryOptions options = new QueryOptions { Rows = ResultsPerPage, Start = (Page_Number - 1) * ResultsPerPage, Fields = new[] { "did", "score", "url", "aleph", "donor", "edition", "format", "holdinglocation", "sourceinstitution", "maintitle", "materialtype", "oclc", "pubdate_display", "author_display", "publisher_display", "mainthumbnail" }, Highlight = new HighlightingParameters { Fields = new[] { "fulltext" }, }, ExtraParams = new Dictionary <string, string> { { "hl.useFastVectorHighlighter", "true" } } }; // Set the sort value if (Sort != 0) { options.OrderBy.Clear(); switch (Sort) { case 1: options.OrderBy.Add(new SortOrder("maintitle_sort")); break; case 2: options.OrderBy.Add(new SortOrder("bibid", Order.ASC)); break; case 3: options.OrderBy.Add(new SortOrder("bibid", Order.DESC)); break; case 10: options.OrderBy.Add(new SortOrder("pubdate", Order.ASC)); break; case 11: options.OrderBy.Add(new SortOrder("pubdate", Order.DESC)); break; } } // If there was an aggregation code included, put that at the beginning of the search if ((AggregationCode.Length > 0) && (AggregationCode.ToUpper() != "ALL")) { queryString = "(aggregation_code:" + AggregationCode.ToUpper() + ")AND(" + queryString + ")"; } // Perform this search SolrQueryResults <Legacy_Solr_Document_Result> results = solrWorker.Query(queryString, options); // Create the search statistcs List <string> metadataLabels = new List <string> { "Author", "Publisher", "Format", "Edition", "Institution", "Donor" }; Complete_Result_Set_Info = new Search_Results_Statistics(metadataLabels) { Total_Titles = results.NumFound, Total_Items = results.NumFound, QueryTime = results.Header.QTime }; // Pass all the results into the List and add the highlighted text to each result as well foreach (Legacy_Solr_Document_Result thisResult in results) { // Add the highlight snipper if ((results.Highlights.ContainsKey(thisResult.DID)) && (results.Highlights[thisResult.DID].Count > 0) && (results.Highlights[thisResult.DID].ElementAt(0).Value.Count > 0)) { thisResult.Snippet = results.Highlights[thisResult.DID].ElementAt(0).Value.ElementAt(0); } // Add this results Paged_Results.Add(thisResult); } return(true); } catch { return(false); } }
/// <summary> Perform an search for documents with matching parameters </summary> /// <param name="AggregationCode"> Aggregation code within which to search </param> /// <param name="QueryString"> Quert string for the actual search to perform aggainst the Solr/Lucene engine </param> /// <param name="ResultsPerPage"> Number of results to display per a "page" of results </param> /// <param name="Page_Number"> Which page of results to return ( one-based, so the first page is page number of one )</param> /// <param name="Sort"> Sort to apply before returning the results of the search </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="Complete_Result_Set_Info"> [OUT] Information about the entire set of results </param> /// <param name="Paged_Results"> [OUT] List of search results for the requested page of results </param> /// <returns> Page search result object with all relevant result information </returns> public static bool Search(string AggregationCode, string QueryString, int ResultsPerPage, int Page_Number, ushort Sort, Custom_Tracer Tracer, out Search_Results_Statistics Complete_Result_Set_Info, out List <iSearch_Title_Result> Paged_Results) { if (Tracer != null) { Tracer.Add_Trace("Solr_Documents_Searcher.Search", String.Empty); } // Set output initially to null Paged_Results = new List <iSearch_Title_Result>(); Complete_Result_Set_Info = null; try { // Ensure page is not erroneously set to zero or negative if (Page_Number <= 0) { Page_Number = 1; } // Create the solr worker to query the document index var solrWorker = Solr_Operations_Cache <Solr_Document_Result> .GetSolrOperations(Engine_ApplicationCache_Gateway.Settings.Servers.Document_Solr_Index_URL); // Create the query options QueryOptions options = new QueryOptions { Rows = ResultsPerPage, Start = (Page_Number - 1) * ResultsPerPage, Fields = new[] { "did", "score", "url", "aleph", "donor", "edition", "format", "holdinglocation", "sourceinstitution", "maintitle", "materialtype", "oclc", "pubdate_display", "author_display", "publisher_display", "mainthumbnail" }, Highlight = new HighlightingParameters { Fields = new[] { "fulltext" }, }, ExtraParams = new Dictionary <string, string> { { "hl.useFastVectorHighlighter", "true" } } }; // Set the sort value if (Sort != 0) { options.OrderBy.Clear(); switch (Sort) { case 1: options.OrderBy.Add(new SortOrder("maintitle_sort")); break; case 2: options.OrderBy.Add(new SortOrder("bibid", Order.ASC)); break; case 3: options.OrderBy.Add(new SortOrder("bibid", Order.DESC)); break; case 10: options.OrderBy.Add(new SortOrder("pubdate", Order.ASC)); break; case 11: options.OrderBy.Add(new SortOrder("pubdate", Order.DESC)); break; } } // If there was an aggregation code included, put that at the beginning of the search if ((AggregationCode.Length > 0) && (AggregationCode.ToUpper() != "ALL")) { QueryString = "(aggregation_code:" + AggregationCode.ToUpper() + ")AND(" + QueryString + ")"; } // Perform this search SolrQueryResults <Solr_Document_Result> results = solrWorker.Query(QueryString, options); // Create the search statistcs List <string> metadataLabels = new List <string> { "Author", "Publisher", "Format", "Edition", "Institution", "Donor" }; Complete_Result_Set_Info = new Search_Results_Statistics(metadataLabels) { Total_Titles = results.NumFound, Total_Items = results.NumFound, QueryTime = results.Header.QTime }; // Pass all the results into the List and add the highlighted text to each result as well foreach (Solr_Document_Result thisResult in results) { // Add the highlight snipper if ((results.Highlights.ContainsKey(thisResult.DID)) && (results.Highlights[thisResult.DID].Count > 0) && (results.Highlights[thisResult.DID].ElementAt(0).Value.Count > 0)) { thisResult.Snippet = results.Highlights[thisResult.DID].ElementAt(0).Value.ElementAt(0); } // Add this results Paged_Results.Add(thisResult); } return(true); } catch { return(false); } }
/// <summary> Gets the browse or info object and any other needed data for display ( text to display) </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Aggregation_Object"> Item Aggregation object</param> /// <param name="Base_Directory"> Base directory location under which the the CMS/info source file will be found</param> /// <param name="Current_User"> Currently logged on user, which can determine which items to show </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="Browse_Object"> [OUT] Stores all the information about this browse or info </param> /// <param name="Complete_Result_Set_Info"> [OUT] Information about the entire set of results </param> /// <param name="Paged_Results"> [OUT] List of search results for the requested page of results </param> /// <param name="Browse_Info_Display_Text"> [OUT] Static HTML-based content to be displayed if this is browing a staticly created html source file </param> /// <returns> TRUE if successful, otherwise FALSE </returns> /// <remarks> This attempts to pull the objects from the cache. If unsuccessful, it builds the objects from the /// database and hands off to the <see cref="CachedDataManager" /> to store in the cache </remarks> protected static bool Get_Browse_Info(Navigation_Object Current_Mode, Item_Aggregation Aggregation_Object, string Base_Directory, User_Object Current_User, Custom_Tracer Tracer, out Item_Aggregation_Child_Page Browse_Object, out Search_Results_Statistics Complete_Result_Set_Info, out List <iSearch_Title_Result> Paged_Results, out HTML_Based_Content Browse_Info_Display_Text) { if (Tracer != null) { Tracer.Add_Trace("abstractHtmlSubwriter.Get_Browse_Info", String.Empty); } // Set output initially to null Paged_Results = null; Complete_Result_Set_Info = null; Browse_Info_Display_Text = null; // First, make sure the browse submode is valid Browse_Object = Aggregation_Object.Child_Page_By_Code(Current_Mode.Info_Browse_Mode); if (Browse_Object == null) { Current_Mode.Error_Message = "Unable to retrieve browse/info item '" + Current_Mode.Info_Browse_Mode + "'"; return(false); } // Is this a table result, or a string? switch (Browse_Object.Source_Data_Type) { case Item_Aggregation_Child_Source_Data_Enum.Database_Table: // Set the current sort to ZERO, if currently set to ONE and this is an ALL BROWSE. // Those two sorts are the same in this case int sort = Current_Mode.Sort.HasValue ? Math.Max(Current_Mode.Sort.Value, ((ushort)1)) : 1; if ((sort == 0) && (Browse_Object.Code == "all")) { sort = 1; } // Special code if this is a JSON browse string browse_code = Current_Mode.Info_Browse_Mode; if (Current_Mode.Writer_Type == Writer_Type_Enum.JSON) { browse_code = browse_code + "_JSON"; sort = 12; } // Get the page count in the results int current_page_index = Current_Mode.Page.HasValue ? Math.Max(Current_Mode.Page.Value, ((ushort)1)) : 1; // Determine if this is a special search type which returns more rows and is not cached. // This is used to return the results as XML and DATASET bool special_search_type = false; int results_per_page = 20; if ((Current_Mode.Writer_Type == Writer_Type_Enum.XML) || (Current_Mode.Writer_Type == Writer_Type_Enum.DataSet)) { results_per_page = 1000000; special_search_type = true; sort = 2; // Sort by BibID always for these } Tracer.Add_Trace("abstractHtmlSubwriter.Get_Browse_Info", "Current_Mode.Writer_Type=[" + Current_Mode.Writer_Type.ToString() + "]."); Tracer.Add_Trace("abstractHtmlSubwriter.Get_Browse_Info", "Current_Mode.Results_Display_Type=[" + Current_Mode.Result_Display_Type + "]."); if (String.Equals(Current_Mode.Result_Display_Type, "timeline", StringComparison.OrdinalIgnoreCase)) { Tracer.Add_Trace("abstractHtmlSubwriter.Get_Browse_Info", "Is timeline, setting browse results_per_page and sort."); results_per_page = 20000; sort = 12; } // Set the flags for how much data is needed. (i.e., do we need to pull ANYTHING? or // perhaps just the next page of results ( as opposed to pulling facets again). bool need_browse_statistics = true; bool need_paged_results = true; if ((!special_search_type) && (Current_User == null)) { // Look to see if the browse statistics are available on any cache for this browse Complete_Result_Set_Info = CachedDataManager.Retrieve_Browse_Result_Statistics(Aggregation_Object.Code, browse_code, Tracer); if (Complete_Result_Set_Info != null) { need_browse_statistics = false; } // Look to see if the paged results are available on any cache.. Paged_Results = CachedDataManager.Retrieve_Browse_Results(Aggregation_Object.Code, browse_code, current_page_index, sort, (uint)results_per_page, Tracer); if (Paged_Results != null) { need_paged_results = false; } } // Was a copy found in the cache? if ((!need_browse_statistics) && (!need_paged_results)) { if (Tracer != null) { Tracer.Add_Trace("SobekCM_Assistant.Get_Browse_Info", "Browse statistics and paged results retrieved from cache"); } } else { if (Tracer != null) { Tracer.Add_Trace("SobekCM_Assistant.Get_Browse_Info", "Building results information"); } // Try to pull more than one page, so we can cache the next page or so List <List <iSearch_Title_Result> > pagesOfResults; // Get from the hierarchy object Multiple_Paged_Results_Args returnArgs = Item_Aggregation_Utilities.Get_Browse_Results(Aggregation_Object, Browse_Object, current_page_index, sort, results_per_page, !special_search_type, need_browse_statistics, Current_User, Tracer); if (need_browse_statistics) { Complete_Result_Set_Info = returnArgs.Statistics; } pagesOfResults = returnArgs.Paged_Results; if ((pagesOfResults != null) && (pagesOfResults.Count > 0)) { Paged_Results = pagesOfResults[0]; } // Save the overall result set statistics to the cache if something was pulled if ((!special_search_type) && (Current_User == null)) { if ((need_browse_statistics) && (Complete_Result_Set_Info != null)) { CachedDataManager.Store_Browse_Result_Statistics(Aggregation_Object.Code, browse_code, Complete_Result_Set_Info, Tracer); } // Save the overall result set statistics to the cache if something was pulled if ((need_paged_results) && (Paged_Results != null)) { CachedDataManager.Store_Browse_Results(Aggregation_Object.Code, browse_code, current_page_index, sort, (uint)results_per_page, pagesOfResults, Tracer); } } } break; case Item_Aggregation_Child_Source_Data_Enum.Static_HTML: Browse_Info_Display_Text = SobekEngineClient.Aggregations.Get_Aggregation_HTML_Child_Page(Aggregation_Object.Code, Aggregation_Object.Language, UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language, Browse_Object.Code, Tracer); break; } return(true); }
/// <summary> Constructor for a new instance of the Admin_HtmlSubwriter class </summary> /// <param name="Results_Statistics"> Information about the entire set of results for a browse of a user's bookshelf folder </param> /// <param name="Paged_Results"> Single page of results for a browse of a user's bookshelf folder, within the entire set </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item">Current item to edit, if the user is requesting to edit an item</param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations </param> /// <param name="Web_Skin_Collection"> Collection of all the web skins </param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="IP_Restrictions"> List of all IP Restriction ranges in use by this digital library </param> /// <param name="URL_Portals"> List of all web portals into this system </param> /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </param> /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public Admin_HtmlSubwriter(Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object All_Items_Lookup, Item_Aggregation Hierarchy_Object, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Dictionary <string, string> Aggregation_Aliases, SobekCM_Skin_Collection Web_Skin_Collection, User_Object Current_User, IP_Restriction_Ranges IP_Restrictions, Dictionary <string, Wordmark_Icon> Icon_Table, Portal_List URL_Portals, Statistics_Dates Stats_Date_Range, List <Thematic_Heading> Thematic_Headings, Custom_Tracer Tracer) { Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Saving values and geting user object back from the session"); resultsStatistics = Results_Statistics; pagedResults = Paged_Results; codeManager = Code_Manager; itemList = All_Items_Lookup; htmlSkin = HTML_Skin; translator = Translator; currentCollection = Hierarchy_Object; currentItem = Current_Item; user = Current_User; ipRestrictions = IP_Restrictions; iconTable = Icon_Table; statsDates = Stats_Date_Range; if (Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Log_Out) { Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Performing logout"); HttpContext.Current.Session["user"] = null; HttpContext.Current.Response.Redirect("?"); } if ((Current_Mode.My_Sobek_Type != My_Sobek_Type_Enum.Logon) && (user != null) && (user.Is_Temporary_Password)) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.New_Password; } if (Current_Mode.Logon_Required) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Logon; } // If the user is not an admin, and admin was selected, reroute this if ((!Current_User.Is_System_Admin) && (!Current_User.Is_Portal_Admin)) { Current_Mode.Mode = Display_Mode_Enum.My_Sobek; Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; Current_Mode.My_Sobek_SubMode = String.Empty; HttpContext.Current.Response.Redirect(Current_Mode.Redirect_URL()); } Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Building the my sobek viewer object"); switch (Current_Mode.Admin_Type) { case Admin_Type_Enum.Aggregation_Single: adminViewer = new Aggregation_Single_AdminViewer(user, Current_Mode, codeManager, Thematic_Headings, Web_Skin_Collection, Tracer); break; case Admin_Type_Enum.Home: adminViewer = new Home_AdminViewer(user, Current_Mode, Tracer); break; case Admin_Type_Enum.Builder_Status: adminViewer = new Builder_AdminViewer(user, Current_Mode); break; case Admin_Type_Enum.Interfaces: adminViewer = new Skins_AdminViewer(user, Current_Mode, Web_Skin_Collection, Tracer); break; case Admin_Type_Enum.Forwarding: adminViewer = new Aliases_AdminViewer(user, Current_Mode, Aggregation_Aliases, Tracer); break; case Admin_Type_Enum.Wordmarks: adminViewer = new Wordmarks_AdminViewer(user, Current_Mode, Tracer); break; case Admin_Type_Enum.URL_Portals: adminViewer = new Portals_AdminViewer(user, Current_Mode, URL_Portals, Tracer); break; case Admin_Type_Enum.Users: adminViewer = new Users_AdminViewer(user, Current_Mode, codeManager, Tracer); break; case Admin_Type_Enum.User_Groups: adminViewer = new User_Group_AdminViewer(user, Current_Mode, codeManager, Tracer); break; case Admin_Type_Enum.Aggregations_Mgmt: adminViewer = new Aggregations_Mgmt_AdminViewer(user, Current_Mode, codeManager, Tracer); break; case Admin_Type_Enum.IP_Restrictions: adminViewer = new IP_Restrictions_AdminViewer(user, Current_Mode, ipRestrictions, Tracer); break; case Admin_Type_Enum.Thematic_Headings: adminViewer = new Thematic_Headings_AdminViewer(user, Current_Mode, Thematic_Headings, Tracer); break; case Admin_Type_Enum.Settings: adminViewer = new Settings_AdminViewer(user, Current_Mode, Tracer); break; case Admin_Type_Enum.Projects: if (Current_Mode.My_Sobek_SubMode.Length > 1) { string project_code = Current_Mode.My_Sobek_SubMode.Substring(1); Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Checking cache for valid project file"); if (user != null) { SobekCM_Item projectObject = Cached_Data_Manager.Retrieve_Project(user.UserID, project_code, Tracer); if (projectObject != null) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Valid project file found in cache"); adminViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, projectObject, codeManager, iconTable, htmlSkin, Tracer); } else { if (SobekCM_Database.Get_All_Projects_Templates(Tracer).Tables[0].Select("ProjectCode='" + project_code + "'").Length > 0) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Building project file from (possible) PMETS"); string pmets_file = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\" + Current_Mode.My_Sobek_SubMode.Substring(1) + ".pmets"; SobekCM_Item pmets_item = File.Exists(pmets_file) ? SobekCM_Item.Read_METS(pmets_file) : new SobekCM_Item(); pmets_item.Bib_Info.Main_Title.Title = "Project level metadata for '" + project_code + "'"; pmets_item.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Project; pmets_item.BibID = project_code.ToUpper(); pmets_item.VID = "00001"; pmets_item.Source_Directory = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\"; Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Adding project file to cache"); Cached_Data_Manager.Store_Project(user.UserID, project_code, pmets_item, Tracer); adminViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, pmets_item, codeManager, iconTable, htmlSkin, Tracer); } } } } if (adminViewer == null) { adminViewer = new Projects_AdminViewer(user, Current_Mode, Tracer); } break; } // Pass in the navigation and translator information adminViewer.CurrentMode = Current_Mode; adminViewer.Translator = translator; }