コード例 #1
0
        /// <summary> Computes the attributes (width, height) for a JPEG file </summary>
        /// <param name="JPEG_File"> METS SobekCM_File_Info object for this jpeg file </param>
        /// <param name="File_Location"> Location where this file exists </param>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        /// <remarks> The attribute information is computed and then stored in the provided METS SobekCM_File_Info object </remarks>
        public bool Compute_Jpeg_Attributes(SobekCM_File_Info JPEG_File, string File_Location)
        {
            // If the width and height are already determined, done!
            if ((JPEG_File.Width > 0) && (JPEG_File.Height > 0))
            {
                return(true);
            }

            // Does this file exist?
            if (File.Exists(File_Location + "/" + JPEG_File.System_Name))
            {
                try
                {
                    // Get the height and width of this JPEG file
                    Bitmap image = (Bitmap)Image.FromFile(File_Location + "/" + JPEG_File.System_Name);
                    JPEG_File.Width  = (ushort)image.Width;
                    JPEG_File.Height = (ushort)image.Height;
                    image.Dispose();
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }

            return(false);
        }
コード例 #2
0
        /// <summary> Gets the view object from this item based on the requested viewer code  </summary>
        /// <param name="viewer_code"> Viewer code for the viewer requested </param>
        /// <returns> Valid view object from this item, based on requested viewer code, or NULL </returns>
        public View_Object Get_Viewer(string viewer_code)
        {
            string lower_code = viewer_code.ToLower();

            // If this is for the restricted viewer, that is always valid
            if (lower_code == "res")
            {
                return(new View_Object(View_Enum.RESTRICTED));
            }

            // If this was for the full citation, jsut return that
            if (lower_code.IndexOf("citation") == 0)
            {
                return(new View_Object(View_Enum.CITATION));
            }

            // Is this in the item level viewer list?
            if (behaviors.Views_Count > 0)
            {
                foreach (View_Object thisView in behaviors.Views)
                {
                    foreach (string thisCode in thisView.Viewer_Codes)
                    {
                        if (thisCode.ToLower() == lower_code)
                        {
                            return(thisView);
                        }
                    }
                }
            }

            // Check each page
            if ((viewer_to_file != null) && (viewer_to_file.ContainsKey(lower_code)))
            {
                return(viewer_to_file[lower_code].Get_Viewer());
            }

            // No match, so just return the default..
            if (behaviors.Default_View != null)
            {
                return(behaviors.Default_View);
            }

            // Return first page viewer
            if ((pages_by_seq != null) && (pages_by_seq.Count > 0) && (pages_by_seq[0].Files.Count > 0))
            {
                SobekCM_File_Info first_page      = pages_by_seq[0].Files[0];
                View_Object       firstPageViewer = first_page.Get_Viewer();
            }

            // If there is a single view, return the first code for it
            if (behaviors.Views_Count > 0)
            {
                return(behaviors.Views[0]);
            }

            // Return null
            return(null);
        }
コード例 #3
0
        /// <summary> Load all the file attributes into this wrapper class </summary>
        /// <param name="Metadata_Location"> Directory to find the metadata for this package </param>
        /// <param name="File_Location"> Directory to fine the files for this package </param>
        /// <remarks> This reads the width and height of all the page image files and stores this
        /// in the internal SobekCM_Item object </remarks>
        public void Load_File_Attributes(string Metadata_Location, string File_Location)
        {
            // First, check to see if there is an existing service METS
            if ((Metadata_Location.Length > 0) && (Directory.Exists(Metadata_Location)) && (File.Exists(Metadata_Location + "/" + bibid + "_" + vid + ".mets.xml")))
            {
                try
                {
                    SobekCM_Item serviceMETS = SobekCM_Item.Read_METS(Metadata_Location + "/" + bibid + "_" + vid + ".mets.xml");

                    // Create a hashtable of all the files in the service METS and tep through each file in this mets and look for attributes in the other
                    Dictionary <string, SobekCM_File_Info> serviceMetsFiles = serviceMETS.Divisions.Files.ToDictionary(thisFile => thisFile.System_Name);

                    // Now, step through each file in this mets and look for attributes in the other
                    foreach (SobekCM_File_Info thisFile in bibPackage.Divisions.Files)
                    {
                        // Is there a match?
                        if (serviceMetsFiles.ContainsKey(thisFile.System_Name))
                        {
                            // Get the match
                            SobekCM_File_Info serviceFile = serviceMetsFiles[thisFile.System_Name];

                            // Copy the data over
                            thisFile.Width       = serviceFile.Width;
                            thisFile.Height      = serviceFile.Height;
                            thisFile.System_Name = serviceFile.System_Name;
                        }
                    }
                }
                catch (Exception)
                {
                    // No need to do anything here.. can still function without this information being saved
                }
            }

            // Now, just look for the data being present in each file
            if (Directory.Exists(File_Location))
            {
                foreach (SobekCM_File_Info thisFile in bibPackage.Divisions.Files)
                {
                    // Is this a jpeg?
                    if (thisFile.System_Name.ToUpper().IndexOf(".JPG") > 0)
                    {
                        if (thisFile.System_Name.ToUpper().IndexOf("THM.JPG") < 0)
                        {
                            Compute_Jpeg_Attributes(thisFile, File_Location);
                        }
                    }

                    // Is this a jpeg2000?
                    if (thisFile.System_Name.ToUpper().IndexOf("JP2") > 0)
                    {
                        Compute_Jpeg2000_Attributes(thisFile, File_Location);
                    }
                }
            }
        }
コード例 #4
0
        private bool get_attributes_from_jpeg2000(SobekCM_File_Info JPEG2000_File, string file)
        {
            try
            {
                // Get the height and width of this JPEG file
                FileStream reader         = new FileStream(file, FileMode.Open, FileAccess.Read);
                int[]      previousValues = new[] { 0, 0, 0, 0 };
                int        bytevalue      = reader.ReadByte();
                int        count          = 1;
                while (bytevalue != -1)
                {
                    // Move this value into the array
                    previousValues[0] = previousValues[1];
                    previousValues[1] = previousValues[2];
                    previousValues[2] = previousValues[3];
                    previousValues[3] = bytevalue;

                    // Is this IHDR?
                    if ((previousValues[0] == 105) && (previousValues[1] == 104) &&
                        (previousValues[2] == 100) && (previousValues[3] == 114))
                    {
                        break;
                    }

                    // Is this the first four bytes and does it match the output from Kakadu 3-2?
                    if ((count == 4) && (previousValues[0] == 255) && (previousValues[1] == 79) &&
                        (previousValues[2] == 255) && (previousValues[3] == 81))
                    {
                        reader.ReadByte();
                        reader.ReadByte();
                        reader.ReadByte();
                        reader.ReadByte();
                        break;
                    }

                    // Read the next byte
                    bytevalue = reader.ReadByte();
                    count++;
                }

                // Now, read ahead for the height and width
                JPEG2000_File.Height = (ushort)((((((reader.ReadByte() * 256) + reader.ReadByte()) * 256) + reader.ReadByte()) * 256) + reader.ReadByte());
                JPEG2000_File.Width  = (ushort)((((((reader.ReadByte() * 256) + reader.ReadByte()) * 256) + reader.ReadByte()) * 256) + reader.ReadByte());
                reader.Close();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #5
0
        /// <summary> Saves the data stored in this instance of the
        /// element to the provided bibliographic object </summary>
        /// <param name="Bib"> Object into which to save this element's data </param>
        public override void Save_To_Bib(SobekCM_Item Bib)
        {
            if (thisViewBox.Text.Trim().Length > 0)
            {
                switch (thisViewBox.Text)
                {
                case "Page Image (JPEG)":
                    Bib.Behaviors.Add_View(View_Enum.JPEG);
                    break;

                case "Zoomable (JPEG2000)":
                    Bib.Behaviors.Add_View(View_Enum.JPEG2000);
                    break;

                case "HTML":
                    View_Object newView = new View_Object(View_Enum.HTML);
                    newView.Attributes = thisAttributesBox.Text.Trim();
                    newView.Label      = thisLabelBox.Text.Trim();
                    Bib.Behaviors.Add_View(newView);
                    if (thisAttributesBox.Text.Trim().Length > 0)
                    {
                        SobekCM_File_Info newestFile = new SobekCM_File_Info(thisAttributesBox.Text.Trim());
                        Bib.Divisions.Physical_Tree.Add_File(newestFile);
                    }
                    break;

                case "HTML_MAP":
                    View_Object newView2 = new View_Object(View_Enum.HTML_MAP);
                    newView2.Attributes = thisAttributesBox.Text.Trim();
                    newView2.Label      = thisLabelBox.Text.Trim();
                    Bib.Behaviors.Add_View(newView2);
                    break;

                case "Thumbnails":
                    Bib.Behaviors.Add_View(View_Enum.RELATED_IMAGES);
                    break;

                case "Text":
                    Bib.Behaviors.Add_View(View_Enum.TEXT);
                    break;

                case "Page Turner":
                    Bib.Behaviors.Add_View(View_Enum.PAGE_TURNER);
                    break;
                }
            }
        }
コード例 #6
0
        /// <summary> Computes the attributes (width, height) for a JPEG2000 file </summary>
        /// <param name="JPEG2000_File"> METS SobekCM_File_Info object for this jpeg2000 file </param>
        /// <param name="File_Location"> Location where this file exists </param>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        /// <remarks> The attribute information is computed and then stored in the provided METS SobekCM_File_Info object </remarks>
        public bool Compute_Jpeg2000_Attributes(SobekCM_File_Info JPEG2000_File, string File_Location)
        {
            // If the width and height are already determined, done!
            if ((JPEG2000_File.Width > 0) && (JPEG2000_File.Height > 0) && (JPEG2000_File.System_Name.Length > 0))
            {
                return(true);
            }

            // Does this file exist?
            if (File.Exists(File_Location + "/" + JPEG2000_File.System_Name))
            {
                return(get_attributes_from_jpeg2000(JPEG2000_File, File_Location + "/" + JPEG2000_File.System_Name));
            }

            if ((JPEG2000_File.System_Name.Length > 0) && (File.Exists(JPEG2000_File.System_Name)))
            {
                return(get_attributes_from_jpeg2000(JPEG2000_File, JPEG2000_File.System_Name));
            }

            return(false);
        }
コード例 #7
0
        /// <summary> Computes the attributes (width, height) for a JPEG file </summary>
        /// <param name="JPEG_File"> METS SobekCM_File_Info object for this jpeg file </param>
        /// <param name="File_Location"> Location where this file exists </param>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        /// <remarks> The attribute information is computed and then stored in the provided METS SobekCM_File_Info object </remarks>
        private bool Compute_Jpeg_Attributes(SobekCM_File_Info JPEG_File, string File_Location)
        {
            // Does this file exist?
            string file_in_place = Path.Combine(File_Location, JPEG_File.System_Name);

            if (File.Exists(file_in_place))
            {
                try
                {
                    // Get the height and width of this JPEG file
                    Bitmap image = (Bitmap)Image.FromFile(file_in_place);
                    JPEG_File.Width  = (ushort)image.Width;
                    JPEG_File.Height = (ushort)image.Height;
                    image.Dispose();
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }

            return(false);
        }
コード例 #8
0
        private bool complete_item_submission(SobekCM_Item Item_To_Complete, Custom_Tracer Tracer)
        {
            // Set an initial flag
            criticalErrorEncountered = false;

            string[] all_files = Directory.GetFiles(digitalResourceDirectory);
            SortedList <string, List <string> > image_files    = new SortedList <string, List <string> >();
            SortedList <string, List <string> > download_files = new SortedList <string, List <string> >();

            foreach (string thisFile in all_files)
            {
                FileInfo thisFileInfo = new FileInfo(thisFile);

                if ((thisFileInfo.Name.IndexOf("agreement.txt") != 0) && (thisFileInfo.Name.IndexOf("TEMP000001_00001.mets") != 0) && (thisFileInfo.Name.IndexOf("doc.xml") != 0) && (thisFileInfo.Name.IndexOf("marc.xml") != 0))
                {
                    // Get information about this files name and extension
                    string extension_upper         = thisFileInfo.Extension.ToUpper();
                    string filename_sans_extension = thisFileInfo.Name.Replace(thisFileInfo.Extension, "");
                    string name_upper = thisFileInfo.Name.ToUpper();

                    // Is this a page image?
                    if ((extension_upper == ".JPG") || (extension_upper == ".TIF") || (extension_upper == ".JP2") || (extension_upper == ".JPX"))
                    {
                        // Exclude .QC.jpg files
                        if (name_upper.IndexOf(".QC.JPG") < 0)
                        {
                            // If this is a thumbnail, trim off the THM part on the file name
                            if (name_upper.IndexOf("THM.JPG") > 0)
                            {
                                filename_sans_extension = filename_sans_extension.Substring(0, filename_sans_extension.Length - 3);
                            }

                            // Is this the first image file with this name?
                            if (image_files.ContainsKey(filename_sans_extension.ToLower()))
                            {
                                image_files[filename_sans_extension.ToLower()].Add(thisFileInfo.Name);
                            }
                            else
                            {
                                List <string> newImageGrouping = new List <string> {
                                    thisFileInfo.Name
                                };
                                image_files[filename_sans_extension.ToLower()] = newImageGrouping;
                            }
                        }
                    }
                    else
                    {
                        // If this does not match the exclusion regular expression, than add this
                        if ((!Regex.Match(thisFileInfo.Name, UI_ApplicationCache_Gateway.Settings.Resources.Files_To_Exclude_From_Downloads, RegexOptions.IgnoreCase).Success) && (String.Compare(thisFileInfo.Name, Item_To_Complete.BibID + "_" + Item_To_Complete.VID + ".html", StringComparison.OrdinalIgnoreCase) != 0))
                        {
                            // Also, exclude files that are .XML and marc.xml, or doc.xml, or have the bibid in the name
                            if ((thisFileInfo.Name.IndexOf("marc.xml", StringComparison.OrdinalIgnoreCase) != 0) && (thisFileInfo.Name.IndexOf("marc.xml", StringComparison.OrdinalIgnoreCase) != 0) && (thisFileInfo.Name.IndexOf(".mets", StringComparison.OrdinalIgnoreCase) < 0) && (thisFileInfo.Name.IndexOf("citation_mets.xml", StringComparison.OrdinalIgnoreCase) < 0) &&
                                ((thisFileInfo.Name.IndexOf(".xml", StringComparison.OrdinalIgnoreCase) < 0) || (thisFileInfo.Name.IndexOf(Item_To_Complete.BibID, StringComparison.OrdinalIgnoreCase) < 0)))
                            {
                                // Is this the first image file with this name?
                                if (download_files.ContainsKey(filename_sans_extension.ToLower()))
                                {
                                    download_files[filename_sans_extension.ToLower()].Add(thisFileInfo.Name);
                                }
                                else
                                {
                                    List <string> newDownloadGrouping = new List <string> {
                                        thisFileInfo.Name
                                    };
                                    download_files[filename_sans_extension.ToLower()] = newDownloadGrouping;
                                }
                            }
                        }
                    }
                }
            }

            // This package is good to go, so build it, save, etc...
            try
            {
                // Save the METS file to the database and back to the directory
                Item_To_Complete.Source_Directory = digitalResourceDirectory;

                // Step through and add each file
                Item_To_Complete.Divisions.Download_Tree.Clear();

                // Add the download files next
                foreach (string thisFileKey in download_files.Keys)
                {
                    // Get the list of files
                    List <string> theseFiles = download_files[thisFileKey];

                    // Add each file
                    foreach (string thisFile in theseFiles)
                    {
                        // Create the new file object and compute a label
                        FileInfo          fileInfo = new FileInfo(thisFile);
                        SobekCM_File_Info newFile  = new SobekCM_File_Info(fileInfo.Name);
                        string            label    = fileInfo.Name.Replace(fileInfo.Extension, "");
                        if (HttpContext.Current.Session["file_" + currentItem.Web.ItemID + "_" + thisFileKey] != null)
                        {
                            string possible_label = HttpContext.Current.Session["file_" + currentItem.Web.ItemID + "_" + thisFileKey].ToString();
                            if (possible_label.Length > 0)
                            {
                                label = possible_label;
                            }
                        }

                        // Add this file
                        Item_To_Complete.Divisions.Download_Tree.Add_File(newFile, label);
                    }
                }

                // Determine the total size of the package before saving
                string[] all_files_final = Directory.GetFiles(digitalResourceDirectory);
                double   size            = all_files_final.Aggregate <string, double>(0, (Current, ThisFile) => Current + (((new FileInfo(ThisFile)).Length) / 1024));
                Item_To_Complete.DiskSize_KB = size;

                // Create the options dictionary used when saving information to the database, or writing MarcXML
                Dictionary <string, object> options = new Dictionary <string, object>();
                if (UI_ApplicationCache_Gateway.Settings.MarcGeneration != null)
                {
                    options["MarcXML_File_ReaderWriter:MARC Cataloging Source Code"] = UI_ApplicationCache_Gateway.Settings.MarcGeneration.Cataloging_Source_Code;
                    options["MarcXML_File_ReaderWriter:MARC Location Code"]          = UI_ApplicationCache_Gateway.Settings.MarcGeneration.Location_Code;
                    options["MarcXML_File_ReaderWriter:MARC Reproduction Agency"]    = UI_ApplicationCache_Gateway.Settings.MarcGeneration.Reproduction_Agency;
                    options["MarcXML_File_ReaderWriter:MARC Reproduction Place"]     = UI_ApplicationCache_Gateway.Settings.MarcGeneration.Reproduction_Place;
                    options["MarcXML_File_ReaderWriter:MARC XSLT File"] = UI_ApplicationCache_Gateway.Settings.MarcGeneration.XSLT_File;
                }
                options["MarcXML_File_ReaderWriter:System Name"]         = UI_ApplicationCache_Gateway.Settings.System.System_Name;
                options["MarcXML_File_ReaderWriter:System Abbreviation"] = UI_ApplicationCache_Gateway.Settings.System.System_Abbreviation;


                // Save to the database
                try
                {
                    SobekCM_Item_Database.Save_Digital_Resource(Item_To_Complete, options);
                    SobekCM_Item_Database.Save_Behaviors(Item_To_Complete, Item_To_Complete.Behaviors.Text_Searchable, false, false);
                }
                catch (Exception ee)
                {
                    StreamWriter writer = new StreamWriter(digitalResourceDirectory + "\\exception.txt", false);
                    writer.WriteLine("ERROR CAUGHT WHILE SAVING DIGITAL RESOURCE");
                    writer.WriteLine(DateTime.Now.ToString());
                    writer.WriteLine();
                    writer.WriteLine(ee.Message);
                    writer.WriteLine(ee.StackTrace);
                    writer.Flush();
                    writer.Close();
                    throw;
                }


                // Assign the file root and assoc file path
                Item_To_Complete.Web.File_Root     = Item_To_Complete.BibID.Substring(0, 2) + "\\" + Item_To_Complete.BibID.Substring(2, 2) + "\\" + Item_To_Complete.BibID.Substring(4, 2) + "\\" + Item_To_Complete.BibID.Substring(6, 2) + "\\" + Item_To_Complete.BibID.Substring(8, 2);
                Item_To_Complete.Web.AssocFilePath = Item_To_Complete.Web.File_Root + "\\" + Item_To_Complete.VID + "\\";

                //// Create the static html pages
                //string base_url = RequestSpecificValues.Current_Mode.Base_URL;
                //try
                //{
                //    Static_Pages_Builder staticBuilder = new Static_Pages_Builder(UI_ApplicationCache_Gateway.Settings.Servers.System_Base_URL, UI_ApplicationCache_Gateway.Settings.Servers.Base_Data_Directory, RequestSpecificValues.HTML_Skin.Skin_Code);
                //    if (!Directory.Exists(digitalResourceDirectory + "\\" + UI_ApplicationCache_Gateway.Settings.Resources.Backup_Files_Folder_Name))
                //        Directory.CreateDirectory(digitalResourceDirectory + "\\" + UI_ApplicationCache_Gateway.Settings.Resources.Backup_Files_Folder_Name);
                //    string filename = digitalResourceDirectory + "\\" + UI_ApplicationCache_Gateway.Settings.Resources.Backup_Files_Folder_Name + "\\" + Item_To_Complete.BibID + "_" + Item_To_Complete.VID + ".html";
                //    staticBuilder.Create_Item_Citation_HTML(Item_To_Complete, filename, String.Empty);

                //    // Copy the static HTML file to the web server
                //    try
                //    {
                //        if (!Directory.Exists(UI_ApplicationCache_Gateway.Settings.Servers.Static_Pages_Location + currentItem.BibID.Substring(0, 2) + "\\" + currentItem.BibID.Substring(2, 2) + "\\" + currentItem.BibID.Substring(4, 2) + "\\" + currentItem.BibID.Substring(6, 2) + "\\" + currentItem.BibID.Substring(8)))
                //            Directory.CreateDirectory(UI_ApplicationCache_Gateway.Settings.Servers.Static_Pages_Location + currentItem.BibID.Substring(0, 2) + "\\" + currentItem.BibID.Substring(2, 2) + "\\" + currentItem.BibID.Substring(4, 2) + "\\" + currentItem.BibID.Substring(6, 2) + "\\" + currentItem.BibID.Substring(8));
                //        if (File.Exists(filename))
                //            File.Copy(filename, UI_ApplicationCache_Gateway.Settings.Servers.Static_Pages_Location + currentItem.BibID.Substring(0, 2) + "\\" + currentItem.BibID.Substring(2, 2) + "\\" + currentItem.BibID.Substring(4, 2) + "\\" + currentItem.BibID.Substring(6, 2) + "\\" + currentItem.BibID.Substring(8) + "\\" + currentItem.BibID + "_" + currentItem.VID + ".html", true);
                //    }
                //    catch (Exception)
                //    {
                //        // This is not critical
                //    }
                //}
                //catch (Exception)
                //{
                //}

                //RequestSpecificValues.Current_Mode.Base_URL = base_url;

                // Save the rest of the metadata
                Item_To_Complete.Save_SobekCM_METS();

                // Finally, set the currentItem for more processing if there were any files
                if (((image_files.Count > 0) || (download_files.Count > 0)) && (Item_To_Complete.Web.ItemID > 0))
                {
                    SobekCM_Item_Database.Update_Additional_Work_Needed_Flag(Item_To_Complete.Web.ItemID, true);
                }
            }
            catch (Exception ee)
            {
                // Set an initial flag
                criticalErrorEncountered = true;

                string error_body    = "<strong>ERROR ENCOUNTERED DURING ONLINE FILE MANAGEMENT</strong><br /><br /><blockquote>Title: " + Item_To_Complete.Bib_Info.Main_Title.Title + "<br />Permanent Link: <a href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "/" + Item_To_Complete.BibID + "/" + Item_To_Complete.VID + "\">" + RequestSpecificValues.Current_Mode.Base_URL + "/" + Item_To_Complete.BibID + "/" + Item_To_Complete.VID + "</a><br />User: "******"<br /><br /></blockquote>" + ee.ToString().Replace("\n", "<br />");
                string error_subject = "Error during file management for '" + Item_To_Complete.Bib_Info.Main_Title.Title + "'";
                string email_to      = UI_ApplicationCache_Gateway.Settings.Email.System_Error_Email;
                if (email_to.Length == 0)
                {
                    email_to = UI_ApplicationCache_Gateway.Settings.Email.System_Email;
                }
                Email_Helper.SendEmail(email_to, error_subject, error_body, true, String.Empty);
            }


            return(criticalErrorEncountered);
        }
        private bool complete_item_submission(SobekCM_Item Item_To_Complete, Custom_Tracer Tracer)
        {
            // Set an initial flag
            criticalErrorEncountered = false;

            string[] all_files = Directory.GetFiles(digitalResourceDirectory);
            SortedList <string, List <string> > image_files    = new SortedList <string, List <string> >();
            SortedList <string, List <string> > download_files = new SortedList <string, List <string> >();

            foreach (string thisFile in all_files)
            {
                FileInfo thisFileInfo = new FileInfo(thisFile);

                if ((thisFileInfo.Name.IndexOf("agreement.txt") != 0) && (thisFileInfo.Name.IndexOf("TEMP000001_00001.mets") != 0) && (thisFileInfo.Name.IndexOf("doc.xml") != 0) && (thisFileInfo.Name.IndexOf("ufdc_mets.xml") != 0) && (thisFileInfo.Name.IndexOf("marc.xml") != 0))
                {
                    // Get information about this files name and extension
                    string extension_upper         = thisFileInfo.Extension.ToUpper();
                    string filename_sans_extension = thisFileInfo.Name.Replace(thisFileInfo.Extension, "");
                    string name_upper = thisFileInfo.Name.ToUpper();

                    // Is this a page image?
                    if ((extension_upper == ".JPG") || (extension_upper == ".TIF") || (extension_upper == ".JP2") || (extension_upper == ".JPX"))
                    {
                        // Exclude .QC.jpg files
                        if (name_upper.IndexOf(".QC.JPG") < 0)
                        {
                            // If this is a thumbnail, trim off the THM part on the file name
                            if (name_upper.IndexOf("THM.JPG") > 0)
                            {
                                filename_sans_extension = filename_sans_extension.Substring(0, filename_sans_extension.Length - 3);
                            }

                            // Is this the first image file with this name?
                            if (image_files.ContainsKey(filename_sans_extension.ToLower()))
                            {
                                image_files[filename_sans_extension.ToLower()].Add(thisFileInfo.Name);
                            }
                            else
                            {
                                List <string> newImageGrouping = new List <string> {
                                    thisFileInfo.Name
                                };
                                image_files[filename_sans_extension.ToLower()] = newImageGrouping;
                            }
                        }
                    }
                    else
                    {
                        // If this does not match the exclusion regular expression, than add this
                        if ((!Regex.Match(thisFileInfo.Name, SobekCM_Library_Settings.Files_To_Exclude_From_Downloads, RegexOptions.IgnoreCase).Success) && (String.Compare(thisFileInfo.Name, Item_To_Complete.BibID + "_" + Item_To_Complete.VID + ".html", true) != 0))
                        {
                            // Is this the first image file with this name?
                            if (download_files.ContainsKey(filename_sans_extension.ToLower()))
                            {
                                download_files[filename_sans_extension.ToLower()].Add(thisFileInfo.Name);
                            }
                            else
                            {
                                List <string> newDownloadGrouping = new List <string> {
                                    thisFileInfo.Name
                                };
                                download_files[filename_sans_extension.ToLower()] = newDownloadGrouping;
                            }
                        }
                    }
                }
            }

            // This package is good to go, so build it, save, etc...
            try
            {
                // Save the METS file to the database and back to the directory
                Item_To_Complete.Source_Directory = digitalResourceDirectory;

                // Step through and add each file
                Item_To_Complete.Divisions.Download_Tree.Clear();

                // Step through each file
                bool error_reading_file_occurred = false;

                // Add the image files first
                bool jpeg_added = false;
                bool jp2_added  = false;
                foreach (string thisFileKey in image_files.Keys)
                {
                    // Get the list of files
                    List <string> theseFiles = image_files[thisFileKey];

                    // Add each file
                    foreach (string thisFile in theseFiles)
                    {
                        // Create the new file object and compute a label
                        System.IO.FileInfo fileInfo = new System.IO.FileInfo(thisFile);
                        SobekCM.Resource_Object.Divisions.SobekCM_File_Info newFile = new SobekCM.Resource_Object.Divisions.SobekCM_File_Info(fileInfo.Name);
                        string label = fileInfo.Name.Replace(fileInfo.Extension, "");
                        if (System.Web.HttpContext.Current.Session["file_" + item.Web.ItemID + "_" + thisFileKey] != null)
                        {
                            string possible_label = System.Web.HttpContext.Current.Session["file_" + item.Web.ItemID + "_" + thisFileKey].ToString();
                            if (possible_label.Length > 0)
                            {
                                label = possible_label;
                            }
                        }

                        // Add this file
                        item.Divisions.Physical_Tree.Add_File(newFile, label);

                        // Seperate code for JP2 and JPEG type files
                        string extension = fileInfo.Extension.ToUpper();
                        if (extension.IndexOf("JP2") >= 0)
                        {
                            if (!error_reading_file_occurred)
                            {
                                if (!newFile.Compute_Jpeg2000_Attributes(item.Source_Directory))
                                {
                                    error_reading_file_occurred = true;
                                }
                            }
                            jp2_added = true;
                        }
                        else
                        {
                            if (!error_reading_file_occurred)
                            {
                                if (!newFile.Compute_Jpeg_Attributes(item.Source_Directory))
                                {
                                    error_reading_file_occurred = true;
                                }
                            }
                            jpeg_added = true;
                        }
                    }
                }

                // Add the download files next
                foreach (string thisFileKey in download_files.Keys)
                {
                    // Get the list of files
                    List <string> theseFiles = download_files[thisFileKey];

                    // Add each file
                    foreach (string thisFile in theseFiles)
                    {
                        // Create the new file object and compute a label
                        FileInfo          fileInfo = new FileInfo(thisFile);
                        SobekCM_File_Info newFile  = new SobekCM_File_Info(fileInfo.Name);
                        string            label    = fileInfo.Name.Replace(fileInfo.Extension, "");
                        if (HttpContext.Current.Session["file_" + item.Web.ItemID + "_" + thisFileKey] != null)
                        {
                            string possible_label = HttpContext.Current.Session["file_" + item.Web.ItemID + "_" + thisFileKey].ToString();
                            if (possible_label.Length > 0)
                            {
                                label = possible_label;
                            }
                        }

                        // Add this file
                        Item_To_Complete.Divisions.Download_Tree.Add_File(newFile, label);
                    }
                }

                // Add the JPEG2000 and JPEG-specific viewers
                item.Behaviors.Clear_Views();
                if (jpeg_added)
                {
                    item.Behaviors.Add_View(SobekCM.Resource_Object.Behaviors.View_Enum.JPEG);
                }
                if (jp2_added)
                {
                    item.Behaviors.Add_View(SobekCM.Resource_Object.Behaviors.View_Enum.JPEG2000);
                }


                // Determine the total size of the package before saving
                string[] all_files_final = Directory.GetFiles(digitalResourceDirectory);
                double   size            = all_files_final.Aggregate <string, double>(0, (current, thisFile) => current + (((new FileInfo(thisFile)).Length) / 1024));
                Item_To_Complete.DiskSize_MB = size;

                // Save to the database
                try
                {
                    SobekCM_Database.Save_Digital_Resource(Item_To_Complete);
                    SobekCM_Database.Save_Behaviors(Item_To_Complete, Item_To_Complete.Behaviors.Text_Searchable, false);
                }
                catch (Exception ee)
                {
                    StreamWriter writer = new StreamWriter(digitalResourceDirectory + "\\exception.txt", false);
                    writer.WriteLine("ERROR CAUGHT WHILE SAVING DIGITAL RESOURCE");
                    writer.WriteLine(DateTime.Now.ToString());
                    writer.WriteLine();
                    writer.WriteLine(ee.Message);
                    writer.WriteLine(ee.StackTrace);
                    writer.Flush();
                    writer.Close();
                    throw;
                }


                // Assign the file root and assoc file path
                Item_To_Complete.Web.File_Root     = Item_To_Complete.BibID.Substring(0, 2) + "\\" + Item_To_Complete.BibID.Substring(2, 2) + "\\" + Item_To_Complete.BibID.Substring(4, 2) + "\\" + Item_To_Complete.BibID.Substring(6, 2) + "\\" + Item_To_Complete.BibID.Substring(8, 2);
                Item_To_Complete.Web.AssocFilePath = Item_To_Complete.Web.File_Root + "\\" + Item_To_Complete.VID + "\\";

                // Create the static html pages
                string base_url = currentMode.Base_URL;
                try
                {
                    Static_Pages_Builder staticBuilder = new Static_Pages_Builder(SobekCM_Library_Settings.System_Base_URL, SobekCM_Library_Settings.Base_Data_Directory, Translator, codeManager, itemList, iconList, webSkin);
                    string filename = digitalResourceDirectory + "\\" + Item_To_Complete.BibID + "_" + Item_To_Complete.VID + ".html";
                    staticBuilder.Create_Item_Citation_HTML(Item_To_Complete, filename, String.Empty);
                }
                catch (Exception ee)
                {
                    string error = ee.Message;
                }

                currentMode.Base_URL = base_url;

                // Save the rest of the metadata
                Item_To_Complete.Save_SobekCM_METS();

                // Finally, set the item for more processing if there were any files
                if (((image_files.Count > 0) || (download_files.Count > 0)) && (Item_To_Complete.Web.ItemID > 0))
                {
                    Database.SobekCM_Database.Update_Additional_Work_Needed_Flag(Item_To_Complete.Web.ItemID, true, Tracer);
                }
            }
            catch (Exception ee)
            {
                validationErrors.Add("Error encountered during item save!");
                validationErrors.Add(ee.ToString().Replace("\r", "<br />"));

                // Set an initial flag
                criticalErrorEncountered = true;

                string error_body    = "<strong>ERROR ENCOUNTERED DURING ONLINE FILE MANAGEMENT</strong><br /><br /><blockquote>Title: " + Item_To_Complete.Bib_Info.Main_Title.Title + "<br />Permanent Link: <a href=\"" + base.currentMode.Base_URL + "/" + Item_To_Complete.BibID + "/" + Item_To_Complete.VID + "\">" + base.currentMode.Base_URL + "/" + Item_To_Complete.BibID + "/" + Item_To_Complete.VID + "</a><br />User: "******"<br /><br /></blockquote>" + ee.ToString().Replace("\n", "<br />");
                string error_subject = "Error during file management for '" + Item_To_Complete.Bib_Info.Main_Title.Title + "'";
                string email_to      = SobekCM_Library_Settings.System_Error_Email;
                if (email_to.Length == 0)
                {
                    email_to = SobekCM_Library_Settings.System_Email;
                }
                Database.SobekCM_Database.Send_Database_Email(email_to, error_subject, error_body, true, false, -1);
            }


            return(criticalErrorEncountered);
        }
        /// <summary> Reads the amdSec at the current position in the XmlTextReader and associates it with the
        /// entire package  </summary>
        /// <param name="Input_XmlReader"> Open XmlReader from which to read the metadata </param>
        /// <param name="Return_Package"> Package into which to read the metadata</param>
        /// <param name="Options"> Dictionary of any options which this METS section reader may utilize</param>
        /// <returns> TRUE if successful, otherwise FALSE</returns>
        /// <remarks> One option is REQUIRED for this to work, you must pass in  a Dictionary&lt;string,SobekCM_File_Info&gt;
        /// generic dictionary with all the pre-collection file information stored by fileid.  It should be include in the
        /// Options dictionary under the key 'SobekCM_FileInfo_METS_amdSec_ReaderWriter:Files_By_FileID'.</remarks>
        public bool Read_amdSec(XmlReader Input_XmlReader, SobekCM_Item Return_Package, Dictionary <string, object> Options)
        {
            Dictionary <string, SobekCM_File_Info> files_by_fileid = null;

            if ((Options == null) || (!Options.ContainsKey("SobekCM_FileInfo_METS_amdSec_ReaderWriter:Files_By_FileID")))
            {
                return(false);
            }

            files_by_fileid = (Dictionary <string, SobekCM_File_Info>)Options["SobekCM_FileInfo_METS_amdSec_ReaderWriter:Files_By_FileID"];


            string fileid = String.Empty;

            // Loop through reading each XML node
            do
            {
                // If this is the end of this section, return
                if ((Input_XmlReader.NodeType == XmlNodeType.EndElement) && (Input_XmlReader.Name == sobekcm_namespace + ":FileInfo"))
                {
                    return(true);
                }

                // get the right division information based on node type
                switch (Input_XmlReader.NodeType)
                {
                case XmlNodeType.EndElement:
                    if (Input_XmlReader.Name == sobekcm_namespace + ":FileInfo")
                    {
                        return(true);
                    }
                    break;

                case XmlNodeType.Element:
                    if ((Input_XmlReader.Name == sobekcm_namespace + ":File") && (Input_XmlReader.HasAttributes) && (Input_XmlReader.MoveToAttribute("fileid")))
                    {
                        fileid = Input_XmlReader.Value;

                        // Save this information
                        SobekCM_File_Info existingFile = null;
                        if (!files_by_fileid.ContainsKey(fileid))
                        {
                            existingFile            = new SobekCM_File_Info(String.Empty);
                            files_by_fileid[fileid] = existingFile;
                        }
                        else
                        {
                            existingFile = files_by_fileid[fileid];
                        }

                        try
                        {
                            if (Input_XmlReader.MoveToAttribute("width"))
                            {
                                existingFile.Width = Convert.ToUInt16(Input_XmlReader.Value);
                            }

                            if (Input_XmlReader.MoveToAttribute("height"))
                            {
                                existingFile.Height = Convert.ToUInt16(Input_XmlReader.Value);
                            }
                        }
                        catch
                        {
                        }
                    }
                    break;
                }
            } while (Input_XmlReader.Read());

            // Return false since this read all the way to the end of the steam
            return(false);
        }
コード例 #11
0
        private bool complete_item_submission(SobekCM_Item Item_To_Complete, Custom_Tracer Tracer)
        {
            // Set an initial flag
            criticalErrorEncountered = false;

            string final_destination = Item_To_Complete.Source_Directory;


            string[] image_files = Directory.GetFiles(digitalResourceDirectory);


            // This package is good to go, so build it, save, etc...
            try
            {
                // Step through each file
                bool error_reading_file_occurred = false;

                // Add the SourceImage files first
                bool jpeg_added = false;
                bool jp2_added  = false;
                foreach (string thisFile in image_files)
                {
                    // Create the new file object and compute a label
                    FileInfo          fileInfo = new System.IO.FileInfo(thisFile);
                    SobekCM_File_Info newFile  = new SobekCM_File_Info(fileInfo.Name);

                    // Copy this file
                    if (File.Exists(final_destination + "\\" + fileInfo.Name))
                    {
                        File.Copy(thisFile, final_destination + "\\" + fileInfo.Name, true);
                    }
                    else
                    {
                        File.Copy(thisFile, final_destination + "\\" + fileInfo.Name, true);
                        item.Divisions.Physical_Tree.Add_File(newFile, "New Page");


                        // Seperate code for JP2 and JPEG type files
                        string extension = fileInfo.Extension.ToUpper();
                        if (extension.IndexOf("JP2") >= 0)
                        {
                            if (!error_reading_file_occurred)
                            {
                                if (!newFile.Compute_Jpeg2000_Attributes(item.Source_Directory))
                                {
                                    error_reading_file_occurred = true;
                                }
                            }
                            jp2_added = true;
                        }
                        else if (extension.IndexOf("JPG") >= 0)
                        {
                            if (!error_reading_file_occurred)
                            {
                                if (!newFile.Compute_Jpeg_Attributes(item.Source_Directory))
                                {
                                    error_reading_file_occurred = true;
                                }
                            }
                            jpeg_added = true;
                        }
                    }
                }

                // Add the JPEG2000 and JPEG-specific viewers
                //item.Behaviors.Clear_Views();
                if (jpeg_added)
                {
                    // Is a JPEG view already existing?
                    bool jpeg_viewer_already_exists = false;
                    foreach (View_Object thisViewer in item.Behaviors.Views)
                    {
                        if (thisViewer.View_Type == View_Enum.JPEG)
                        {
                            jpeg_viewer_already_exists = true;
                            break;
                        }
                    }

                    // Add the JPEG view if it did not already exists
                    if (!jpeg_viewer_already_exists)
                    {
                        item.Behaviors.Add_View(View_Enum.JPEG);
                    }
                }

                // If a JPEG2000 file was just added, ensure it exists as a view for this item
                if (jp2_added)
                {
                    // Is a JPEG view already existing?
                    bool jpg2000_viewer_already_exists = false;
                    foreach (View_Object thisViewer in item.Behaviors.Views)
                    {
                        if (thisViewer.View_Type == View_Enum.JPEG2000)
                        {
                            jpg2000_viewer_already_exists = true;
                            break;
                        }
                    }

                    // Add the JPEG2000 view if it did not already exists
                    if (!jpg2000_viewer_already_exists)
                    {
                        item.Behaviors.Add_View(View_Enum.JPEG2000);
                    }
                }

                // Determine the total size of the package before saving
                string[] all_files_final = Directory.GetFiles(final_destination);
                double   size            = all_files_final.Aggregate <string, double>(0, (current, thisFile) => current + (((new FileInfo(thisFile)).Length) / 1024));
                Item_To_Complete.DiskSize_MB = size;

                // Save to the database
                try
                {
                    SobekCM_Database.Save_Digital_Resource(Item_To_Complete);
                }
                catch (Exception ee)
                {
                    StreamWriter writer = new StreamWriter(digitalResourceDirectory + "\\exception.txt", false);
                    writer.WriteLine("ERROR CAUGHT WHILE SAVING DIGITAL RESOURCE");
                    writer.WriteLine(DateTime.Now.ToString());
                    writer.WriteLine();
                    writer.WriteLine(ee.Message);
                    writer.WriteLine(ee.StackTrace);
                    writer.Flush();
                    writer.Close();
                    throw;
                }


                // Assign the file root and assoc file path
                Item_To_Complete.Web.File_Root     = Item_To_Complete.BibID.Substring(0, 2) + "\\" + Item_To_Complete.BibID.Substring(2, 2) + "\\" + Item_To_Complete.BibID.Substring(4, 2) + "\\" + Item_To_Complete.BibID.Substring(6, 2) + "\\" + Item_To_Complete.BibID.Substring(8, 2);
                Item_To_Complete.Web.AssocFilePath = Item_To_Complete.Web.File_Root + "\\" + Item_To_Complete.VID + "\\";

                // Save the rest of the metadata
                Item_To_Complete.Save_SobekCM_METS();

                // Finally, set the item for more processing if there were any files
                if ((image_files.Length > 0) && (Item_To_Complete.Web.ItemID > 0))
                {
                    Database.SobekCM_Database.Update_Additional_Work_Needed_Flag(Item_To_Complete.Web.ItemID, true, Tracer);
                }

                foreach (string thisFile in image_files)
                {
                    try
                    {
                        File.Delete(thisFile);
                    }
                    catch
                    {
                        // Do nothing - not a fatal problem
                    }
                }

                try
                {
                    Directory.Delete(digitalResourceDirectory);
                }
                catch
                {
                    // Do nothing - not a fatal problem
                }

                // This may be called from QC, so check on that as well
                string userInProcessDirectory = SobekCM_Library_Settings.In_Process_Submission_Location + "\\" + user.UserName.Replace(".", "").Replace("@", "") + "\\qcwork\\" + Item_To_Complete.METS_Header.ObjectID;
                if (user.ShibbID.Trim().Length > 0)
                {
                    userInProcessDirectory = SobekCM_Library_Settings.In_Process_Submission_Location + "\\" + user.ShibbID + "\\qcwork\\" + Item_To_Complete.METS_Header.ObjectID;
                }

                // Make the folder for the user in process directory
                if (Directory.Exists(userInProcessDirectory))
                {
                    foreach (string thisFile in Directory.GetFiles(userInProcessDirectory))
                    {
                        try
                        {
                            File.Delete(thisFile);
                        }
                        catch
                        {
                            // Do nothing - not a fatal problem
                        }
                    }
                }
                HttpContext.Current.Session[Item_To_Complete.BibID + "_" + Item_To_Complete.VID + " QC Work"] = null;
            }
            catch (Exception ee)
            {
                validationErrors.Add("Error encountered during item save!");
                validationErrors.Add(ee.ToString().Replace("\r", "<br />"));

                // Set an initial flag
                criticalErrorEncountered = true;

                string error_body    = "<strong>ERROR ENCOUNTERED DURING ONLINE PAGE IMAGE UPLOAD</strong><br /><br /><blockquote>Title: " + Item_To_Complete.Bib_Info.Main_Title.Title + "<br />Permanent Link: <a href=\"" + base.currentMode.Base_URL + "/" + Item_To_Complete.BibID + "/" + Item_To_Complete.VID + "\">" + base.currentMode.Base_URL + "/" + Item_To_Complete.BibID + "/" + Item_To_Complete.VID + "</a><br />User: "******"<br /><br /></blockquote>" + ee.ToString().Replace("\n", "<br />");
                string error_subject = "Error during file management for '" + Item_To_Complete.Bib_Info.Main_Title.Title + "'";
                string email_to      = SobekCM_Library_Settings.System_Error_Email;
                if (email_to.Length == 0)
                {
                    email_to = SobekCM_Library_Settings.System_Email;
                }
                Database.SobekCM_Database.Send_Database_Email(email_to, error_subject, error_body, true, false, -1, -1);
            }


            return(criticalErrorEncountered);
        }
コード例 #12
0
        public static bool add_local_files(string[] files, Division_Info BibDivInfo, string directory, ref int pages_added, ref int files_added)
        {
            bool returnValue = false;

            files_added = 0;
            pages_added = 0;

            // Get the list of all divisions and page nodes (with attached files)
            List <abstract_TreeNode> allDivs = BibDivInfo.Physical_Tree.Divisions_PreOrder;

            // Get the full name for the current directory, normalized
            string package_normalized_dirname = (new DirectoryInfo(directory)).FullName.ToUpper();

            // Store the hashtable between directory and relative directory (computed as necessary)
            Dictionary <string, string> directory_to_relative = new Dictionary <string, string>();

            // Get the list of selected files
            foreach (string thisFile in files)
            {
                // Get the basic file information
                FileInfo thisFileInfo = new FileInfo(thisFile);

                // Get the normalized directoryname for this
                string this_normalized_dirname = thisFileInfo.Directory.FullName.ToUpper();

                // Is this from the same directory?
                bool   abort = false;
                string relative_directory = String.Empty;
                if (!this_normalized_dirname.Equals(package_normalized_dirname))
                {
                    // Is this in a subdirectory
                    if (this_normalized_dirname.Contains(package_normalized_dirname))
                    {
                        // Was the relative directory already computed?
                        if (directory_to_relative.ContainsKey(this_normalized_dirname))
                        {
                            relative_directory = directory_to_relative[this_normalized_dirname];
                        }
                        else
                        {
                            // Compute the relative directory here
                            StringBuilder relativeBuilder     = new StringBuilder();
                            DirectoryInfo relativeDirIterator = thisFileInfo.Directory;
                            relativeBuilder.Append(relativeDirIterator.Name);
                            int binding_counter = 0;
                            while ((relativeDirIterator.Parent.FullName.ToUpper() != package_normalized_dirname) && (binding_counter < 10))
                            {
                                relativeDirIterator = relativeDirIterator.Parent;
                                relativeBuilder.Insert(0, relativeDirIterator.Name + "\\");
                                binding_counter++;
                            }
                            if (binding_counter >= 10)
                            {
                                abort = true;
                                MessageBox.Show("Error finding relative directory of file directory.   ");
                            }

                            // Set the relative directory and save it
                            relative_directory = relativeBuilder.ToString();
                            directory_to_relative[this_normalized_dirname] = relative_directory;
                        }
                    }
                    else
                    {
                        // Not in a subdirectory, so look at potentially moving this file over
                        if (File.Exists(directory + "\\" + thisFileInfo.Name))
                        {
                            DialogResult thisResult = MessageBox.Show("New file matches existing file in the resource directory.\n\nWould you like to copy and overwrite the existing file?     ", "Overwrite?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                            if (thisResult != DialogResult.Yes)
                            {
                                abort = true;
                            }
                            else
                            {
                                File.Copy(thisFile, directory + "\\" + thisFileInfo.Name, true);
                                thisFileInfo = new FileInfo(directory + "\\" + thisFileInfo.Name);
                            }
                        }
                        else
                        {
                            File.Copy(thisFile, directory + "\\" + thisFileInfo.Name, true);
                            thisFileInfo = new FileInfo(directory + "\\" + thisFileInfo.Name);
                        }
                    }
                }

                // Create the file object, so we can use it we need to
                SobekCM_File_Info newMetsFile = new SobekCM_File_Info(relative_directory.Length == 0 ? thisFileInfo.Name : relative_directory + "\\" + thisFileInfo.Name);

                if (!abort)
                {
                    // Get the short filename for inserting into the structure map
                    string filename = newMetsFile.File_Name_Sans_Extension;
                    if (MetaTemplate_UserSettings.Page_Images_In_Seperate_Folders_Can_Be_Same_Page)
                    {
                        if (filename.IndexOf("\\") > 0)
                        {
                            string[] slash_splitter = filename.Split("\\".ToCharArray());
                            filename = slash_splitter[slash_splitter.Length - 1];
                        }
                    }

                    string extension = newMetsFile.File_Extension;

                    // Is this an image file?
                    if ((extension == "TIF") || (extension == "TIFF") || (extension == "JPG") || (extension == "JPEG") || (extension == "GIF") || (extension == "JP2") || (extension == "JPX") || (extension == "TXT") || (extension == "PRO") || (extension == "PNG"))
                    {
                        bool file_found = false;
                        bool page_found = false;

                        // Does this match an existing page file?
                        foreach (abstract_TreeNode thisNode in allDivs)
                        {
                            // Is this a page?
                            if (thisNode.Page)
                            {
                                // Step through all the files in this page
                                Page_TreeNode pageNode = (Page_TreeNode)thisNode;
                                foreach (SobekCM_File_Info existingFile in pageNode.Files)
                                {
                                    // Get the filename for this
                                    string existingFileName = existingFile.System_Name.ToUpper();
                                    if (MetaTemplate_UserSettings.Page_Images_In_Seperate_Folders_Can_Be_Same_Page)
                                    {
                                        if (existingFileName.IndexOf("\\") > 0)
                                        {
                                            string[] slash_splitter = existingFileName.Split("\\".ToCharArray());
                                            existingFileName = slash_splitter[slash_splitter.Length - 1];
                                        }
                                    }

                                    // Does this system name match the filename?
                                    if (existingFileName.IndexOf(filename + ".") == 0)
                                    {
                                        page_found = true;
                                        if (existingFileName == filename + "." + extension)
                                        {
                                            // Since we strip THM.JPG from the filename, let's do one last check for this
                                            if (existingFile.System_Name.ToUpper() == newMetsFile.System_Name.ToUpper())
                                            {
                                                file_found = true;
                                                break;
                                            }
                                        }
                                    }
                                }

                                // Is this a matching page?
                                if (page_found)
                                {
                                    // If the file was not found, add this to the page
                                    if (!file_found)
                                    {
                                        pageNode.Files.Add(newMetsFile);
                                        files_added++;
                                        returnValue = true;
                                    }

                                    break;
                                }
                            }
                        }

                        // If not found, add this as a new page at the bottom
                        if (!page_found)
                        {
                            // If there is no root division yet, make one
                            if (BibDivInfo.Physical_Tree.Roots.Count == 0)
                            {
                                Division_TreeNode newRoot = new Division_TreeNode("Main", String.Empty);
                                BibDivInfo.Physical_Tree.Roots.Add(newRoot);
                            }

                            // Create a mage node
                            Page_TreeNode newPage = new Page_TreeNode();
                            newPage.Files.Add(newMetsFile);
                            ((Division_TreeNode)BibDivInfo.Physical_Tree.Roots[0]).Nodes.Add(newPage);
                            files_added++;
                            pages_added++;
                            returnValue = true;

                            // Woah!  This call below should be refactored since this is a time-expensive operation to
                            // pull the entire nodes each time they list is altered.
                            allDivs = BibDivInfo.Physical_Tree.Divisions_PreOrder;
                        }
                    }
                    else
                    {
                        BibDivInfo.Download_Tree.Add_File(thisFileInfo.Name);
                        files_added++;
                        returnValue = true;
                    }
                }
            }

            return(returnValue);
        }
コード例 #13
0
        /// <summary> Create a test digital resource item  </summary>
        /// <param name="directory">Directory for the package source directory</param>
        /// <returns>Fully built test bib package</returns>
        public static SobekCM_Item Create(string directory)
        {
            SobekCM_Item testPackage = new SobekCM_Item();

            // Add all the METS header information
            testPackage.METS_Header.Create_Date        = new DateTime(2007, 1, 1);
            testPackage.METS_Header.Modify_Date        = DateTime.Now;
            testPackage.METS_Header.Creator_Individual = "Mark Sullivan";
            testPackage.METS_Header.Add_Creator_Individual_Notes("Programmer of new SobekCM.Resource_Object");
            testPackage.METS_Header.Add_Creator_Individual_Notes("Adding coordinates");
            testPackage.METS_Header.Creator_Organization = "University of Florida";
            testPackage.METS_Header.Creator_Software     = "SobekCM Bib Package Test";
            testPackage.METS_Header.RecordStatus_Enum    = METS_Record_Status.COMPLETE;
            testPackage.METS_Header.Add_Creator_Org_Notes("This test package was done to test DLCs new METS package");

            // Add all the MODS elements
            Abstract_Info testAbstract = testPackage.Bib_Info.Add_Abstract("This is a sample abstract", "en");

            testPackage.Bib_Info.Add_Abstract("Tämä on esimerkki abstrakteja", "fin");
            testAbstract.Display_Label = "Summary Abstract";
            testAbstract.Type          = "summary";

            testPackage.Bib_Info.Access_Condition.Text          = "All rights are reserved by source institution.";
            testPackage.Bib_Info.Access_Condition.Language      = "en";
            testPackage.Bib_Info.Access_Condition.Type          = "restrictions on use";
            testPackage.Bib_Info.Access_Condition.Display_Label = "Rights";

            testPackage.Bib_Info.Add_Identifier("000123234", "OCLC", "Electronic OCLC");
            testPackage.Bib_Info.Add_Identifier("182-asdsd-28k", "DOI");

            testPackage.Bib_Info.Add_Language("English", String.Empty, "en");
            testPackage.Bib_Info.Add_Language("Finnish");
            testPackage.Bib_Info.Add_Language(String.Empty, "ita", String.Empty);

            testPackage.Bib_Info.Location.Holding_Code            = "MVS";
            testPackage.Bib_Info.Location.Holding_Name            = "From the Private Library of Mark Sullivan";
            testPackage.Bib_Info.Location.PURL                    = "http://www.uflib.ufl.edu/ufdc/?b=CA00000000";
            testPackage.Bib_Info.Location.Other_URL               = "http://www.fnhm.edu";
            testPackage.Bib_Info.Location.Other_URL_Display_Label = "Specimen Information";
            testPackage.Bib_Info.Location.Other_URL_Note          = "Specimen FLAS 125342 Database";
            testPackage.Bib_Info.Location.EAD_URL                 = "http://digital.uflib.ufl.edu/";
            testPackage.Bib_Info.Location.EAD_Name                = "Digital Library Center Finding Guide";

            testPackage.Bib_Info.Main_Entity_Name.Name_Type        = Name_Info_Type_Enum.personal;
            testPackage.Bib_Info.Main_Entity_Name.Full_Name        = "Brown, B.F.";
            testPackage.Bib_Info.Main_Entity_Name.Terms_Of_Address = "Dr.";
            testPackage.Bib_Info.Main_Entity_Name.Display_Form     = "B.F. Brown";
            testPackage.Bib_Info.Main_Entity_Name.Affiliation      = "Chemistry Dept., American University";
            testPackage.Bib_Info.Main_Entity_Name.Description      = "Chemistry Professor Emeritus";
            testPackage.Bib_Info.Main_Entity_Name.Add_Role("Author");

            Zoological_Taxonomy_Info taxonInfo = new Zoological_Taxonomy_Info();

            testPackage.Add_Metadata_Module(GlobalVar.ZOOLOGICAL_TAXONOMY_METADATA_MODULE_KEY, taxonInfo);
            taxonInfo.Scientific_Name       = "Ctenomys sociabilis";
            taxonInfo.Higher_Classification = "Animalia; Chordata; Vertebrata; Mammalia; Theria; Eutheria; Rodentia; Hystricognatha; Hystricognathi; Ctenomyidae; Ctenomyini; Ctenomys";
            taxonInfo.Kingdom          = "Animalia";
            taxonInfo.Phylum           = "Chordata";
            taxonInfo.Class            = "Mammalia";
            taxonInfo.Order            = "Rodentia";
            taxonInfo.Family           = "Ctenomyidae";
            taxonInfo.Genus            = "Ctenomys";
            taxonInfo.Specific_Epithet = "sociabilis";
            taxonInfo.Taxonomic_Rank   = "species";
            taxonInfo.Common_Name      = "Social Tuco-Tuco";

            Name_Info name1 = new Name_Info();

            name1.Name_Type        = Name_Info_Type_Enum.personal;
            name1.Given_Name       = "John Paul";
            name1.Terms_Of_Address = "Pope; II";
            name1.Dates            = "1920-2002";
            name1.User_Submitted   = true;
            testPackage.Bib_Info.Add_Named_Entity(name1);

            Name_Info name2 = new Name_Info();

            name2.Name_Type = Name_Info_Type_Enum.conference;
            name2.Full_Name = "Paris Peace Conference (1919-1920)";
            name2.Dates     = "1919-1920";
            testPackage.Bib_Info.Add_Named_Entity(name2);

            Name_Info name3 = new Name_Info();

            name3.Name_Type = Name_Info_Type_Enum.corporate;
            name3.Full_Name = "United States -- Court of Appeals (2nd Court)";
            testPackage.Bib_Info.Add_Named_Entity(name3);

            Name_Info name4 = new Name_Info();

            name4.Name_Type        = Name_Info_Type_Enum.personal;
            name4.Full_Name        = "Wilson, Mary";
            name4.Display_Form     = "Mary 'Weels' Wilson";
            name4.Given_Name       = "Mary";
            name4.Family_Name      = "Wilson";
            name4.ID               = "NAM4";
            name4.Terms_Of_Address = "2nd";
            name4.Add_Role("illustrator");
            name4.Add_Role("cartographer");
            testPackage.Bib_Info.Add_Named_Entity(name4);

            Name_Info donor = new Name_Info();

            donor.Name_Type        = Name_Info_Type_Enum.personal;
            donor.Full_Name        = "Livingston, Arthur";
            donor.Description      = "Gift in honor of Arthur Livingston";
            donor.Terms_Of_Address = "3rd";
            donor.Add_Role("honoree", String.Empty);
            testPackage.Bib_Info.Donor = donor;

            testPackage.Bib_Info.Main_Title.NonSort  = "The ";
            testPackage.Bib_Info.Main_Title.Title    = "Man Who Would Be King";
            testPackage.Bib_Info.Main_Title.Subtitle = "The story of succession in England";

            Title_Info title1 = new Title_Info("homme qui voulut être roi", Title_Type_Enum.translated);

            title1.NonSort  = "L'";
            title1.Language = "fr";
            testPackage.Bib_Info.Add_Other_Title(title1);

            Title_Info title2 = new Title_Info();

            title2.Title         = "Man Who Be King";
            title2.Display_Label = "also known as";
            title2.NonSort       = "The";
            title2.Title_Type    = Title_Type_Enum.alternative;
            testPackage.Bib_Info.Add_Other_Title(title2);

            Title_Info title3 = new Title_Info();

            title3.Title     = "Great works of England";
            title3.Authority = "naf";
            title3.Add_Part_Name("Second Portion");
            title3.Add_Part_Number("2nd");
            title3.Title_Type     = Title_Type_Enum.uniform;
            title3.User_Submitted = true;
            testPackage.Bib_Info.Add_Other_Title(title3);

            testPackage.Bib_Info.Add_Note("Funded by the NEH", Note_Type_Enum.funding);
            testPackage.Bib_Info.Add_Note("Based on a play which originally appeared in France as \"Un peu plus tard, un peu plus tôt\"").User_Submitted = true;
            testPackage.Bib_Info.Add_Note("Anne Baxter (Louise), Maria Perschy (Angela), Gustavo Rojo (Bill), Reginald Gilliam (Mr. Johnson), [Catherine Elliot?] (Aunt Sallie), Ben Tatar (waiter)", Note_Type_Enum.performers, "Performed By");

            testPackage.Bib_Info.Origin_Info.Add_Place("New York", "nyu", "usa");
            testPackage.Bib_Info.Origin_Info.Date_Issued           = "1992";
            testPackage.Bib_Info.Origin_Info.MARC_DateIssued_Start = "1992";
            testPackage.Bib_Info.Origin_Info.MARC_DateIssued_End   = "1993";
            testPackage.Bib_Info.Origin_Info.Date_Copyrighted      = "1999";
            testPackage.Bib_Info.Origin_Info.Edition = "2nd";

            Publisher_Info newPub = testPackage.Bib_Info.Add_Publisher("Published for the American Vacuum Society by the American Institute of Physics");

            newPub.Add_Place("New York, New York");
            newPub.User_Submitted = true;
            testPackage.Bib_Info.Add_Publisher("University of Florida Press House").Add_Place("Gainesville, FL");
            testPackage.Bib_Info.Add_Manufacturer("Addison Randly Publishing House");

            testPackage.Bib_Info.Original_Description.Extent = "1 sound disc (56 min.) : digital ; 3/4 in.";
            testPackage.Bib_Info.Original_Description.Add_Note("The sleeve of this sound disc was damaged in a fire");
            testPackage.Bib_Info.Original_Description.Add_Note("The disc has a moderate amount of scratches, but still plays");

            testPackage.Bib_Info.Series_Part_Info.Day         = "18";
            testPackage.Bib_Info.Series_Part_Info.Day_Index   = 18;
            testPackage.Bib_Info.Series_Part_Info.Month       = "Syyskuu";
            testPackage.Bib_Info.Series_Part_Info.Month_Index = 9;
            testPackage.Bib_Info.Series_Part_Info.Year        = "1992";
            testPackage.Bib_Info.Series_Part_Info.Year_Index  = 1992;

            testPackage.Bib_Info.Series_Part_Info.Enum1       = "Volume 12";
            testPackage.Bib_Info.Series_Part_Info.Enum1_Index = 12;
            testPackage.Bib_Info.Series_Part_Info.Enum2       = "Issue 3";
            testPackage.Bib_Info.Series_Part_Info.Enum2_Index = 3;
            testPackage.Bib_Info.Series_Part_Info.Enum3       = "Part 1";
            testPackage.Bib_Info.Series_Part_Info.Enum3_Index = 1;

            testPackage.Behaviors.Serial_Info.Add_Hierarchy(1, 1992, "1992");
            testPackage.Behaviors.Serial_Info.Add_Hierarchy(2, 9, "Syyskuu");
            testPackage.Behaviors.Serial_Info.Add_Hierarchy(3, 18, "18");

            testPackage.Bib_Info.SeriesTitle.Title = "Shakespeare's most famous musicals";

            testPackage.Bib_Info.Add_Target_Audience("young adults");
            testPackage.Bib_Info.Add_Target_Audience("adolescent", "marctarget");

            testPackage.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Newspaper;

            // Add cartographic subject
            Subject_Info_Cartographics newCartographics = testPackage.Bib_Info.Add_Cartographics_Subject();

            newCartographics.Scale       = "1:2000";
            newCartographics.Projection  = "Conical Projection";
            newCartographics.Coordinates = "E 72°--E 148°/N 13°--N 18°";

            // Add hierarchical geographic subject
            Subject_Info_HierarchicalGeographic hierarchical = testPackage.Bib_Info.Add_Hierarchical_Geographic_Subject();

            hierarchical.Continent = "North America";
            hierarchical.Country   = "United States of America";
            hierarchical.State     = "Kansas";
            hierarchical.County    = "Butler";
            hierarchical.City      = "Augusta";

            // Add hierarchical geographic subject
            Subject_Info_HierarchicalGeographic hierarchical2 = testPackage.Bib_Info.Add_Hierarchical_Geographic_Subject();

            hierarchical2.Region = "Arctic Ocean";

            // Add hierarchical geographic subject
            Subject_Info_HierarchicalGeographic hierarchical3 = testPackage.Bib_Info.Add_Hierarchical_Geographic_Subject();

            hierarchical3.Island    = "Puerto Rico";
            hierarchical3.Language  = "English";
            hierarchical3.Province  = "Provincial";
            hierarchical3.Territory = "Puerto Rico";
            hierarchical3.Area      = "Intercontinental areas (Western Hemisphere)";

            // Add a name subject
            Subject_Info_Name subjname1 = testPackage.Bib_Info.Add_Name_Subject();

            subjname1.Authority = "lcsh";
            subjname1.Full_Name = "Garcia Lorca, Federico";
            subjname1.Dates     = "1898-1936";
            subjname1.Add_Geographic("Russia");
            subjname1.Add_Geographic("Moscow");
            subjname1.Add_Genre("maps");
            subjname1.User_Submitted = true;

            // Add a title information subject
            Subject_Info_TitleInfo subjtitle1 = testPackage.Bib_Info.Add_Title_Subject();

            subjtitle1.Title_Type = Title_Type_Enum.uniform;
            subjtitle1.Authority  = "naf";
            subjtitle1.Title      = "Missale Carnotense";

            // Add a standard subject
            Subject_Info_Standard subject1 = testPackage.Bib_Info.Add_Subject();

            subject1.Authority = "lcsh";
            subject1.Add_Topic("Real property");
            subject1.Add_Geographic("Mississippi");
            subject1.Add_Geographic("Tippah County");
            subject1.Add_Genre("Maps");


            // Add a standard subject
            Subject_Info_Standard subject2 = testPackage.Bib_Info.Add_Subject();

            subject2.Add_Occupation("Migrant laborers");
            subject2.Add_Genre("School district case files");

            // Add a standard subject
            Subject_Info_Standard subject3 = testPackage.Bib_Info.Add_Subject();

            subject3.Authority = "lctgm";
            subject3.Add_Topic("Educational buildings");
            subject3.Add_Geographic("Washington (D.C.)");
            subject3.Add_Temporal("1890-1910");

            // Add a standard subject
            Subject_Info_Standard subject4 = testPackage.Bib_Info.Add_Subject();

            subject4.Authority = "rvm";
            subject4.Language  = "french";
            subject4.Add_Topic("Église catholique");
            subject4.Add_Topic("Histoire");
            subject4.Add_Temporal("20e siècle");

            // Add record information
            testPackage.Bib_Info.Record.Add_Catalog_Language(new Language_Info("English", "eng", "en"));
            testPackage.Bib_Info.Record.Add_Catalog_Language(new Language_Info("French", "fre", "fr"));
            testPackage.Bib_Info.Record.MARC_Creation_Date = "080303";
            testPackage.Bib_Info.Record.Add_MARC_Record_Content_Sources("FUG");
            testPackage.Bib_Info.Record.Record_Origin = "Imported from (OCLC)001213124";


            // Test the items which are in the non-MODS portion of the Bib_Info object
            testPackage.BibID              = "MVS0000001";
            testPackage.VID                = "00001";
            testPackage.Bib_Info.SortDate  = 1234;
            testPackage.Bib_Info.SortTitle = "MAN WHO WOULD BE KING";
            testPackage.Bib_Info.Add_Temporal_Subject(1990, 2002, "Recent history");
            testPackage.Bib_Info.Add_Temporal_Subject(1990, 2002, "Lähihistoria");
            testPackage.Bib_Info.Source.Code      = "UF";
            testPackage.Bib_Info.Source.Statement = "University of Florida";

            // Add an affiliation
            Affiliation_Info affiliation1 = new Affiliation_Info();

            affiliation1.University     = "University of Florida";
            affiliation1.Campus         = "Gainesville Campus";
            affiliation1.College        = "College of Engineering";
            affiliation1.Department     = "Computer Engineering Department";
            affiliation1.Unit           = "Robotics";
            affiliation1.Name_Reference = "NAM4";
            testPackage.Bib_Info.Add_Affiliation(affiliation1);

            // Add a related item
            Related_Item_Info relatedItem1 = new Related_Item_Info();

            relatedItem1.SobekCM_ID   = "UF00001234";
            relatedItem1.Relationship = Related_Item_Type_Enum.preceding;
            relatedItem1.Publisher    = "Gainesville Sun Publishing House";
            relatedItem1.Add_Note(new Note_Info("Digitized with funding from NEH", Note_Type_Enum.funding));
            relatedItem1.Add_Note(new Note_Info("Gainesville Bee was the precursor to this item"));
            relatedItem1.Main_Title.NonSort = "The";
            relatedItem1.Main_Title.Title   = "Gainesville Bee";
            relatedItem1.Add_Identifier("01234353", "oclc");
            relatedItem1.Add_Identifier("002232311", "aleph");
            Name_Info ri_name = new Name_Info();

            ri_name.Full_Name        = "Hills, Bryan";
            ri_name.Terms_Of_Address = "Mr.";
            ri_name.Name_Type        = Name_Info_Type_Enum.personal;
            ri_name.Add_Role("author");
            relatedItem1.Add_Name(ri_name);
            relatedItem1.URL = @"http://www.uflib.ufl.edu/ufdc/?b=UF00001234";
            relatedItem1.URL_Display_Label = "Full Text";
            testPackage.Bib_Info.Add_Related_Item(relatedItem1);

            // Add another related item
            Related_Item_Info relatedItem2 = new Related_Item_Info();

            relatedItem2.Relationship       = Related_Item_Type_Enum.succeeding;
            relatedItem2.SobekCM_ID         = "UF00009999";
            relatedItem2.Main_Title.NonSort = "The";
            relatedItem2.Main_Title.Title   = "Daily Sun";
            relatedItem2.Add_Identifier("0125437", "oclc");
            relatedItem2.Add_Note("Name change occured in Fall 1933");
            relatedItem2.Start_Date = "Fall 1933";
            relatedItem2.End_Date   = "December 31, 1945";
            testPackage.Bib_Info.Add_Related_Item(relatedItem2);

            // Add some processing parameters
            testPackage.Behaviors.Add_Aggregation("JUV");
            testPackage.Behaviors.Add_Aggregation("DLOC");
            testPackage.Behaviors.Add_Aggregation("DLOSA1");
            testPackage.Behaviors.Add_Aggregation("ALICE");
            testPackage.Behaviors.Add_Aggregation("ARTE");

            testPackage.Web.GUID = "GUID!";
            testPackage.Behaviors.Add_Wordmark("DLOC");
            testPackage.Behaviors.Add_Wordmark("UFSPEC");
            testPackage.Behaviors.Main_Thumbnail = "00001thm.jpg";

            // Add some downloads
            testPackage.Divisions.Download_Tree.Add_File("MVS_Complete.PDF");
            testPackage.Divisions.Download_Tree.Add_File("MVS_Complete.MP2");
            testPackage.Divisions.Download_Tree.Add_File("MVS_Part1.MP2");
            testPackage.Divisions.Download_Tree.Add_File("MVS_Part1.PDF");

            // Add some coordinate information
            GeoSpatial_Information geoSpatial = new GeoSpatial_Information();

            testPackage.Add_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY, geoSpatial);
            geoSpatial.Add_Point(29.530151, -82.301459, "Lake Wauberg");
            geoSpatial.Add_Point(29.634352, -82.350640, "Veterinary School");
            Coordinate_Polygon polygon = new Coordinate_Polygon();

            polygon.Label = "University of Florida Campus";
            polygon.Add_Edge_Point(new Coordinate_Point(29.651435, -82.339869, String.Empty));
            polygon.Add_Edge_Point(new Coordinate_Point(29.641216, -82.340298, String.Empty));
            polygon.Add_Edge_Point(new Coordinate_Point(29.629503, -82.371969, String.Empty));
            polygon.Add_Edge_Point(new Coordinate_Point(29.649645, -82.371712, String.Empty));
            polygon.Add_Inner_Point(29.649794, -82.351971, "Stadium");
            polygon.Add_Inner_Point(29.650988, -82.341156, "Library");
            geoSpatial.Add_Polygon(polygon);
            Coordinate_Line line = new Coordinate_Line();

            line.Label = "Waldo Road";
            line.Add_Point(29.652852, -82.310944, "Gainesville");
            line.Add_Point(29.716681, -82.268372, String.Empty);
            line.Add_Point(29.791494, -82.167778, "Waldo");
            geoSpatial.Add_Line(line);


            // Add some performing arts information
            Performing_Arts_Info partInfo = new Performing_Arts_Info();

            testPackage.Add_Metadata_Module("PerformingArts", partInfo);
            partInfo.Performance      = "Hamlet";
            partInfo.Performance_Date = "August 12, 1923";
            Performer performer1 = partInfo.Add_Performer("Sullivan, Mark");

            performer1.Sex        = "M";
            performer1.LifeSpan   = "1873-";
            performer1.Occupation = "actor";
            performer1.Title      = "Mr.";

            Performer performer2 = partInfo.Add_Performer("Waldbart, Julia");

            performer2.Sex        = "F";
            performer2.LifeSpan   = "1876-";
            performer2.Occupation = "actress";
            performer2.Title      = "Mrs.";

            // Add some oral history information
            Oral_Interview_Info oralInfo = new Oral_Interview_Info();

            testPackage.Add_Metadata_Module("OralInterview", oralInfo);
            oralInfo.Interviewee = "Edwards, Herm";
            oralInfo.Interviewer = "Proctor, Samual";

            // Add some learning object resource information
            LearningObjectMetadata lomInfo = new LearningObjectMetadata();

            testPackage.Add_Metadata_Module(GlobalVar.IEEE_LOM_METADATA_MODULE_KEY, lomInfo);
            lomInfo.AggregationLevel = AggregationLevelEnum.level3;
            lomInfo.Status           = StatusEnum.draft;
            LOM_System_Requirements lomReq1 = new LOM_System_Requirements();

            lomReq1.RequirementType = RequirementTypeEnum.operating_system;
            lomReq1.Name.Value      = "Windows";
            lomReq1.MinimumVersion  = "Windows XP";
            lomReq1.MaximumVersion  = "Windows 7";
            lomInfo.Add_SystemRequirements(lomReq1);
            LOM_System_Requirements lomReq2 = new LOM_System_Requirements();

            lomReq2.RequirementType = RequirementTypeEnum.software;
            lomReq2.Name.Value      = "Java SDK";
            lomReq2.MinimumVersion  = "1.7.1";
            lomReq2.MaximumVersion  = "2.09";
            lomInfo.Add_SystemRequirements(lomReq2);
            lomInfo.InteractivityType = InteractivityTypeEnum.mixed;
            lomInfo.Add_LearningResourceType("exercise");
            lomInfo.Add_LearningResourceType("Tutorials", "encdlwebpedagogicaltype");
            lomInfo.InteractivityLevel = InteractivityLevelEnum.high;
            lomInfo.Add_IntendedEndUserRole(IntendedEndUserRoleEnum.learner);
            lomInfo.Add_Context("Undergraduate lower division", "enclearningcontext");
            lomInfo.Add_Context("15", "grade");
            lomInfo.Add_Context("16", "grade");
            lomInfo.Add_Context("5", "group");
            lomInfo.Add_TypicalAgeRange("suitable for children over 7", "en");
            lomInfo.Add_TypicalAgeRange("2-8");
            lomInfo.DifficultyLevel     = DifficultyLevelEnum.medium;
            lomInfo.TypicalLearningTime = "PT45M";

            LOM_Classification lomClassification1 = new LOM_Classification();

            lomInfo.Add_Classification(lomClassification1);
            lomClassification1.Purpose.Value = "Discipline";
            LOM_TaxonPath lomTaxonPath1 = new LOM_TaxonPath();

            lomClassification1.Add_TaxonPath(lomTaxonPath1);
            lomTaxonPath1.Add_SourceName("ARIADNE");
            LOM_Taxon lomTaxon1 = new LOM_Taxon();

            lomTaxonPath1.Add_Taxon(lomTaxon1);
            lomTaxon1.ID = "BF120";
            lomTaxon1.Add_Entry("Work_History", "en");
            lomTaxon1.Add_Entry("Historie", "nl");
            LOM_Taxon lomTaxon2 = new LOM_Taxon();

            lomTaxonPath1.Add_Taxon(lomTaxon2);
            lomTaxon2.ID = "BF120.1";
            lomTaxon2.Add_Entry("American Work_History", "en");
            LOM_Taxon lomTaxon3 = new LOM_Taxon();

            lomTaxonPath1.Add_Taxon(lomTaxon3);
            lomTaxon3.ID = "BF120.1.4";
            lomTaxon3.Add_Entry("American Civil War", "en");

            LOM_Classification lomClassification2 = new LOM_Classification();

            lomInfo.Add_Classification(lomClassification2);
            lomClassification2.Purpose.Value = "Educational Objective";

            LOM_TaxonPath lomTaxonPath2 = new LOM_TaxonPath();

            lomClassification2.Add_TaxonPath(lomTaxonPath2);
            lomTaxonPath2.Add_SourceName("Common Core Standards", "en");
            LOM_Taxon lomTaxon4 = new LOM_Taxon();

            lomTaxonPath2.Add_Taxon(lomTaxon4);
            lomTaxon4.ID = "CCS.Math.Content";
            LOM_Taxon lomTaxon5 = new LOM_Taxon();

            lomTaxonPath2.Add_Taxon(lomTaxon5);
            lomTaxon5.ID = "3";
            lomTaxon5.Add_Entry("Grade 3", "en");
            LOM_Taxon lomTaxon6 = new LOM_Taxon();

            lomTaxonPath2.Add_Taxon(lomTaxon6);
            lomTaxon6.ID = "OA";
            lomTaxon6.Add_Entry("Operations and Algebraic Thinking", "en");
            LOM_Taxon lomTaxon7 = new LOM_Taxon();

            lomTaxonPath2.Add_Taxon(lomTaxon7);
            lomTaxon7.ID = "A";
            lomTaxon7.Add_Entry("Represent and solve problems involving multiplication and division.", "en");
            LOM_Taxon lomTaxon8 = new LOM_Taxon();

            lomTaxonPath2.Add_Taxon(lomTaxon8);
            lomTaxon8.ID = "3";
            lomTaxon8.Add_Entry("Use multiplication and division within 100 to solve word problems in situations involving equal groups, arrays, and measurement quantities, e.g., by using drawings and equations with a symbol for the unknown number to represent the problem.", "en");

            LOM_TaxonPath lomTaxonPath3 = new LOM_TaxonPath();

            lomClassification2.Add_TaxonPath(lomTaxonPath3);
            lomTaxonPath3.Add_SourceName("Common Core Standards", "en");
            LOM_Taxon lomTaxon14 = new LOM_Taxon();

            lomTaxonPath3.Add_Taxon(lomTaxon14);
            lomTaxon14.ID = "CCS.Math.Content";
            LOM_Taxon lomTaxon15 = new LOM_Taxon();

            lomTaxonPath3.Add_Taxon(lomTaxon15);
            lomTaxon15.ID = "3";
            lomTaxon15.Add_Entry("Grade 3", "en");
            LOM_Taxon lomTaxon16 = new LOM_Taxon();

            lomTaxonPath3.Add_Taxon(lomTaxon16);
            lomTaxon16.ID = "OA";
            lomTaxon16.Add_Entry("Operations and Algebraic Thinking", "en");
            LOM_Taxon lomTaxon17 = new LOM_Taxon();

            lomTaxonPath3.Add_Taxon(lomTaxon17);
            lomTaxon17.ID = "A";
            lomTaxon17.Add_Entry("Represent and solve problems involving multiplication and division.", "en");
            LOM_Taxon lomTaxon18 = new LOM_Taxon();

            lomTaxonPath3.Add_Taxon(lomTaxon18);
            lomTaxon18.ID = "4";
            lomTaxon18.Add_Entry("Determine the unknown whole number in a multiplication or division equation relating three whole numbers. For example, determine the unknown number that makes the equation true in each of the equations 8 × ? = 48, 5 = _ ÷ 3, 6 × 6 = ?", "en");


            // Add some views and interfaces
            testPackage.Behaviors.Clear_Web_Skins();
            testPackage.Behaviors.Add_Web_Skin("dLOC");
            testPackage.Behaviors.Add_Web_Skin("UFDC");
            testPackage.Behaviors.Add_View(View_Enum.JPEG2000);
            testPackage.Behaviors.Add_View(View_Enum.JPEG);
            testPackage.Behaviors.Add_View(View_Enum.RELATED_IMAGES);
            testPackage.Behaviors.Add_View(View_Enum.HTML, "Full Document", "MVS001214.html");

            // Create the chapters and pages and link them
            Division_TreeNode chapter1 = new Division_TreeNode("Chapter", "First Chapter");
            Page_TreeNode     page1    = new Page_TreeNode("First Page");
            Page_TreeNode     page2    = new Page_TreeNode("Page 2");

            chapter1.Nodes.Add(page1);
            chapter1.Nodes.Add(page2);
            Division_TreeNode chapter2 = new Division_TreeNode("Chapter", "Last Chapter");
            Page_TreeNode     page3    = new Page_TreeNode("Page 3");
            Page_TreeNode     page4    = new Page_TreeNode("Last Page");

            chapter2.Nodes.Add(page3);
            chapter2.Nodes.Add(page4);
            testPackage.Divisions.Physical_Tree.Roots.Add(chapter1);
            testPackage.Divisions.Physical_Tree.Roots.Add(chapter2);

            // Create the files
            SobekCM_File_Info file1_1 = new SobekCM_File_Info("2000626_0001.jp2", 2120, 1100);
            SobekCM_File_Info file1_2 = new SobekCM_File_Info("2000626_0001.jpg", 630, 330);
            SobekCM_File_Info file1_3 = new SobekCM_File_Info("2000626_0001.tif");
            SobekCM_File_Info file2_1 = new SobekCM_File_Info("2000626_0002.jp2", 1754, 2453);
            SobekCM_File_Info file2_2 = new SobekCM_File_Info("2000626_0002.jpg", 630, 832);
            SobekCM_File_Info file2_3 = new SobekCM_File_Info("2000626_0002.tif");
            SobekCM_File_Info file3_1 = new SobekCM_File_Info("2000626_0003.jp2", 2321, 1232);
            SobekCM_File_Info file3_2 = new SobekCM_File_Info("2000626_0003.jpg", 630, 342);
            SobekCM_File_Info file3_3 = new SobekCM_File_Info("2000626_0003.tif");
            SobekCM_File_Info file4_1 = new SobekCM_File_Info("2000626_0004.jp2", 2145, 1024);
            SobekCM_File_Info file4_2 = new SobekCM_File_Info("2000626_0004.jpg", 630, 326);
            SobekCM_File_Info file4_3 = new SobekCM_File_Info("2000626_0004.tif");

            // Link the files to the pages
            page1.Files.Add(file1_1);
            page1.Files.Add(file1_2);
            page1.Files.Add(file1_3);
            page2.Files.Add(file2_1);
            page2.Files.Add(file2_2);
            page2.Files.Add(file2_3);
            page3.Files.Add(file3_1);
            page3.Files.Add(file3_2);
            page3.Files.Add(file3_3);
            page4.Files.Add(file4_1);
            page4.Files.Add(file4_2);
            page4.Files.Add(file4_3);

            // Add the DAITSS information
            DAITSS_Info daitssInfo = new DAITSS_Info();

            daitssInfo.Account    = "FTU";
            daitssInfo.SubAccount = "CLAS";
            daitssInfo.Project    = "UFDC";
            daitssInfo.toArchive  = true;
            testPackage.Add_Metadata_Module(GlobalVar.DAITSS_METADATA_MODULE_KEY, daitssInfo);

            PALMM_Info palmmInfo = new PALMM_Info();

            testPackage.Add_Metadata_Module("PALMM", palmmInfo);
            palmmInfo.toPALMM = false;

            // Save this package
            testPackage.Source_Directory = directory;
            return(testPackage);
        }