public v5_Solr_Title_Result Map_To_Result(v5_SolrDocument thisResult, List <Complete_Item_Aggregation_Metadata_Type> DisplayFields) { // Create the results v5_Solr_Title_Result resultConverted = new v5_Solr_Title_Result(); resultConverted.MaterialType = thisResult.Type; // Get the bibid resultConverted.BibID = thisResult.DID.Substring(0, 10); // For now... resultConverted.GroupThumbnail = thisResult.MainThumbnail; resultConverted.GroupTitle = thisResult.Title ?? "NO TITLE"; // These should not really be necessary resultConverted.Primary_Identifier = String.Empty; resultConverted.Primary_Identifier_Type = String.Empty; resultConverted.Snippet = String.Empty; // Add the item v5_Solr_Item_Result itemResult = new v5_Solr_Item_Result(); itemResult.VID = thisResult.DID.Substring(11, 5); itemResult.Title = thisResult.Title ?? "NO TITLE"; itemResult.MainThumbnail = thisResult.MainThumbnail; resultConverted.Items.Add(itemResult); // Build the display results values List <string> display_result_fields = new List <string>(); foreach (Complete_Item_Aggregation_Metadata_Type metadataField in DisplayFields) { display_result_fields.Add(data_from_display_field(thisResult, metadataField.SolrCode) ?? String.Empty); } resultConverted.Metadata_Display_Values = display_result_fields.ToArray(); return(resultConverted); }
/// <summary> Indexes a single digital resource within a SobekCM library </summary> /// <param name="SolrDocumentUrl"> URL for the solr/lucene core used for searching for a single document within the library </param> /// <param name="SolrPageUrl"> URL for the solr/lucene core used for searching within a single document for matching pages </param> /// <param name="Resource"> Digital resource to index</param> /// <param name="Include_Text"> Flag indicates whether to look for and include full text </param> public void Update_Index(string SolrDocumentUrl, string SolrPageUrl, SobekCM_Item Resource, bool Include_Text) { // Get rid of trailling '/' in solr document url SolrDocumentUrl = SolrDocumentUrl.Trim(); if ((!String.IsNullOrEmpty(SolrDocumentUrl)) && (SolrDocumentUrl[SolrDocumentUrl.Length - 1] == '/')) { SolrDocumentUrl = SolrDocumentUrl.Substring(0, SolrDocumentUrl.Length - 1); } // Get rid of trailling '/' in solr page url SolrPageUrl = SolrPageUrl.Trim(); if ((!String.IsNullOrEmpty(SolrPageUrl)) && (SolrPageUrl[SolrPageUrl.Length - 1] == '/')) { SolrPageUrl = SolrPageUrl.Substring(0, SolrPageUrl.Length - 1); } // Create the solr workers var solrDocumentWorker = Solr_Operations_Cache <v5_SolrDocument> .GetSolrOperations(SolrDocumentUrl); var solrPageWorker = Solr_Operations_Cache <Legacy_SolrPage> .GetSolrOperations(SolrPageUrl); // Get the list of all items in this collection List <v5_SolrDocument> index_files = new List <v5_SolrDocument>(); List <Legacy_SolrPage> index_pages = new List <Legacy_SolrPage>(); // Add this document to the list of documents to index v5_SolrDocument_Builder builder = new v5_SolrDocument_Builder(); v5_SolrDocument solrDocument = builder.Build_Solr_Document(Resource, Resource.Source_Directory); index_files.Add(solrDocument); bool document_success = false; int document_attempts = 0; while (!document_success) { try { solrDocumentWorker.AddRange(index_files); document_success = true; } catch (Exception ee) { if (document_attempts > 5) { throw; } document_attempts++; Console.WriteLine(@"ERROR {0}", document_attempts); Thread.Sleep(document_attempts * 1000); } } // Add each page to be indexed foreach (v5_SolrDocument document in index_files) { index_pages.AddRange(document.Solr_Pages); } bool page_success = false; int page_attempts = 0; while (!page_success) { try { solrPageWorker.Add(index_pages); page_success = true; } catch (Exception ee) { if (page_attempts > 5) { throw; } page_attempts++; Thread.Sleep(page_attempts * 1000); } } // Comit the changes to the solr/lucene index try { solrDocumentWorker.Commit(); } catch (Exception ee) { Thread.Sleep(10 * 60 * 1000); } try { solrPageWorker.Commit(); } catch (Exception ee) { Thread.Sleep(10 * 60 * 1000); } }
private static string data_from_display_field(v5_SolrDocument SolrDocument, string SolrDisplayField) { switch (SolrDisplayField.ToLower()) { case "date": case "date.display": return(SolrDocument.DateDisplay); case "timeline_date": return(SolrDocument.TimelineDate.ToString()); case "timeline_date.display": return(SolrDocument.TimelineDateDisplay); case "title": return(SolrDocument.Title); case "type": return(SolrDocument.Type); case "language": return(collection_to_string(SolrDocument.Language)); case "creator.display": return(collection_to_string(SolrDocument.Creator_Display)); case "publisher.display": return(collection_to_string(SolrDocument.Publisher_Display)); case "publication_place": return(collection_to_string(SolrDocument.PubPlace)); case "subject.display": return(collection_to_string(SolrDocument.SubjectDisplay)); case "genre.display": return(collection_to_string(SolrDocument.GenreDisplay)); case "audience": return(collection_to_string(SolrDocument.Audience)); case "spatial_standard.display": return(collection_to_string(SolrDocument.SpatialDisplay)); case "country": return(collection_to_string(SolrDocument.Country)); case "state": return(collection_to_string(SolrDocument.State)); case "county": return(collection_to_string(SolrDocument.County)); case "city": return(collection_to_string(SolrDocument.City)); case "source": return(SolrDocument.Source); case "holding": return(SolrDocument.Holding); case "identifier.display": return(collection_to_string(SolrDocument.IdentifierDisplay)); case "notes": return(collection_to_string(SolrDocument.Notes)); case "other": return(collection_to_string(SolrDocument.OtherCitation)); case "tickler": return(collection_to_string(SolrDocument.Tickler)); case "donor": return(SolrDocument.Donor); case "format": return(SolrDocument.Format); case "bibid": return(SolrDocument.BibID); case "publication date": return(SolrDocument.Date); case "affiliation": return(collection_to_string(SolrDocument.Affiliation)); case "frequency": return(collection_to_string(SolrDocument.Frequency)); case "name_as_subject.display": return(collection_to_string(SolrDocument.NameAsSubjectDisplay)); case "title_as_subject.display": return(collection_to_string(SolrDocument.TitleAsSubjectDisplay)); case "all subjects": return(collection_to_string(SolrDocument.SubjectDisplay)); case "temporal subject": return(String.Empty); case "attribution": return(SolrDocument.Attribution); case "user description": return(String.Empty); case "temporal decade": return(String.Empty); case "mime_type": return(collection_to_string(SolrDocument.MimeType)); case "tracking_box": return(collection_to_string(SolrDocument.TrackingBox)); case "abstract": return(collection_to_string(SolrDocument.Abstract)); case "edition": return(SolrDocument.Edition); case "zt_kingdom": return(collection_to_string(SolrDocument.ZoologicalKingdom)); case "zt_phylum": return(collection_to_string(SolrDocument.ZoologicalPhylum)); case "zt_class": return(collection_to_string(SolrDocument.ZoologicalClass)); case "zt_order": return(collection_to_string(SolrDocument.ZoologicalOrder)); case "zt_family": return(collection_to_string(SolrDocument.ZoologicalFamily)); case "zt_genus": return(collection_to_string(SolrDocument.ZoologicalGenus)); case "zt_species": return(collection_to_string(SolrDocument.ZoologicalSpecies)); case "zt_common_name": return(collection_to_string(SolrDocument.ZoologicalCommonName)); case "zt_scientific_name": return(collection_to_string(SolrDocument.ZoologicalScientificName)); case "zt all taxonomy": return(collection_to_string(SolrDocument.ZoologicalHierarchical)); case "cultural_context": return(collection_to_string(SolrDocument.CulturalContext)); case "inscription": return(collection_to_string(SolrDocument.Inscription)); case "material": return(collection_to_string(SolrDocument.Material)); case "style_period": return(collection_to_string(SolrDocument.StylePeriod)); case "technique": return(collection_to_string(SolrDocument.Technique)); case "accession_number.display": return(SolrDocument.AccessionNumberDisplay); case "etd_committee": return(collection_to_string(SolrDocument.EtdCommittee)); case "etd_degree": return(SolrDocument.EtdDegree); case "etd_degree_discipline": return(SolrDocument.EtdDegreeDiscipline); case "etd_degree_grantor": return(SolrDocument.EtdDegreeGrantor); case "etd_degree_level": return(SolrDocument.EtdDegreeLevel); case "temporal year": return(String.Empty); case "interviewee": return(collection_to_string(SolrDocument.Interviewee)); case "interviewer": return(collection_to_string(SolrDocument.Interviewer)); case "user_defined_01.display": return(collection_to_string(SolrDocument.UserDefinedDisplay01)); case "user_defined_02.display": return(collection_to_string(SolrDocument.UserDefinedDisplay02)); case "user_defined_03.display": return(collection_to_string(SolrDocument.UserDefinedDisplay03)); case "user_defined_04.display": return(collection_to_string(SolrDocument.UserDefinedDisplay04)); case "user_defined_05.display": return(collection_to_string(SolrDocument.UserDefinedDisplay05)); case "user_defined_06.display": return(collection_to_string(SolrDocument.UserDefinedDisplay06)); case "user_defined_07.display": return(collection_to_string(SolrDocument.UserDefinedDisplay07)); case "user_defined_08.display": return(collection_to_string(SolrDocument.UserDefinedDisplay08)); case "user_defined_09.display": return(collection_to_string(SolrDocument.UserDefinedDisplay09)); case "user_defined_10.display": return(collection_to_string(SolrDocument.UserDefinedDisplay10)); case "user_defined_11.display": return(collection_to_string(SolrDocument.UserDefinedDisplay11)); case "user_defined_12.display": return(collection_to_string(SolrDocument.UserDefinedDisplay12)); case "user_defined_13.display": return(collection_to_string(SolrDocument.UserDefinedDisplay13)); case "user_defined_14.display": return(collection_to_string(SolrDocument.UserDefinedDisplay14)); case "user_defined_15.display": return(collection_to_string(SolrDocument.UserDefinedDisplay15)); case "user_defined_16.display": return(collection_to_string(SolrDocument.UserDefinedDisplay16)); case "user_defined_17.display": return(collection_to_string(SolrDocument.UserDefinedDisplay17)); case "user_defined_18.display": return(collection_to_string(SolrDocument.UserDefinedDisplay18)); case "user_defined_19.display": return(collection_to_string(SolrDocument.UserDefinedDisplay19)); case "user_defined_20.display": return(collection_to_string(SolrDocument.UserDefinedDisplay20)); case "user_defined_21.display": return(collection_to_string(SolrDocument.UserDefinedDisplay21)); case "user_defined_22.display": return(collection_to_string(SolrDocument.UserDefinedDisplay22)); case "user_defined_23.display": return(collection_to_string(SolrDocument.UserDefinedDisplay23)); case "user_defined_24.display": return(collection_to_string(SolrDocument.UserDefinedDisplay24)); case "user_defined_25.display": return(collection_to_string(SolrDocument.UserDefinedDisplay25)); case "user_defined_26.display": return(collection_to_string(SolrDocument.UserDefinedDisplay26)); case "user_defined_27.display": return(collection_to_string(SolrDocument.UserDefinedDisplay27)); case "user_defined_28.display": return(collection_to_string(SolrDocument.UserDefinedDisplay28)); case "user_defined_29.display": return(collection_to_string(SolrDocument.UserDefinedDisplay29)); case "user_defined_30.display": return(collection_to_string(SolrDocument.UserDefinedDisplay30)); case "user_defined_31.display": return(collection_to_string(SolrDocument.UserDefinedDisplay31)); case "user_defined_32.display": return(collection_to_string(SolrDocument.UserDefinedDisplay32)); case "user_defined_33.display": return(collection_to_string(SolrDocument.UserDefinedDisplay33)); case "user_defined_34.display": return(collection_to_string(SolrDocument.UserDefinedDisplay34)); case "user_defined_35.display": return(collection_to_string(SolrDocument.UserDefinedDisplay35)); case "user_defined_36.display": return(collection_to_string(SolrDocument.UserDefinedDisplay36)); case "user_defined_37.display": return(collection_to_string(SolrDocument.UserDefinedDisplay37)); case "user_defined_38.display": return(collection_to_string(SolrDocument.UserDefinedDisplay38)); case "user_defined_39.display": return(collection_to_string(SolrDocument.UserDefinedDisplay39)); case "user_defined_40.display": return(collection_to_string(SolrDocument.UserDefinedDisplay40)); case "user_defined_41.display": return(collection_to_string(SolrDocument.UserDefinedDisplay41)); case "user_defined_42.display": return(collection_to_string(SolrDocument.UserDefinedDisplay42)); case "user_defined_43.display": return(collection_to_string(SolrDocument.UserDefinedDisplay43)); case "user_defined_44.display": return(collection_to_string(SolrDocument.UserDefinedDisplay44)); case "user_defined_45.display": return(collection_to_string(SolrDocument.UserDefinedDisplay45)); case "user_defined_46.display": return(collection_to_string(SolrDocument.UserDefinedDisplay46)); case "user_defined_47.display": return(collection_to_string(SolrDocument.UserDefinedDisplay47)); case "user_defined_48.display": return(collection_to_string(SolrDocument.UserDefinedDisplay48)); case "user_defined_49.display": return(collection_to_string(SolrDocument.UserDefinedDisplay49)); case "user_defined_50.display": return(collection_to_string(SolrDocument.UserDefinedDisplay50)); case "user_defined_51.display": return(collection_to_string(SolrDocument.UserDefinedDisplay51)); case "user_defined_52.display": return(collection_to_string(SolrDocument.UserDefinedDisplay52)); case "measurements": return(collection_to_string(SolrDocument.Measurements)); case "aggregations": return(collection_to_string(SolrDocument.Aggregations)); case "lom_aggregation": return(SolrDocument.LomAggregation); case "lom_context.display": return(collection_to_string(SolrDocument.LomContextDisplay)); case "lom_classification.display": return(collection_to_string(SolrDocument.LomClassification)); case "lom_difficulty": return(SolrDocument.LomDifficulty); case "lom_intended_end_user.display": return(SolrDocument.LomIntendedEndUserDisplay); case "lom_interactivity_level": return(SolrDocument.LomInteractivityLevel); case "lom_interactivity_type": return(SolrDocument.LomInteractivityType); case "lom_status": return(SolrDocument.LomStatus); case "lom_requirement.display": return(collection_to_string(SolrDocument.LomRequirementDisplay)); case "lom_age_range": return(collection_to_string(SolrDocument.LomAgeRange)); case "etd_degree_division": return(SolrDocument.EtdDegreeDivision); case "performance.display": return(SolrDocument.PerformanceDisplay); case "performance_date": return(SolrDocument.PerformanceDate); case "performer.display": return(collection_to_string(SolrDocument.PerformerDisplay)); case "lom_resource_type.display": return(collection_to_string(SolrDocument.LomResourceTypeDisplay)); case "lom_learning_time": return(SolrDocument.LomLearningTime); } return(String.Empty); }
/// <summary> Build the solr document from the SobekCM Digital Resource object </summary> /// <param name="Digital_Object"> Digital object to create an easily indexable view object for </param> /// <param name="File_Location"> Location for all of the text files associated with this item </param> /// <returns> Fully built (v5) solr document </returns> public v5_SolrDocument Build_Solr_Document(SobekCM_Item Digital_Object, string File_Location) { // Start the return object v5_SolrDocument returnValue = new v5_SolrDocument(); returnValue.FileLocation = File_Location; // Set the unique key returnValue.DID = Digital_Object.BibID + ":" + Digital_Object.VID; // Add the administrative fields returnValue.Aggregations = new List <string>(); returnValue.Aggregations.AddRange(Digital_Object.Behaviors.Aggregation_Code_List); returnValue.BibID = Digital_Object.BibID; returnValue.VID = Digital_Object.VID; returnValue.MainThumbnail = Digital_Object.Behaviors.Main_Thumbnail; // Add the made public field if (Digital_Object.Web.MadePublicDate.HasValue) { returnValue.MadePublicDate = Digital_Object.Web.MadePublicDate.Value; } else { // If this is public and non-dark, but no date for made // public exists, make it today if ((!Digital_Object.Behaviors.Dark_Flag) && (Digital_Object.Behaviors.IP_Restriction_Membership >= 0)) { Digital_Object.Web.MadePublicDate = DateTime.Now; } } // Add Serial hierarchy fields returnValue.Level1_Text = String.Empty; returnValue.Level1_Index = -1; returnValue.Level1_Facet = "NONE"; returnValue.Level2_Text = String.Empty; returnValue.Level2_Index = -1; returnValue.Level2_Facet = "NONE"; returnValue.Level3_Text = String.Empty; returnValue.Level3_Index = -1; returnValue.Level3_Facet = "NONE"; returnValue.Level4_Text = String.Empty; returnValue.Level4_Index = -1; returnValue.Level4_Facet = "NONE"; returnValue.Level5_Text = String.Empty; returnValue.Level5_Index = -1; returnValue.Level5_Facet = "NONE"; if (Digital_Object.Behaviors != null) { if (Digital_Object.Behaviors.Serial_Info.Count > 0) { returnValue.Level1_Index = Digital_Object.Behaviors.Serial_Info[0].Order; returnValue.Level1_Text = Digital_Object.Behaviors.Serial_Info[0].Display; returnValue.Level1_Text_Display = Digital_Object.Behaviors.Serial_Info[0].Display; returnValue.Level1_Facet = Digital_Object.Behaviors.Serial_Info[0].Order.ToString().PadLeft(5, '0') + '|' + Digital_Object.Behaviors.Serial_Info[0].Display; } if (Digital_Object.Behaviors.Serial_Info.Count > 1) { returnValue.Level2_Index = Digital_Object.Behaviors.Serial_Info[1].Order; returnValue.Level2_Text = Digital_Object.Behaviors.Serial_Info[1].Display; returnValue.Level2_Text_Display = Digital_Object.Behaviors.Serial_Info[1].Display; returnValue.Level2_Facet = Digital_Object.Behaviors.Serial_Info[1].Order.ToString().PadLeft(5, '0') + '|' + Digital_Object.Behaviors.Serial_Info[1].Display; } if (Digital_Object.Behaviors.Serial_Info.Count > 2) { returnValue.Level3_Index = Digital_Object.Behaviors.Serial_Info[2].Order; returnValue.Level3_Text = Digital_Object.Behaviors.Serial_Info[2].Display; returnValue.Level3_Text_Display = Digital_Object.Behaviors.Serial_Info[2].Display; returnValue.Level3_Facet = Digital_Object.Behaviors.Serial_Info[2].Order.ToString().PadLeft(5, '0') + '|' + Digital_Object.Behaviors.Serial_Info[2].Display; } if (Digital_Object.Behaviors.Serial_Info.Count > 3) { returnValue.Level4_Index = Digital_Object.Behaviors.Serial_Info[3].Order; returnValue.Level4_Text = Digital_Object.Behaviors.Serial_Info[3].Display; returnValue.Level4_Text_Display = Digital_Object.Behaviors.Serial_Info[3].Display; returnValue.Level4_Facet = Digital_Object.Behaviors.Serial_Info[3].Order.ToString().PadLeft(5, '0') + '|' + Digital_Object.Behaviors.Serial_Info[3].Display; } if (Digital_Object.Behaviors.Serial_Info.Count > 4) { returnValue.Level5_Index = Digital_Object.Behaviors.Serial_Info[4].Order; returnValue.Level5_Text = Digital_Object.Behaviors.Serial_Info[4].Display; returnValue.Level5_Text_Display = Digital_Object.Behaviors.Serial_Info[4].Display; returnValue.Level5_Facet = Digital_Object.Behaviors.Serial_Info[4].Order.ToString().PadLeft(5, '0') + '|' + Digital_Object.Behaviors.Serial_Info[4].Display; } returnValue.Hidden = Digital_Object.Behaviors.Dark_Flag; } // Some defaults returnValue.Discover_Groups = new List <int> { 0 }; returnValue.Discover_Users = new List <int> { 0 }; returnValue.RestrictedMsg = String.Empty; // Set the IP restrictions based on PRIVATE or NOT if (Digital_Object.Behaviors.IP_Restriction_Membership == -1) { returnValue.Discover_IPs = new List <int> { -1 } } ; else { returnValue.Discover_IPs = new List <int> { 0 }; // If some restrictions, set the restriction message if (Digital_Object.Behaviors.IP_Restriction_Membership > 0) { returnValue.RestrictedMsg = "Access Restrictions Apply"; } } // Set the spatial KML GeoSpatial_Information geo = Digital_Object.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information; if (geo != null) { if (returnValue.SpatialFootprintKml == null) { returnValue.SpatialFootprintKml = new List <string>(); } returnValue.SpatialFootprintKml.Add(geo.SobekCM_Main_Spatial_String); returnValue.SpatialDistance = (int)geo.SobekCM_Main_Spatial_Distance; } // Get the rest of the metadata, from the item List <KeyValuePair <string, string> > searchTerms = Digital_Object.Search_Terms; // Loop through and add each data field foreach (KeyValuePair <string, string> searchTerm in searchTerms) { // Ensure there is a value here if (String.IsNullOrWhiteSpace(searchTerm.Value)) { continue; } // Assign based on the key term switch (searchTerm.Key.ToLower()) { case "title": returnValue.Title = searchTerm.Value; break; case "sort title": returnValue.SortTitle = searchTerm.Value; break; case "other title": if (returnValue.AltTitle == null) { returnValue.AltTitle = new List <string>(); } returnValue.AltTitle.Add(searchTerm.Value); break; case "translated title": if (returnValue.TranslatedTitle == null) { returnValue.TranslatedTitle = new List <string>(); } returnValue.TranslatedTitle.Add(searchTerm.Value); break; case "series title": returnValue.SeriesTitle = searchTerm.Value; break; case "other citation": if (returnValue.OtherCitation == null) { returnValue.OtherCitation = new List <string>(); } returnValue.OtherCitation.Add(searchTerm.Value); break; case "tickler": if (returnValue.Tickler == null) { returnValue.Tickler = new List <string>(); } returnValue.Tickler.Add(searchTerm.Value); break; case "abstract": if (returnValue.Abstract == null) { returnValue.Abstract = new List <string>(); } returnValue.Abstract.Add(searchTerm.Value); break; case "affililation": if (returnValue.Affiliation == null) { returnValue.Affiliation = new List <string>(); } returnValue.Affiliation.Add(searchTerm.Value); // For now, also put this in the display if (returnValue.AffiliationDisplay == null) { returnValue.AffiliationDisplay = new List <string>(); } returnValue.AffiliationDisplay.Add(searchTerm.Value); break; case "affililation display": if (returnValue.AffiliationDisplay == null) { returnValue.AffiliationDisplay = new List <string>(); } returnValue.AffiliationDisplay.Add(searchTerm.Value); break; case "genre": if (returnValue.Genre == null) { returnValue.Genre = new List <string>(); } returnValue.Genre.Add(searchTerm.Value); break; case "genre display": if (returnValue.GenreDisplay == null) { returnValue.GenreDisplay = new List <string>(); } returnValue.GenreDisplay.Add(searchTerm.Value); break; case "donor": returnValue.Donor = searchTerm.Value; break; case "identifier": if (returnValue.Identifier == null) { returnValue.Identifier = new List <string>(); } returnValue.Identifier.Add(searchTerm.Value); break; case "identifier display": if (returnValue.IdentifierDisplay == null) { returnValue.IdentifierDisplay = new List <string>(); } returnValue.IdentifierDisplay.Add(searchTerm.Value); break; case "accession number": // Set the display value (also used for faceting) to the full term returnValue.AccessionNumberDisplay = searchTerm.Value; // Make sure the list is built if (returnValue.AccessionNumber == null) { returnValue.AccessionNumber = new List <string>(); } // If there are any periods, represeting a hierarchical identifier, split it if (searchTerm.Value.IndexOf(".") > 0) { // Add each segment of the identifier string[] split = searchTerm.Value.Split(".".ToCharArray()); StringBuilder builder = new StringBuilder(split[0]); returnValue.AccessionNumber.Add(builder.ToString()); for (int i = 1; i < split.Length; i++) { builder.Append("." + split[i]); returnValue.AccessionNumber.Add(builder.ToString()); } } else { returnValue.AccessionNumber.Add(searchTerm.Value); } break; case "language": if (returnValue.Language == null) { returnValue.Language = new List <string>(); } returnValue.Language.Add(searchTerm.Value); break; case "creator": if (returnValue.Creator == null) { returnValue.Creator = new List <string>(); } returnValue.Creator.Add(searchTerm.Value); break; case "creator.display": if (returnValue.Creator_Display == null) { returnValue.Creator_Display = new List <string>(); } returnValue.Creator_Display.Add(searchTerm.Value); break; case "publisher": if (returnValue.Publisher == null) { returnValue.Publisher = new List <string>(); } returnValue.Publisher.Add(searchTerm.Value); break; case "publisher.display": if (returnValue.Publisher_Display == null) { returnValue.Publisher_Display = new List <string>(); } returnValue.Publisher_Display.Add(searchTerm.Value); break; case "holding location": returnValue.Holding = searchTerm.Value; break; case "notes": if (returnValue.Notes == null) { returnValue.Notes = new List <string>(); } returnValue.Notes.Add(searchTerm.Value); break; case "frequency": if (returnValue.Frequency == null) { returnValue.Frequency = new List <string>(); } returnValue.Frequency.Add(searchTerm.Value); break; case "edition": returnValue.Edition = searchTerm.Value; break; case "publication place": if (returnValue.PubPlace == null) { returnValue.PubPlace = new List <string>(); } returnValue.PubPlace.Add(searchTerm.Value); break; case "format": returnValue.Format = searchTerm.Value; break; case "source institution": returnValue.Source = searchTerm.Value; break; case "target audience": if (returnValue.Audience == null) { returnValue.Audience = new List <string>(); } returnValue.Audience.Add(searchTerm.Value); break; case "type": returnValue.Type = searchTerm.Value; break; case "name as subject": if (returnValue.NameAsSubject == null) { returnValue.NameAsSubject = new List <string>(); } returnValue.NameAsSubject.Add(searchTerm.Value); break; case "name as subject dispay": if (returnValue.NameAsSubjectDisplay == null) { returnValue.NameAsSubjectDisplay = new List <string>(); } returnValue.NameAsSubjectDisplay.Add(searchTerm.Value); break; case "title as subject": if (returnValue.TitleAsSubject == null) { returnValue.TitleAsSubject = new List <string>(); } returnValue.TitleAsSubject.Add(searchTerm.Value); break; case "title as subject display": if (returnValue.TitleAsSubjectDisplay == null) { returnValue.TitleAsSubjectDisplay = new List <string>(); } returnValue.TitleAsSubjectDisplay.Add(searchTerm.Value); break; case "spatial coverage": if (returnValue.Spatial == null) { returnValue.Spatial = new List <string>(); } returnValue.Spatial.Add(searchTerm.Value); break; case "spatial coverage.display": if (returnValue.SpatialDisplay == null) { returnValue.SpatialDisplay = new List <string>(); } returnValue.SpatialDisplay.Add(searchTerm.Value); break; case "country": if (returnValue.Country == null) { returnValue.Country = new List <string>(); } returnValue.Country.Add(searchTerm.Value); break; case "state": if (returnValue.State == null) { returnValue.State = new List <string>(); } returnValue.State.Add(searchTerm.Value); break; case "county": if (returnValue.County == null) { returnValue.County = new List <string>(); } returnValue.County.Add(searchTerm.Value); break; case "city": if (returnValue.City == null) { returnValue.City = new List <string>(); } returnValue.City.Add(searchTerm.Value); break; case "subject keyword": if (returnValue.Subject == null) { returnValue.Subject = new List <string>(); } returnValue.Subject.Add(searchTerm.Value.Trim()); break; case "subjects.display": if (returnValue.SubjectDisplay == null) { returnValue.SubjectDisplay = new List <string>(); } returnValue.SubjectDisplay.Add(searchTerm.Value.Trim()); break; case "publication date": returnValue.Date = searchTerm.Value; returnValue.DateDisplay = searchTerm.Value; break; case "date year": returnValue.DateYear = searchTerm.Value; break; case "toc": if (returnValue.TableOfContents == null) { returnValue.TableOfContents = new List <string>(); } returnValue.TableOfContents.Add(searchTerm.Value.Trim()); break; case "mime type": if (returnValue.MimeType == null) { returnValue.MimeType = new List <string>(); } returnValue.MimeType.Add(searchTerm.Value.Trim()); break; case "cultural context": if (returnValue.CulturalContext == null) { returnValue.CulturalContext = new List <string>(); } returnValue.CulturalContext.Add(searchTerm.Value.Trim()); break; case "inscription": if (returnValue.Inscription == null) { returnValue.Inscription = new List <string>(); } returnValue.Inscription.Add(searchTerm.Value.Trim()); break; case "materials": case "material": if (returnValue.Material == null) { returnValue.Material = new List <string>(); } returnValue.Material.Add(searchTerm.Value.Trim()); break; case "materials display": case "material display": if (returnValue.MaterialDisplay == null) { returnValue.MaterialDisplay = new List <string>(); } returnValue.MaterialDisplay.Add(searchTerm.Value.Trim()); break; case "measurements": if (returnValue.Measurements == null) { returnValue.Measurements = new List <string>(); } returnValue.Measurements.Add(searchTerm.Value.Trim()); break; case "measurements display": if (returnValue.MeasurementsDisplay == null) { returnValue.MeasurementsDisplay = new List <string>(); } returnValue.MeasurementsDisplay.Add(searchTerm.Value.Trim()); break; case "style period": if (returnValue.StylePeriod == null) { returnValue.StylePeriod = new List <string>(); } returnValue.StylePeriod.Add(searchTerm.Value.Trim()); break; case "technique": if (returnValue.Technique == null) { returnValue.Technique = new List <string>(); } returnValue.Technique.Add(searchTerm.Value.Trim()); break; case "interviewee": if (returnValue.Interviewee == null) { returnValue.Interviewee = new List <string>(); } returnValue.Interviewee.Add(searchTerm.Value.Trim()); break; case "interviewer": if (returnValue.Interviewer == null) { returnValue.Interviewer = new List <string>(); } returnValue.Interviewer.Add(searchTerm.Value.Trim()); break; case "performance": returnValue.Performance = searchTerm.Value.Trim(); // For now, we aren't setting the performance display any differently than performance returnValue.PerformanceDisplay = searchTerm.Value.Trim(); break; case "performance date": returnValue.PerformanceDate = searchTerm.Value.Trim(); break; case "performer": if (returnValue.Performer == null) { returnValue.Performer = new List <string>(); } returnValue.Performer.Add(searchTerm.Value.Trim()); // For now, we aren't setting the performer display any differently than performer if (returnValue.PerformerDisplay == null) { returnValue.PerformerDisplay = new List <string>(); } returnValue.PerformerDisplay.Add(searchTerm.Value.Trim()); break; case "etd committee": if (returnValue.EtdCommittee == null) { returnValue.EtdCommittee = new List <string>(); } returnValue.EtdCommittee.Add(searchTerm.Value.Trim()); break; case "etd degree": returnValue.EtdDegree = searchTerm.Value.Trim(); break; case "etd degree discipline": returnValue.EtdDegreeDiscipline = searchTerm.Value.Trim(); break; case "etd degree division": returnValue.EtdDegreeDivision = searchTerm.Value.Trim(); break; case "etd degree grantor": returnValue.EtdDegreeGrantor = searchTerm.Value.Trim(); break; case "etd degree level": returnValue.EtdDegreeLevel = searchTerm.Value.Trim(); break; case "zt kingdom": if (returnValue.ZoologicalKingdom == null) { returnValue.ZoologicalKingdom = new List <string>(); } returnValue.ZoologicalKingdom.Add(searchTerm.Value.Trim()); break; case "zt phylum": if (returnValue.ZoologicalPhylum == null) { returnValue.ZoologicalPhylum = new List <string>(); } returnValue.ZoologicalPhylum.Add(searchTerm.Value.Trim()); break; case "zt class": if (returnValue.ZoologicalClass == null) { returnValue.ZoologicalClass = new List <string>(); } returnValue.ZoologicalClass.Add(searchTerm.Value.Trim()); break; case "zt order": if (returnValue.ZoologicalOrder == null) { returnValue.ZoologicalOrder = new List <string>(); } returnValue.ZoologicalOrder.Add(searchTerm.Value.Trim()); break; case "zt family": if (returnValue.ZoologicalFamily == null) { returnValue.ZoologicalFamily = new List <string>(); } returnValue.ZoologicalFamily.Add(searchTerm.Value.Trim()); break; case "zt genus": if (returnValue.ZoologicalGenus == null) { returnValue.ZoologicalGenus = new List <string>(); } returnValue.ZoologicalGenus.Add(searchTerm.Value.Trim()); break; case "zt species": if (returnValue.ZoologicalSpecies == null) { returnValue.ZoologicalSpecies = new List <string>(); } returnValue.ZoologicalSpecies.Add(searchTerm.Value.Trim()); break; case "zt common name": if (returnValue.ZoologicalCommonName == null) { returnValue.ZoologicalCommonName = new List <string>(); } returnValue.ZoologicalCommonName.Add(searchTerm.Value.Trim()); break; case "zt scientific name": if (returnValue.ZoologicalScientificName == null) { returnValue.ZoologicalScientificName = new List <string>(); } returnValue.ZoologicalScientificName.Add(searchTerm.Value.Trim()); break; case "zt hierarchical": if (returnValue.ZoologicalHierarchical == null) { returnValue.ZoologicalHierarchical = new List <string>(); } returnValue.ZoologicalHierarchical.Add(searchTerm.Value.Trim()); break; // Solr already rolls up to a zt_all field, so ignore this case "zt all taxonomy": break; case "lom aggregation": returnValue.LomAggregation = searchTerm.Value.Trim(); break; case "lom context": if (returnValue.LomContext == null) { returnValue.LomContext = new List <string>(); } returnValue.LomContext.Add(searchTerm.Value.Trim()); break; case "lom context display": if (returnValue.LomContextDisplay == null) { returnValue.LomContextDisplay = new List <string>(); } returnValue.LomContextDisplay.Add(searchTerm.Value.Trim()); break; case "lom difficulty": returnValue.LomDifficulty = searchTerm.Value.Trim(); break; case "lom intended end user": if (returnValue.LomIntendedEndUser == null) { returnValue.LomIntendedEndUser = new List <string>(); } returnValue.LomIntendedEndUser.Add(searchTerm.Value.Trim()); break; case "lom intended end user display": returnValue.LomIntendedEndUserDisplay = searchTerm.Value.Trim(); break; case "lom interactivity level": returnValue.LomInteractivityLevel = searchTerm.Value.Trim(); break; case "lom interactivity type": returnValue.LomInteractivityType = searchTerm.Value.Trim(); break; case "lom status": returnValue.LomStatus = searchTerm.Value.Trim(); break; case "lom requirement": if (returnValue.LomRequirement == null) { returnValue.LomRequirement = new List <string>(); } returnValue.LomRequirement.Add(searchTerm.Value.Trim()); break; case "lom requirement display": if (returnValue.LomRequirementDisplay == null) { returnValue.LomRequirementDisplay = new List <string>(); } returnValue.LomRequirementDisplay.Add(searchTerm.Value.Trim()); break; case "lom age range": if (returnValue.LomAgeRange == null) { returnValue.LomAgeRange = new List <string>(); } returnValue.LomAgeRange.Add(searchTerm.Value.Trim()); break; case "lom resource type": if (returnValue.LomResourceType == null) { returnValue.LomResourceType = new List <string>(); } returnValue.LomResourceType.Add(searchTerm.Value.Trim()); break; case "lom resource type display": if (returnValue.LomResourceTypeDisplay == null) { returnValue.LomResourceTypeDisplay = new List <string>(); } returnValue.LomResourceTypeDisplay.Add(searchTerm.Value.Trim()); break; case "lom learning time": returnValue.LomLearningTime = searchTerm.Value.Trim(); break; case "temporal subject": returnValue.TemporalSubject = searchTerm.Value.Trim(); break; case "temporal subject display": returnValue.TemporalSubjectDisplay = searchTerm.Value.Trim(); break; // Not handled yet case "temporal year": case "ead name": break; // Ignore these case "bibid": case "vid": break; // Some more to ignore, since these are handled differently in solr case "all subjects": case "aggregation": break; default: StreamWriter writer = new StreamWriter("missing_fields.txt", true); writer.WriteLine(searchTerm.Key); writer.Flush(); writer.Close(); break; } } // Find the Gregorian date issues value string pub_date = Digital_Object.Bib_Info.Origin_Info.Date_Check_All_Fields; returnValue.Date = pub_date; returnValue.DateDisplay = pub_date; DateTime gregDate; if (DateTime.TryParse(pub_date, out gregDate)) { returnValue.Date = returnValue.Date + " (Date Auto-Converted to " + gregDate.ToShortDateString() + ")"; returnValue.GregorianDate = gregDate; returnValue.DateYear = gregDate.Year.ToString(); // For now (since temporal subject isn't the best) just use this date for the timeline returnValue.TimelineDate = gregDate; returnValue.TimelineDateDisplay = pub_date; } else { int year_only; if ((pub_date.Length == 4) && (int.TryParse(pub_date, out year_only))) { gregDate = new DateTime(year_only, 1, 1); returnValue.Date = returnValue.Date = returnValue.Date + " (Date Converted to " + gregDate.ToShortDateString() + ")"; returnValue.GregorianDate = gregDate; returnValue.DateYear = gregDate.Year.ToString(); // For now (since temporal subject isn't the best) just use this date for the timeline returnValue.TimelineDate = gregDate; returnValue.TimelineDateDisplay = pub_date; } else { returnValue.Date = returnValue.Date + " (Date NOT Converted)"; } } //// Subject metadata fields ( and also same spatial information ) //List<string> spatials = new List<string>(); //List<Subject_Info_HierarchicalGeographic> hierarhicals = new List<Subject_Info_HierarchicalGeographic>(); //if ( Digital_Object.Bib_Info.Subjects_Count > 0 ) //{ // List<string> subjects = new List<string>(); // List<string> name_as_subject = new List<string>(); // List<string> title_as_subject = new List<string>(); // // Collect the types of subjects // foreach (Subject_Info thisSubject in Digital_Object.Bib_Info.Subjects) // { // switch (thisSubject.Class_Type) // { // case Subject_Info_Type.Name: // name_as_subject.Add(thisSubject.ToString()); // break; // case Subject_Info_Type.TitleInfo: // title_as_subject.Add(thisSubject.ToString()); // break; // case Subject_Info_Type.Standard: // subjects.Add(thisSubject.ToString()); // Subject_Info_Standard standardSubj = thisSubject as Subject_Info_Standard; // if (standardSubj.Geographics_Count > 0) // { // spatials.AddRange(standardSubj.Geographics); // } // break; // case Subject_Info_Type.Hierarchical_Spatial: // hierarhicals.Add( thisSubject as Subject_Info_HierarchicalGeographic); // break; // } // } // // Now add to this document, if present // if (name_as_subject.Count > 0) // { // NameAsSubject = new List<string>(); // NameAsSubject.AddRange(name_as_subject); // } // if (title_as_subject.Count > 0) // { // TitleAsSubject = new List<string>(); // TitleAsSubject.AddRange(title_as_subject); // } // if (subjects.Count > 0) // { // Subject = new List<string>(); // Subject.AddRange(subjects); // } //} // Add the empty solr pages for now returnValue.Solr_Pages = new List <Legacy_SolrPage>(); // Prepare to step through all the divisions/pages in this item int pageorder = 1; List <abstract_TreeNode> divsAndPages = Digital_Object.Divisions.Physical_Tree.Divisions_PreOrder; // Get the list of all TXT files in this division string[] text_files = Directory.GetFiles(File_Location, "*.txt"); Dictionary <string, string> text_files_existing = new Dictionary <string, string>(); foreach (string thisTextFile in text_files) { string filename = (new FileInfo(thisTextFile)).Name.ToUpper(); text_files_existing[filename] = filename; } // Get the list of all THM.JPG files in this division string[] thumbnail_files = Directory.GetFiles(File_Location, "*thm.jpg"); Dictionary <string, string> thumbnail_files_existing = new Dictionary <string, string>(); foreach (string thisTextFile in thumbnail_files) { string filename = (new FileInfo(thisTextFile)).Name; thumbnail_files_existing[filename.ToUpper().Replace("THM.JPG", "")] = filename; } // Step through all division nodes from the physical tree here List <string> text_files_included = new List <string>(); foreach (abstract_TreeNode thisNode in divsAndPages) { if (thisNode.Page) { // Cast to a page to continnue Page_TreeNode pageNode = (Page_TreeNode)thisNode; // Look for the root filename and then look for a matching TEXT file if (pageNode.Files.Count > 0) { string root = pageNode.Files[0].File_Name_Sans_Extension; if (text_files_existing.ContainsKey(root.ToUpper() + ".TXT")) { try { // SInce this is marked to be included, save this name text_files_included.Add(root.ToUpper() + ".TXT"); // Read the page text StreamReader reader = new StreamReader(File_Location + "\\" + root + ".txt"); string pageText = reader.ReadToEnd().Trim(); reader.Close(); // Look for a matching thumbnail string thumbnail = String.Empty; if (thumbnail_files_existing.ContainsKey(root.ToUpper())) { thumbnail = thumbnail_files_existing[root.ToUpper()]; } Legacy_SolrPage newPage = new Legacy_SolrPage(Digital_Object.BibID, Digital_Object.VID, pageorder, pageNode.Label, pageText, thumbnail); returnValue.Solr_Pages.Add(newPage); } catch { } } } // Increment the page order for the next page irregardless pageorder++; } } // Now, check for any other valid text files returnValue.AdditionalTextFiles = new List <string>(); foreach (string thisTextFile in text_files_existing.Keys) { if ((!text_files_included.Contains(thisTextFile.ToUpper())) && (thisTextFile.ToUpper() != "AGREEMENT.TXT") && (thisTextFile.ToUpper().IndexOf("REQUEST") != 0)) { returnValue.AdditionalTextFiles.Add(thisTextFile); } } return(returnValue); }