/// <summary> Stream to which to write the HTML for this subwriter </summary> /// <param name="Output"> Response stream for the item viewer to write directly to </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public override void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("EAD_Description_ItemViewer.Write_Main_Viewer_Section", ""); } // Get the metadata module for EADs EAD_Info eadInfo = (EAD_Info)CurrentItem.Get_Metadata_Module(GlobalVar.EAD_METADATA_MODULE_KEY); // Build the value Output.WriteLine(" <td>"); Output.WriteLine(" <div id=\"sbkEad_MainArea\">"); if (CurrentMode.Text_Search.Length > 0) { // Get any search terms List <string> terms = new List <string>(); if (CurrentMode.Text_Search.Trim().Length > 0) { string[] splitter = CurrentMode.Text_Search.Replace("\"", "").Split(" ".ToCharArray()); terms.AddRange(from thisSplit in splitter where thisSplit.Trim().Length > 0 select thisSplit.Trim()); } Output.Write(Text_Search_Term_Highlighter.Hightlight_Term_In_HTML(eadInfo.Full_Description, terms)); } else { Output.Write(eadInfo.Full_Description); } Output.WriteLine(" </div>"); Output.WriteLine(" </td>"); }
/// <summary> Adds the main view section to the page turner </summary> /// <param name="placeHolder"> Main place holder ( "mainPlaceHolder" ) in the itemNavForm form into which the the bulk of the item viewer's output is displayed</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public override void Add_Main_Viewer_Section(PlaceHolder placeHolder, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("EAD_Description_ItemViewer.Add_Main_Viewer_Section", "Adds one literal with all the html"); } // Get the metadata module for EADs EAD_Info eadInfo = (EAD_Info)CurrentItem.Get_Metadata_Module(GlobalVar.EAD_METADATA_MODULE_KEY); // Build the value StringBuilder builder = new StringBuilder(15000); builder.AppendLine(" <td align=\"left\"><span class=\"SobekViewerTitle\">Archival Description</span></td>"); builder.AppendLine(" </tr>"); builder.AppendLine(" <tr>"); builder.AppendLine(" <td>"); builder.AppendLine(" <div class=\"SobekCitation\">"); builder.AppendLine(" <br />"); builder.AppendLine(" <blockquote>"); if (CurrentMode.Text_Search.Length > 0) { // Get any search terms List <string> terms = new List <string>(); if (CurrentMode.Text_Search.Trim().Length > 0) { string[] splitter = CurrentMode.Text_Search.Replace("\"", "").Split(" ".ToCharArray()); terms.AddRange(from thisSplit in splitter where thisSplit.Trim().Length > 0 select thisSplit.Trim()); } builder.Append(Text_Search_Term_Highlighter.Hightlight_Term_In_HTML(eadInfo.Full_Description, terms)); } else { builder.Append(eadInfo.Full_Description); } builder.AppendLine(" </blockquote>"); builder.AppendLine(" <br />"); builder.AppendLine(" </div>"); // Add the HTML for the image Literal mainLiteral = new Literal { Text = builder.ToString() }; placeHolder.Controls.Add(mainLiteral); }
/// <summary> Reads metadata from an open stream and saves to the provided item/package </summary> /// <param name="Input_Stream"> Open stream to read metadata from </param> /// <param name="Return_Package"> Package into which to read the metadata </param> /// <param name="Options"> Dictionary of any options which this metadata reader/writer may utilize </param> /// <param name="Error_Message">[OUTPUT] Explanation of the error, if an error occurs during reading </param> /// <returns>TRUE if successful, otherwise FALSE </returns> /// <remarks>This reader accepts two option values. 'EAD_File_ReaderWriter:XSL_Location' gives the location of a XSL /// file, which can be used to transform the description XML read from this EAD into HTML (or another format of XML). /// 'EAD_File_ReaderWriter:Analyze_Description' indicates whether to analyze the description section of the EAD and /// read it into the item. (Default is TRUE).</remarks> public bool Read_Metadata(Stream Input_Stream, SobekCM_Item Return_Package, Dictionary <string, object> Options, out string Error_Message) { // Ensure this metadata module extension exists EAD_Info eadInfo = Return_Package.Get_Metadata_Module(GlobalVar.EAD_METADATA_MODULE_KEY) as EAD_Info; if (eadInfo == null) { eadInfo = new EAD_Info(); Return_Package.Add_Metadata_Module(GlobalVar.EAD_METADATA_MODULE_KEY, eadInfo); } // Set a couple defaults first Return_Package.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.EAD; Return_Package.Bib_Info.Type.Collection = true; Error_Message = String.Empty; // Check for some options string XSL_Location = String.Empty; bool Analyze_Description = true; if (Options != null) { if (Options.ContainsKey("EAD_File_ReaderWriter:XSL_Location")) { XSL_Location = Options["EAD_File_ReaderWriter:XSL_Location"].ToString(); } if (Options.ContainsKey("EAD_File_ReaderWriter:Analyze_Description")) { bool.TryParse(Options["EAD_File_ReaderWriter:Analyze_Description"].ToString(), out Analyze_Description); } } // Use a string builder to seperate the description and container sections StringBuilder description_builder = new StringBuilder(20000); StringBuilder container_builder = new StringBuilder(20000); // Read through with a simple stream reader first StreamReader reader = new StreamReader(Input_Stream); string line = reader.ReadLine(); bool in_container_list = false; // Step through each line while (line != null) { if (!in_container_list) { // Do not import the XML stylesheet portion if ((line.IndexOf("xml-stylesheet") < 0) && (line.IndexOf("<!DOCTYPE ") < 0)) { // Does the start a DSC section? if ((line.IndexOf("<dsc ") >= 0) || (line.IndexOf("<dsc>") > 0)) { in_container_list = true; container_builder.AppendLine(line); } else { description_builder.AppendLine(line); } } } else { // Add this to the container builder container_builder.AppendLine(line); // Does this end the container list section? if (line.IndexOf("</dsc>") >= 0) { in_container_list = false; } } // Get the next line line = reader.ReadLine(); } // Close the reader reader.Close(); // Just assign all the description section first eadInfo.Full_Description = description_builder.ToString(); // Should the decrpition additionally be analyzed? if (Analyze_Description) { // Try to read the XML try { StringReader strReader = new StringReader(description_builder.ToString()); XmlTextReader reader2 = new XmlTextReader(strReader); // Initial doctype declaration sometimes throws an error for a missing EAD.dtd. bool ead_start_found = false; int error = 0; while ((!ead_start_found) && (error < 5)) { try { reader2.Read(); if ((reader2.NodeType == XmlNodeType.Element) && (reader2.Name.ToLower() == "ead")) { ead_start_found = true; } } catch { error++; } } // Now read the body of the EAD while (reader2.Read()) { if (reader2.NodeType == XmlNodeType.Element) { string nodeName = reader2.Name.ToLower(); switch (nodeName) { case "descrules": string descrules_text = reader2.ReadInnerXml().ToUpper(); if (descrules_text.IndexOf("FINDING AID PREPARED USING ") == 0) { Return_Package.Bib_Info.Record.Description_Standard = descrules_text.Replace("FINDING AID PREPARED USING ", ""); } else { string[] likely_description_standards = { "DACS", "APPM", "AACR2", "RDA", "ISADG", "ISAD", "MAD", "RAD" }; foreach (string likely_standard in likely_description_standards) { if (descrules_text.IndexOf(likely_standard) >= 0) { Return_Package.Bib_Info.Record.Description_Standard = likely_standard; break; } } } break; case "unittitle": while (reader2.Read()) { if (reader2.NodeType == XmlNodeType.Text) { Return_Package.Bib_Info.Main_Title.Title = reader2.Value; break; } else if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.Equals("unittitle")) { break; } } while (!(reader2.NodeType == XmlNodeType.EndElement && reader2.Name.Equals("unittitle"))) { reader2.Read(); } break; case "unitid": while (reader2.Read()) { if (reader2.NodeType == XmlNodeType.Text) { Return_Package.Bib_Info.Add_Identifier(reader2.Value, "Main Identifier"); } if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.ToLower().Equals(nodeName)) { break; } } break; case "origination": while (reader2.Read()) { if (reader2.NodeType == XmlNodeType.Element && reader2.Name.Equals("persname")) { while (reader2.Read()) { if (reader2.NodeType == XmlNodeType.Text) { Return_Package.Bib_Info.Main_Entity_Name.Full_Name = Trim_Final_Punctuation(reader2.Value); Return_Package.Bib_Info.Main_Entity_Name.Name_Type = Name_Info_Type_Enum.personal; } else if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.ToLower().Equals(nodeName)) { break; } } } if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.ToLower().Equals(nodeName)) { break; } } break; case "physdesc": while (reader2.Read()) { if (reader2.NodeType == XmlNodeType.Element && reader2.Name.Equals("extent")) { while (reader2.Read()) { if (reader2.NodeType == XmlNodeType.Text) { Return_Package.Bib_Info.Original_Description.Extent = reader2.Value; } else if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.Equals("extent")) { break; } } } if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.Equals("physdesc")) { break; } } break; case "abstract": while (reader2.Read()) { if (reader2.NodeType == XmlNodeType.Text) { Return_Package.Bib_Info.Add_Abstract(reader2.Value); } else if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.ToLower().Equals(nodeName)) { break; } } break; case "repository": while (reader2.Read()) { if (reader2.NodeType == XmlNodeType.Element && reader2.Name.Equals("corpname")) { while (reader2.Read()) { if (reader2.NodeType == XmlNodeType.Text) { Return_Package.Bib_Info.Location.Holding_Name = reader2.Value; } else if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.ToLower().Equals(nodeName)) { break; } } } if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.ToLower().Equals(nodeName)) { break; } } break; case "accessrestrict": Return_Package.Bib_Info.Add_Note(Clean_Text_Block(reader2.ReadInnerXml()), Note_Type_Enum.restriction); break; case "userestrict": Return_Package.Bib_Info.Access_Condition.Text = Clean_Text_Block(reader2.ReadInnerXml()); break; case "acqinfo": Return_Package.Bib_Info.Add_Note(Clean_Text_Block(reader2.ReadInnerXml()), Note_Type_Enum.acquisition); break; case "bioghist": Return_Package.Bib_Info.Add_Note(Clean_Text_Block(reader2.ReadInnerXml()), Note_Type_Enum.biographical); break; case "scopecontent": Return_Package.Bib_Info.Add_Abstract(Clean_Text_Block(reader2.ReadInnerXml()), "", "summary", "Summary"); break; case "controlaccess": while (reader2.Read()) { if (reader2.NodeType == XmlNodeType.Element && (reader2.Name.Equals("corpname") || reader2.Name.Equals("persname"))) { string tagnamei = reader2.Name; string source = ""; if (reader2.MoveToAttribute("source")) { source = reader2.Value; } while (reader2.Read()) { if (reader2.NodeType == XmlNodeType.Text) { Subject_Info_Name newName = new Subject_Info_Name(); //ToSee: where to add name? and ehat types //ToDo: Type newName.Full_Name = Trim_Final_Punctuation(reader2.Value); newName.Authority = source; Return_Package.Bib_Info.Add_Subject(newName); if (tagnamei.StartsWith("corp")) { newName.Name_Type = Name_Info_Type_Enum.corporate; } else if (tagnamei.StartsWith("pers")) { newName.Name_Type = Name_Info_Type_Enum.personal; } else { newName.Name_Type = Name_Info_Type_Enum.UNKNOWN; } } else if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.Equals(tagnamei)) { break; } } } else if (reader2.NodeType == XmlNodeType.Element && (reader2.Name.Equals("subject"))) { string tagnamei = reader2.Name; string source = ""; if (reader2.MoveToAttribute("source")) { source = reader2.Value; } while (reader2.Read()) { if (reader2.NodeType == XmlNodeType.Text) { string subjectTerm = Trim_Final_Punctuation(reader2.Value.Trim()); if (subjectTerm.Length > 1) { Subject_Info_Standard subject = Return_Package.Bib_Info.Add_Subject(); subject.Authority = source; if (subjectTerm.IndexOf("--") == 0) { subject.Add_Topic(subjectTerm); } else { while (subjectTerm.IndexOf("--") > 0) { string fragment = subjectTerm.Substring(0, subjectTerm.IndexOf("--")).Trim(); if (fragment.ToLower() == "florida") { subject.Add_Geographic(fragment); } else { subject.Add_Topic(fragment); } if (subjectTerm.Length > subjectTerm.IndexOf("--") + 3) { subjectTerm = subjectTerm.Substring(subjectTerm.IndexOf("--") + 2); } else { subjectTerm = String.Empty; } } if (subjectTerm.Trim().Length > 0) { string fragment = subjectTerm.Trim(); if (fragment.ToLower() == "florida") { subject.Add_Geographic(fragment); } else { subject.Add_Topic(fragment); } } } } } else if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.Equals(tagnamei)) { break; } } } if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.ToLower().Equals(nodeName)) { break; } } break; case "dsc": eadInfo.Container_Hierarchy.Read(reader2); break; } } if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.Equals("ead")) { break; } } reader2.Close(); } catch (Exception ee) { Error_Message = "Error caught in EAD_reader2_Writer: " + ee.Message; return(false); } } // If there is a XSL, apply it to the description stored in the EAD sub-section of the item id if (XSL_Location.Length > 0) { try { // Create the transform and load the XSL indicated XslCompiledTransform transform = new XslCompiledTransform(); transform.Load(XSL_Location); // Apply the transform to convert the XML into HTML StringWriter results = new StringWriter(); XmlReaderSettings settings = new XmlReaderSettings(); settings.ProhibitDtd = false; using (XmlReader transformreader = XmlReader.Create(new StringReader(eadInfo.Full_Description), settings)) { transform.Transform(transformreader, null, results); } eadInfo.Full_Description = results.ToString(); // Get rid of the <?xml header if (eadInfo.Full_Description.IndexOf("<?xml") >= 0) { int xml_end_index = eadInfo.Full_Description.IndexOf("?>"); eadInfo.Full_Description = eadInfo.Full_Description.Substring(xml_end_index + 2); } // Since this was successful, try to build the TOC list of included sections SortedList <int, string> toc_sorter = new SortedList <int, string>(); string description = eadInfo.Full_Description; int did = description.IndexOf("<a name=\"did\""); int bioghist = description.IndexOf("<a name=\"bioghist\""); int scopecontent = description.IndexOf("<a name=\"scopecontent\""); int organization = description.IndexOf("<a name=\"organization\""); int arrangement = description.IndexOf("<a name=\"arrangement\""); int relatedmaterial = description.IndexOf("<a name=\"relatedmaterial\""); int otherfindaid = description.IndexOf("<a name=\"otherfindaid\""); int index = description.IndexOf("<a name=\"index\">"); int bibliography = description.IndexOf("<a name=\"bibliography\""); int odd = description.IndexOf("<a name=\"odd\""); int controlaccess = description.IndexOf("<a name=\"controlaccess\""); int accruals = description.IndexOf("<a name=\"accruals\""); int appraisal = description.IndexOf("<a name=\"appraisal\""); int processinfo = description.IndexOf("<a name=\"processinfo\""); int acqinfo = description.IndexOf("<a name=\"acqinfo\""); int prefercite = description.IndexOf("<a name=\"prefercite\""); int altformavail = description.IndexOf("<a name=\"altformavail\""); int custodhist = description.IndexOf("<a name=\"custodhist\""); int accessrestrict = description.IndexOf("<a name=\"accessrestrict\""); int admininfo = description.IndexOf("<a name=\"admininfo\""); if (did >= 0) { toc_sorter[did] = "did"; } if (bioghist >= 0) { toc_sorter[bioghist] = "bioghist"; } if (scopecontent >= 0) { toc_sorter[scopecontent] = "scopecontent"; } if (organization >= 0) { toc_sorter[organization] = "organization"; } if (arrangement >= 0) { toc_sorter[arrangement] = "arrangement"; } if (relatedmaterial >= 0) { toc_sorter[relatedmaterial] = "relatedmaterial"; } if (otherfindaid >= 0) { toc_sorter[otherfindaid] = "otherfindaid"; } if (index >= 0) { toc_sorter[index] = "index"; } if (bibliography >= 0) { toc_sorter[bibliography] = "bibliography"; } if (odd >= 0) { toc_sorter[odd] = "odd"; } if (controlaccess >= 0) { toc_sorter[controlaccess] = "controlaccess"; } if (accruals >= 0) { toc_sorter[accruals] = "accruals"; } if (appraisal >= 0) { toc_sorter[appraisal] = "appraisal"; } if (processinfo >= 0) { toc_sorter[processinfo] = "processinfo"; } if (acqinfo >= 0) { toc_sorter[acqinfo] = "acqinfo"; } if (prefercite >= 0) { toc_sorter[prefercite] = "prefercite"; } if (altformavail >= 0) { toc_sorter[altformavail] = "altformavail"; } if (custodhist >= 0) { toc_sorter[custodhist] = "custodhist"; } if (accessrestrict >= 0) { toc_sorter[accessrestrict] = "accessrestrict"; } if (admininfo >= 0) { toc_sorter[admininfo] = "admininfo"; } // Now, add each section back to the TOC list foreach (string thisEadSection in toc_sorter.Values) { // Index needs to have its head looked up, everything else adds simply if (thisEadSection != "index") { switch (thisEadSection) { case "did": eadInfo.Add_TOC_Included_Section("did", "Descriptive Summary"); break; case "bioghist": eadInfo.Add_TOC_Included_Section("bioghist", "Biographical / Historical Note"); break; case "scopecontent": eadInfo.Add_TOC_Included_Section("scopecontent", "Scope and Content"); break; case "accessrestrict": eadInfo.Add_TOC_Included_Section("accessrestrict", "Access or Use Restrictions"); break; case "relatedmaterial": eadInfo.Add_TOC_Included_Section("relatedmaterial", "Related or Separated Material"); break; case "admininfo": eadInfo.Add_TOC_Included_Section("admininfo", "Administrative Information"); break; case "altformavail": eadInfo.Add_TOC_Included_Section("altformavail", " Alternate Format Available"); break; case "prefercite": eadInfo.Add_TOC_Included_Section("prefercite", " Preferred Citation"); break; case "acqinfo": eadInfo.Add_TOC_Included_Section("acqinfo", " Acquisition Information"); break; case "processinfo": eadInfo.Add_TOC_Included_Section("processinfo", " Processing Information"); break; case "custodhist": eadInfo.Add_TOC_Included_Section("custodhist", " Custodial Work_History"); break; case "controlaccess": eadInfo.Add_TOC_Included_Section("controlaccess", "Selected Subjects"); break; case "otherfindaid": eadInfo.Add_TOC_Included_Section("otherfindaid", "Alternate Form of Finding Aid"); break; } } else { int end_link = eadInfo.Full_Description.IndexOf("</a>", index); string index_title = eadInfo.Full_Description.Substring(index + 16, end_link - index - 16); if (index_title.Length > 38) { index_title = index_title.Substring(0, 32) + "..."; } eadInfo.Add_TOC_Included_Section("index", index_title); } } } catch (Exception ee) { bool error = false; } } // Now, parse the container section as XML if (container_builder.Length > 0) { StringReader containerReader = new StringReader(container_builder.ToString()); XmlTextReader xml_reader = new XmlTextReader(containerReader); xml_reader.Read(); eadInfo.Container_Hierarchy.Read(xml_reader); } return(true); }
/// <summary> Adds the main view section to the page turner </summary> /// <param name="placeHolder"> Main place holder ( "mainPlaceHolder" ) in the itemNavForm form into which the the bulk of the item viewer's output is displayed</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public override void Add_Main_Viewer_Section(PlaceHolder placeHolder, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("EAD_Container_List_ItemViewer.Add_Main_Viewer_Section", "Adds one literal with all the html"); } // Get the metadata module for EADs EAD_Info eadInfo = (EAD_Info)CurrentItem.Get_Metadata_Module(GlobalVar.EAD_METADATA_MODULE_KEY); // Build any search terms List <string> terms = new List <string>(); if (CurrentMode.Text_Search.Length > 0) { // Get any search terms if (CurrentMode.Text_Search.Trim().Length > 0) { string[] splitter = CurrentMode.Text_Search.Replace("\"", "").Split(" ".ToCharArray()); terms.AddRange(from thisSplit in splitter where thisSplit.Trim().Length > 0 select thisSplit.Trim()); } } // Build the value StringBuilder builder = new StringBuilder(15000); builder.AppendLine(" <td align=\"left\"><span class=\"SobekViewerTitle\">Container List</span></td>"); builder.AppendLine(" </tr>"); builder.AppendLine(" <tr>"); builder.AppendLine(" <td>"); builder.AppendLine(" <div class=\"SobekCitation\">"); builder.AppendLine(" <br />"); builder.AppendLine(" <blockquote>"); // Step through the top level first foreach (Container_Info container in eadInfo.Container_Hierarchy.Containers) { // Add this container title and date information first builder.Append("<h2>" + container.Unit_Title); if (container.Unit_Date.Length > 0) { builder.Append(", " + container.Unit_Date); } builder.AppendLine("</h2>"); // Add physical extent, if it exists if (container.Extent.Length > 0) { builder.AppendLine("<strong>" + container.Extent + "</strong><br />"); } // Add the scope content next if (container.Scope_And_Content.Length > 0) { builder.AppendLine(container.Scope_And_Content); } // Add any bioghist next if (container.Biographical_History.Length > 0) { builder.AppendLine(container.Biographical_History); } // Are there children to this top container if (container.Children.Count > 0) { // Dump the current builder into a literal Literal newLiteral = new Literal { Text = Text_Search_Term_Highlighter.Hightlight_Term_In_HTML(builder.ToString(), terms) }; placeHolder.Controls.Add(newLiteral); // Clear the contents of the builder builder.Remove(0, builder.Length); // Now, add this as a tree TreeView treeView1 = new TreeView { Width = new Unit(700), NodeWrap = true, EnableClientScript = true, PopulateNodesFromClient = false }; // Set some tree view properties treeView1.TreeNodePopulate += treeView1_TreeNodePopulate; // Add each child tree node foreach (Container_Info child in container.Children) { // Add this node TreeNode childNode = new TreeNode(child.Unit_Title) { SelectAction = TreeNodeSelectAction.None }; if (child.DAO_Link.Length > 0) { if (child.DAO_Title.Length > 0) { childNode.Text = child.Unit_Title + " <a href=\"" + child.DAO_Link + "\">" + child.DAO_Title + "</a>"; } else { childNode.Text = "<a href=\"" + child.DAO_Link + "\">" + child.Unit_Title + "</a>"; } } treeView1.Nodes.Add(childNode); // Add the description, if there is one if (child.Scope_And_Content.Length > 0) { TreeNode scopeContentNode = new TreeNode(child.Scope_And_Content) { SelectAction = TreeNodeSelectAction.None }; childNode.ChildNodes.Add(scopeContentNode); } // Add the grand children if (child.Children_Count > 0) { foreach (Container_Info grandChild in child.Children) { // Add this node TreeNode grandChildNode = new TreeNode(grandChild.Unit_Title) { SelectAction = TreeNodeSelectAction.None }; if (grandChild.DAO_Link.Length > 0) { if (grandChild.DAO_Title.Length > 0) { grandChildNode.Text = grandChild.Unit_Title + " <a href=\"" + grandChild.DAO_Link + "\">" + grandChild.DAO_Title + "</a>"; } else { grandChildNode.Text = "<a href=\"" + grandChild.DAO_Link + "\">" + grandChild.Unit_Title + "</a>"; } } childNode.ChildNodes.Add(grandChildNode); } } } // Configure the tree view collapsed nodes treeView1.CollapseAll(); // Add this tree view to the place holder placeHolder.Controls.Add(treeView1); } // Put some spaces for now builder.AppendLine("<br /><br />"); } builder.AppendLine(" </blockquote>"); builder.AppendLine(" <br />"); builder.AppendLine(" </div>"); // Add the HTML for the image Literal mainLiteral = new Literal { Text = builder.ToString() }; placeHolder.Controls.Add(mainLiteral); }
private void Finish_Building_Item(SobekCM_Item thisPackage, DataSet databaseInfo, bool multiple) { // Copy over some basic values DataRow mainItemRow = databaseInfo.Tables[2].Rows[0]; thisPackage.Behaviors.Set_Primary_Identifier(mainItemRow["Primary_Identifier_Type"].ToString(), mainItemRow["Primary_Identifier"].ToString()); thisPackage.Behaviors.GroupTitle = mainItemRow["GroupTitle"].ToString(); thisPackage.Web.File_Root = mainItemRow["File_Location"].ToString(); thisPackage.Web.AssocFilePath = mainItemRow["File_Location"] + "\\" + thisPackage.VID + "\\"; thisPackage.Behaviors.IP_Restriction_Membership = Convert.ToInt16(mainItemRow["IP_Restriction_Mask"]); thisPackage.Behaviors.CheckOut_Required = Convert.ToBoolean(mainItemRow["CheckoutRequired"]); thisPackage.Behaviors.Text_Searchable = Convert.ToBoolean(mainItemRow["TextSearchable"]); thisPackage.Web.ItemID = Convert.ToInt32(mainItemRow["ItemID"]); thisPackage.Web.GroupID = Convert.ToInt32(mainItemRow["GroupID"]); thisPackage.Behaviors.Suppress_Endeca = Convert.ToBoolean(mainItemRow["SuppressEndeca"]); //thisPackage.Behaviors.Expose_Full_Text_For_Harvesting = Convert.ToBoolean(mainItemRow["SuppressEndeca"]); thisPackage.Tracking.Internal_Comments = mainItemRow["Comments"].ToString(); thisPackage.Behaviors.Dark_Flag = Convert.ToBoolean(mainItemRow["Dark"]); thisPackage.Tracking.Born_Digital = Convert.ToBoolean(mainItemRow["Born_Digital"]); //thisPackage.Divisions.Page_Count = Convert.ToInt32(mainItemRow["Pages"]); if (mainItemRow["Disposition_Advice"] != DBNull.Value) { thisPackage.Tracking.Disposition_Advice = Convert.ToInt16(mainItemRow["Disposition_Advice"]); } else { thisPackage.Tracking.Disposition_Advice = -1; } if (mainItemRow["Material_Received_Date"] != DBNull.Value) { thisPackage.Tracking.Material_Received_Date = Convert.ToDateTime(mainItemRow["Material_Received_Date"]); } else { thisPackage.Tracking.Material_Received_Date = null; } if (mainItemRow["Material_Recd_Date_Estimated"] != DBNull.Value) { thisPackage.Tracking.Material_Rec_Date_Estimated = Convert.ToBoolean(mainItemRow["Material_Recd_Date_Estimated"]); } if (databaseInfo.Tables[2].Columns.Contains("Tracking_Box")) { if (mainItemRow["Tracking_Box"] != DBNull.Value) { thisPackage.Tracking.Tracking_Box = mainItemRow["Tracking_Box"].ToString(); } } // Set more of the sobekcm web portions in the item thisPackage.Web.Set_BibID_VID(thisPackage.BibID, thisPackage.VID); thisPackage.Web.Image_Root = SobekCM_Library_Settings.Image_URL; if (multiple) { thisPackage.Web.Siblings = 2; } // Set the serial hierarchy from the database (if multiple) if ((multiple) && (mainItemRow["Level1_Text"].ToString().Length > 0)) { bool found = false; // Get the values from the database first string level1_text = mainItemRow["Level1_Text"].ToString(); string level2_text = mainItemRow["Level2_Text"].ToString(); string level3_text = mainItemRow["Level3_Text"].ToString(); int level1_index = Convert.ToInt32(mainItemRow["Level1_Index"]); int level2_index = Convert.ToInt32(mainItemRow["Level2_Index"]); int level3_index = Convert.ToInt32(mainItemRow["Level3_Index"]); // Does this match the enumeration if (level1_text.ToUpper().Trim() == thisPackage.Bib_Info.Series_Part_Info.Enum1.ToUpper().Trim()) { // Copy the database values to the enumeration portion thisPackage.Bib_Info.Series_Part_Info.Enum1 = level1_text; thisPackage.Bib_Info.Series_Part_Info.Enum1_Index = level1_index; thisPackage.Bib_Info.Series_Part_Info.Enum2 = level2_text; thisPackage.Bib_Info.Series_Part_Info.Enum2_Index = level2_index; thisPackage.Bib_Info.Series_Part_Info.Enum3 = level3_text; thisPackage.Bib_Info.Series_Part_Info.Enum3_Index = level3_index; found = true; } // Does this match the chronology if ((!found) && (level1_text.ToUpper().Trim() == thisPackage.Bib_Info.Series_Part_Info.Year.ToUpper().Trim())) { // Copy the database values to the chronology portion thisPackage.Bib_Info.Series_Part_Info.Year = level1_text; thisPackage.Bib_Info.Series_Part_Info.Year_Index = level1_index; thisPackage.Bib_Info.Series_Part_Info.Month = level2_text; thisPackage.Bib_Info.Series_Part_Info.Month_Index = level2_index; thisPackage.Bib_Info.Series_Part_Info.Day = level3_text; thisPackage.Bib_Info.Series_Part_Info.Day_Index = level3_index; found = true; } if (!found) { // No match. If it is numeric, move it to the chronology, otherwise, enumeration bool charFound = level1_text.Trim().Any(thisChar => !Char.IsNumber(thisChar)); if (charFound) { // Copy the database values to the enumeration portion thisPackage.Bib_Info.Series_Part_Info.Enum1 = level1_text; thisPackage.Bib_Info.Series_Part_Info.Enum1_Index = level1_index; thisPackage.Bib_Info.Series_Part_Info.Enum2 = level2_text; thisPackage.Bib_Info.Series_Part_Info.Enum2_Index = level2_index; thisPackage.Bib_Info.Series_Part_Info.Enum3 = level3_text; thisPackage.Bib_Info.Series_Part_Info.Enum3_Index = level3_index; } else { // Copy the database values to the chronology portion thisPackage.Bib_Info.Series_Part_Info.Year = level1_text; thisPackage.Bib_Info.Series_Part_Info.Year_Index = level1_index; thisPackage.Bib_Info.Series_Part_Info.Month = level2_text; thisPackage.Bib_Info.Series_Part_Info.Month_Index = level2_index; thisPackage.Bib_Info.Series_Part_Info.Day = level3_text; thisPackage.Bib_Info.Series_Part_Info.Day_Index = level3_index; } } // Copy the database values to the simple serial portion (used to actually determine serial heirarchy) thisPackage.Behaviors.Serial_Info.Clear(); thisPackage.Behaviors.Serial_Info.Add_Hierarchy(1, level1_index, level1_text); if (level2_text.Length > 0) { thisPackage.Behaviors.Serial_Info.Add_Hierarchy(2, level2_index, level2_text); if (level3_text.Length > 0) { thisPackage.Behaviors.Serial_Info.Add_Hierarchy(3, level3_index, level3_text); } } } // See if this can be described bool can_describe = false; foreach (DataRow thisRow in databaseInfo.Tables[1].Rows) { int thisAggregationValue = Convert.ToInt16(thisRow["Items_Can_Be_Described"]); if (thisAggregationValue == 0) { can_describe = false; break; } if (thisAggregationValue == 2) { can_describe = true; } } thisPackage.Behaviors.Can_Be_Described = can_describe; // Look for user descriptions foreach (DataRow thisRow in databaseInfo.Tables[0].Rows) { string first_name = thisRow["FirstName"].ToString(); string nick_name = thisRow["NickName"].ToString(); string last_name = thisRow["LastName"].ToString(); int userid = Convert.ToInt32(thisRow["UserID"]); string tag = thisRow["Description_Tag"].ToString(); int tagid = Convert.ToInt32(thisRow["TagID"]); DateTime dateAdded = Convert.ToDateTime(thisRow["Date_Modified"]); if (nick_name.Length > 0) { thisPackage.Behaviors.Add_User_Tag(userid, nick_name + " " + last_name, tag, dateAdded, tagid); } else { thisPackage.Behaviors.Add_User_Tag(userid, first_name + " " + last_name, tag, dateAdded, tagid); } } // Look for ticklers foreach (DataRow thisRow in databaseInfo.Tables[3].Rows) { thisPackage.Behaviors.Add_Tickler(thisRow["MetadataValue"].ToString().Trim()); } // Set the aggregations in the package to the aggregation links from the database thisPackage.Behaviors.Clear_Aggregations(); foreach (DataRow thisRow in databaseInfo.Tables[1].Rows) { if (!Convert.ToBoolean(thisRow["impliedLink"])) { thisPackage.Behaviors.Add_Aggregation(thisRow["Code"].ToString()); } } // If no collections, add some regardless of whether it was IMPLIED if (thisPackage.Behaviors.Aggregation_Count == 0) { foreach (DataRow thisRow in databaseInfo.Tables[1].Rows) { if (thisRow["Type"].ToString().ToUpper() == "COLLECTION") { thisPackage.Behaviors.Add_Aggregation(thisRow["Code"].ToString()); } } } // Step through each page and set the static page count pageseq = 0; List <Page_TreeNode> pages_encountered = new List <Page_TreeNode>(); foreach (abstract_TreeNode rootNode in thisPackage.Divisions.Physical_Tree.Roots) { recurse_through_nodes(thisPackage, rootNode, pages_encountered); } thisPackage.Web.Static_PageCount = pages_encountered.Count; thisPackage.Web.Static_Division_Count = divseq; // Make sure no icons were retained from the METS file itself thisPackage.Behaviors.Clear_Wordmarks(); // Add the icons from the database information foreach (DataRow iconRow in databaseInfo.Tables[5].Rows) { string image = iconRow[0].ToString(); string link = iconRow[1].ToString().Replace("&", "&").Replace("\"", """); string code = iconRow[2].ToString(); string name = code.Replace("&", "&").Replace("\"", """); string html; if (link.Length == 0) { html = "<img class=\"SobekItemWordmark\" src=\"<%BASEURL%>design/wordmarks/" + image + "\" title=\"" + name + "\" alt=\"" + name + "\" />"; } else { if (link[0] == '?') { html = "<a href=\"" + link + "\"><img class=\"SobekItemWordmark\" src=\"<%BASEURL%>design/wordmarks/" + image + "\" title=\"" + name + "\" alt=\"" + name + "\" /></a>"; } else { html = "<a href=\"" + link + "\" target=\"_blank\"><img class=\"SobekItemWordmark\" src=\"<%BASEURL%>design/wordmarks/" + image + "\" title=\"" + name + "\" alt=\"" + name + "\" /></a>"; } } Wordmark_Info newIcon = new Wordmark_Info { HTML = html, Link = link, Title = name, Code = code }; thisPackage.Behaviors.Add_Wordmark(newIcon); } // Make sure no web skins were retained from the METS file itself thisPackage.Behaviors.Clear_Web_Skins(); // Add the web skins from the database foreach (DataRow skinRow in databaseInfo.Tables[6].Rows) { thisPackage.Behaviors.Add_Web_Skin(skinRow[0].ToString().ToUpper()); } // Make sure no views were retained from the METS file itself thisPackage.Behaviors.Clear_Views(); // If this has more than 1 sibling (this count includes itself), add the multi-volumes viewer if (multiple) { thisPackage.Behaviors.Add_View(View_Enum.ALL_VOLUMES, String.Empty, thisPackage.Bib_Info.SobekCM_Type_String); } // Add the full citation view and the (hidden) tracking view thisPackage.Behaviors.Add_View(View_Enum.CITATION); thisPackage.Behaviors.Add_View(View_Enum.TRACKING); // Add the full text if (thisPackage.Behaviors.Text_Searchable) { thisPackage.Behaviors.Add_View(View_Enum.SEARCH); } // Is there an embedded video? if (thisPackage.Behaviors.Embedded_Video.Length > 0) { thisPackage.Behaviors.Add_View(View_Enum.EMBEDDED_VIDEO); } // If there is no PURL, add one based on how SobekCM operates if (thisPackage.Bib_Info.Location.PURL.Length == 0) { thisPackage.Bib_Info.Location.PURL = SobekCM_Library_Settings.System_Base_URL + thisPackage.BibID + "/" + thisPackage.VID; } // IF this is dark, add no other views if (!thisPackage.Behaviors.Dark_Flag) { // Check to see which views were present from the database, and build the list Dictionary <View_Enum, View_Object> viewsFromDb = new Dictionary <View_Enum, View_Object>(); foreach (DataRow viewRow in databaseInfo.Tables[4].Rows) { string viewType = viewRow[0].ToString(); string attribute = viewRow[1].ToString(); string label = viewRow[2].ToString(); View_Enum viewTypeEnum = View_Enum.None; switch (viewType) { case "JPEG": viewTypeEnum = View_Enum.JPEG; break; case "JPEG2000": viewTypeEnum = View_Enum.JPEG2000; break; case "Text": viewTypeEnum = View_Enum.TEXT; break; case "Page Turner": viewTypeEnum = View_Enum.PAGE_TURNER; break; case "Google Map": viewTypeEnum = View_Enum.GOOGLE_MAP; break; case "HTML Viewer": viewTypeEnum = View_Enum.HTML; break; case "HTML Map Viewer": viewTypeEnum = View_Enum.HTML_MAP; break; case "Related Images": viewTypeEnum = View_Enum.RELATED_IMAGES; break; case "TOC": viewTypeEnum = View_Enum.TOC; break; case "TEI": viewTypeEnum = View_Enum.TEI; break; } if (viewTypeEnum != View_Enum.None) { viewsFromDb[viewTypeEnum] = new View_Object(viewTypeEnum, label, attribute); } } // Add the thumbnail view, if requested and has multiple pages if (thisPackage.Divisions.Page_Count > 1) { if (viewsFromDb.ContainsKey(View_Enum.RELATED_IMAGES)) { thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.RELATED_IMAGES]); viewsFromDb.Remove(View_Enum.RELATED_IMAGES); } thisPackage.Behaviors.Add_View(View_Enum.QUALITY_CONTROL); } else { if (viewsFromDb.ContainsKey(View_Enum.RELATED_IMAGES)) { viewsFromDb.Remove(View_Enum.RELATED_IMAGES); } } // If this item has more than one division, look for the TOC viewer if ((thisPackage.Divisions.Has_Multiple_Divisions) && (!thisPackage.Bib_Info.ImageClass)) { if (viewsFromDb.ContainsKey(View_Enum.TOC)) { thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.TOC]); viewsFromDb.Remove(View_Enum.TOC); } } // In addition, if there is a latitude or longitude listed, look for the Google Maps bool hasCoords = false; GeoSpatial_Information geoInfo = (GeoSpatial_Information)thisPackage.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY); if ((geoInfo != null) && (geoInfo.hasData)) { if ((geoInfo.Point_Count > 0) || (geoInfo.Polygon_Count > 0)) { hasCoords = true; } } if (!hasCoords) { List <abstract_TreeNode> pageList = thisPackage.Divisions.Physical_Tree.Pages_PreOrder; foreach (abstract_TreeNode thisPage in pageList) { GeoSpatial_Information geoInfo2 = (GeoSpatial_Information)thisPage.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY); if ((geoInfo2 != null) && (geoInfo2.hasData)) { if ((geoInfo2.Point_Count > 0) || (geoInfo2.Polygon_Count > 0)) { hasCoords = true; break; } } } } if (hasCoords) { if (viewsFromDb.ContainsKey(View_Enum.GOOGLE_MAP)) { thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.GOOGLE_MAP]); viewsFromDb.Remove(View_Enum.GOOGLE_MAP); } else { thisPackage.Behaviors.Add_View(View_Enum.GOOGLE_MAP); } } // Step through each download and make sure it is fully built if (thisPackage.Divisions.Download_Tree.Has_Files) { string ead_file = String.Empty; int pdf_download = 0; string pdf_download_url = String.Empty; int non_flash_downloads = 0; List <abstract_TreeNode> downloadPages = thisPackage.Divisions.Download_Tree.Pages_PreOrder; foreach (Page_TreeNode downloadPage in downloadPages) { // Was this an EAD page? if ((downloadPage.Label == GlobalVar.EAD_METADATA_MODULE_KEY) && (downloadPage.Files.Count == 1)) { ead_file = downloadPage.Files[0].System_Name; } // Was this an XSL/EAD page? if ((downloadPage.Label == "XSL") && (downloadPage.Files.Count == 1)) { } // Step through each download file foreach (SobekCM_File_Info thisFile in downloadPage.Files) { if (thisFile.File_Extension == "SWF") { string flashlabel = downloadPage.Label; View_Object newView = thisPackage.Behaviors.Add_View(View_Enum.FLASH, flashlabel, String.Empty, thisFile.System_Name); thisPackage.Behaviors.Default_View = newView; } else { non_flash_downloads++; } if (thisFile.File_Extension == "PDF") { pdf_download++; pdf_download_url = thisFile.System_Name; } } } if (((non_flash_downloads > 0) && (pdf_download != 1)) || ((non_flash_downloads > 1) && (pdf_download == 1))) { if (thisPackage.Web.Static_PageCount == 0) { thisPackage.Behaviors.Default_View = thisPackage.Behaviors.Add_View(View_Enum.DOWNLOADS); } else { thisPackage.Behaviors.Add_View(View_Enum.DOWNLOADS); } } if (pdf_download == 1) { if ((thisPackage.Web.Static_PageCount == 0) && (thisPackage.Behaviors.Default_View == null)) { thisPackage.Behaviors.Default_View = thisPackage.Behaviors.Add_View(View_Enum.PDF); thisPackage.Behaviors.Default_View.FileName = pdf_download_url; } else { thisPackage.Behaviors.Add_View(View_Enum.PDF).FileName = pdf_download_url; } } // Some special code for EAD objects if ((thisPackage.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.Archival) && (ead_file.Length > 0)) { // Now, read this EAD file information string ead_file_location = SobekCM_Library_Settings.Image_Server_Network + thisPackage.Web.AssocFilePath + ead_file; EAD_File_ReaderWriter reader = new EAD_File_ReaderWriter(); string Error_Message; Dictionary <string, object> options = new Dictionary <string, object>(); options["EAD_File_ReaderWriter:XSL_Location"] = SobekCM_Library_Settings.System_Base_URL + "default/sobekcm_default.xsl"; reader.Read_Metadata(ead_file_location, thisPackage, options, out Error_Message); // Clear all existing views thisPackage.Behaviors.Clear_Views(); thisPackage.Behaviors.Add_View(View_Enum.CITATION); thisPackage.Behaviors.Default_View = thisPackage.Behaviors.Add_View(View_Enum.EAD_DESCRIPTION); // Get the metadata module for EADs EAD_Info eadInfo = (EAD_Info)thisPackage.Get_Metadata_Module(GlobalVar.EAD_METADATA_MODULE_KEY); if ((eadInfo != null) && (eadInfo.Container_Hierarchy.Containers.Count > 0)) { thisPackage.Behaviors.Add_View(View_Enum.EAD_CONTAINER_LIST); } } } else { if (thisPackage.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.Aerial) { thisPackage.Behaviors.Add_View(View_Enum.DOWNLOADS); } } // If there is a RELATED URL with youtube, add that viewer if ((thisPackage.Bib_Info.hasLocationInformation) && (thisPackage.Bib_Info.Location.Other_URL.ToLower().IndexOf("www.youtube.com") >= 0)) { View_Object newViewObj = new View_Object(View_Enum.YOUTUBE_VIDEO); thisPackage.Behaviors.Add_View(newViewObj); thisPackage.Behaviors.Default_View = newViewObj; } // Look for the HTML type views next, and possible set some defaults if (viewsFromDb.ContainsKey(View_Enum.HTML)) { thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.HTML]); thisPackage.Behaviors.Default_View = viewsFromDb[View_Enum.HTML]; viewsFromDb.Remove(View_Enum.HTML); } // Look for the HTML MAP type views next, and possible set some defaults if (viewsFromDb.ContainsKey(View_Enum.HTML_MAP)) { thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.HTML_MAP]); thisPackage.Behaviors.Default_View = viewsFromDb[View_Enum.HTML_MAP]; viewsFromDb.Remove(View_Enum.HTML_MAP); } // Copy the TEI flag if (viewsFromDb.ContainsKey(View_Enum.TEI)) { thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.TEI]); viewsFromDb.Remove(View_Enum.HTML); } // Look to add any index information here ( such as on SANBORN maps) Map_Info mapInfo = (Map_Info)thisPackage.Get_Metadata_Module(GlobalVar.SOBEKCM_MAPS_METADATA_MODULE_KEY); if (mapInfo != null) { // Was there a HTML map here? if (mapInfo.Index_Count > 0) { Map_Index thisIndex = mapInfo.Get_Index(0); View_Object newMapSanbView = thisPackage.Behaviors.Add_View(View_Enum.HTML_MAP, thisIndex.Title, thisIndex.Image_File + ";" + thisIndex.HTML_File); thisPackage.Behaviors.Default_View = newMapSanbView; } //// Were there streets? //if (thisPackage.Map.Streets.Count > 0) //{ // returnValue.Item_Views.Add(new ViewerFetcher.Streets_ViewerFetcher()); //} //// Were there features? //if (thisPackage.Map.Features.Count > 0) //{ // returnValue.Item_Views.Add(new ViewerFetcher.Features_ViewerFetcher()); //} } // Look for the RELATED IMAGES view next if (viewsFromDb.ContainsKey(View_Enum.RELATED_IMAGES)) { thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.RELATED_IMAGES]); viewsFromDb.Remove(View_Enum.RELATED_IMAGES); } // Look for the PAGE TURNER view next if (viewsFromDb.ContainsKey(View_Enum.PAGE_TURNER)) { thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.PAGE_TURNER]); viewsFromDb.Remove(View_Enum.PAGE_TURNER); } // Finally, add all the ITEM VIEWS foreach (View_Object thisObject in viewsFromDb.Values) { switch (thisObject.View_Type) { case View_Enum.TEXT: case View_Enum.JPEG: case View_Enum.JPEG2000: thisPackage.Behaviors.Add_Item_Level_Page_View(thisObject); break; } } } }