Build_Final_Adjustment_And_Checks() public method

Steps through each element after reading the template information and ensures that any element that must be aware of a comparable element's existence is notified ( such as creator/contributor ).
public Build_Final_Adjustment_And_Checks ( ) : void
return void
示例#1
0
        /// <summary> Reads the CompleteTemplate XML configuration file specified into a CompleteTemplate object </summary>
        /// <param name="XML_File"> Filename of the CompleteTemplate XML configuraiton file to read  </param>
        /// <param name="ThisCompleteTemplate"> CompleteTemplate object to populate form the configuration file </param>
        /// <param name="exclude_divisions"> Flag indicates whether to include the structure map, if included in the CompleteTemplate file </param>
        public void Read_XML(string XML_File, CompleteTemplate ThisCompleteTemplate, bool exclude_divisions)
        {
            // Load this MXF File
            XmlDocument templateXml = new XmlDocument();

            templateXml.Load(XML_File);

            // create the node reader
            XmlNodeReader nodeReader = new XmlNodeReader(templateXml);

            // Read through all main input CompleteTemplate tag is found
            move_to_node(nodeReader, "input_template");

            // Process all of the header information for this CompleteTemplate
            process_template_header(nodeReader, ThisCompleteTemplate);

            // Process all of the input portion / hierarchy
            process_inputs(nodeReader, ThisCompleteTemplate, exclude_divisions);

            // Process any constant sectoin
            process_constants(nodeReader, ThisCompleteTemplate);

            // Do any final processing
            ThisCompleteTemplate.Build_Final_Adjustment_And_Checks();
        }
示例#2
0
        /// <summary> Static method reads a template XML configuraton file and creates the <see cref="CompleteTemplate"/> object  </summary>
        /// <param name="XmlFile"> Filename of the template XML configuraiton file to read </param>
        /// <param name="ExcludeDivisions"> Flag indicates whether to include the structure map, if included in the template file </param>
        /// <returns> Fully built template object </returns>
        /// <remarks> This utilizes the <see cref="Template_XML_Reader"/> class to do the actual reading</remarks>
        public static CompleteTemplate Read_XML_Template(string XmlFile, bool ExcludeDivisions)
        {
            CompleteTemplate    returnValue = new CompleteTemplate();
            Template_XML_Reader reader      = new Template_XML_Reader();

            reader.Read_XML(XmlFile, returnValue, ExcludeDivisions);
            returnValue.Build_Final_Adjustment_And_Checks();
            return(returnValue);
        }
        /// <summary> Reads the CompleteTemplate XML configuration file specified into a CompleteTemplate object </summary>
        /// <param name="XML_File"> Filename of the CompleteTemplate XML configuraiton file to read  </param>
        /// <param name="ThisCompleteTemplate"> CompleteTemplate object to populate form the configuration file </param>
        /// <param name="exclude_divisions"> Flag indicates whether to include the structure map, if included in the CompleteTemplate file </param>
        public void Read_XML( string XML_File, CompleteTemplate ThisCompleteTemplate, bool exclude_divisions )
        {
            // Load this MXF File
            XmlDocument templateXml = new XmlDocument();
            templateXml.Load( XML_File );

            // create the node reader
            XmlNodeReader nodeReader = new XmlNodeReader( templateXml );

            // Read through all main input CompleteTemplate tag is found
            move_to_node( nodeReader, "input_template" );

            // Process all of the header information for this CompleteTemplate
            process_template_header( nodeReader, ThisCompleteTemplate );

            // Process all of the input portion / hierarchy
            process_inputs(nodeReader, ThisCompleteTemplate, exclude_divisions);

            // Process any constant sectoin
            process_constants( nodeReader, ThisCompleteTemplate );

            // Do any final processing
            ThisCompleteTemplate.Build_Final_Adjustment_And_Checks();
        }
 /// <summary> Static method reads a template XML configuraton file and creates the <see cref="CompleteTemplate"/> object  </summary>
 /// <param name="XmlFile"> Filename of the template XML configuraiton file to read </param>
 /// <param name="ExcludeDivisions"> Flag indicates whether to include the structure map, if included in the template file </param>
 /// <returns> Fully built template object </returns>
 /// <remarks> This utilizes the <see cref="Template_XML_Reader"/> class to do the actual reading</remarks>
 public static CompleteTemplate Read_XML_Template( string XmlFile, bool ExcludeDivisions )
 {
     CompleteTemplate returnValue = new CompleteTemplate();
     Template_XML_Reader reader = new Template_XML_Reader();
     reader.Read_XML( XmlFile, returnValue, ExcludeDivisions );
     returnValue.Build_Final_Adjustment_And_Checks();
     return returnValue;
 }
        /// <summary> Constructor for a new instance of the Edit_Item_Metadata_MySobekViewer class </summary>
        /// <param name="DefaultMetadata"> Default metadata object, if that is how this is being used </param>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Edit_Item_Metadata_MySobekViewer( SobekCM_Item DefaultMetadata, RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", String.Empty);

            popUpFormsHtml = String.Empty;
            delayed_popup = String.Empty;

            // If no user then that is an error
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
                RequestSpecificValues.Current_Mode.Aggregation = String.Empty;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // If the default metadata was provided, use that
            if (DefaultMetadata != null)
            {
                currentItem = DefaultMetadata;
            }
            else
            {
                // Ensure BibID and VID provided
                RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Validate provided bibid / vid");
                if ((String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID)) || (String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.VID)))
                {
                    RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "BibID or VID was not provided!");
                    RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error;
                    RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : BibID/VID missing in item metadata edit request";
                    return;
                }

                // Ensure the item is valid
                RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Validate bibid/vid exists");
                if (!UI_ApplicationCache_Gateway.Items.Contains_BibID_VID(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID))
                {
                    RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "BibID/VID indicated is not valid", Custom_Trace_Type_Enum.Error);
                    RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error;
                    RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : BibID/VID indicated is not valid";
                    return;
                }

                RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Try to pull this sobek complete item");
                currentItem = SobekEngineClient.Items.Get_Sobek_Item(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID, RequestSpecificValues.Current_User.UserID, RequestSpecificValues.Tracer);
                if (currentItem == null)
                {
                    RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Unable to build complete item");
                    RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error;
                    RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : Unable to build complete item";
                    return;
                }
            }

            // If the RequestSpecificValues.Current_User cannot edit this item, go back
            if (!RequestSpecificValues.Current_User.Can_Edit_This_Item(currentItem.BibID, currentItem.Bib_Info.SobekCM_Type_String, currentItem.Bib_Info.Source.Code, currentItem.Bib_Info.HoldingCode, currentItem.Behaviors.Aggregation_Code_List))
            {
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                HttpContext.Current.Response.Redirect(UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode));
            }

            // Is this a project
            isProject = currentItem.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.Project;

            string template_code = RequestSpecificValues.Current_User.Edit_Template_Code_Simple;

            if ((currentItem.Contains_Complex_Content) || (currentItem.Using_Complex_Template))
            {
                template_code = RequestSpecificValues.Current_User.Edit_Template_Code_Complex;
            }
            if (isProject)
            {
                template_code = "standard_project";
                completeTemplate = Template_MemoryMgmt_Utility.Retrieve_Template(template_code, RequestSpecificValues.Tracer);
                if (completeTemplate != null)
                {
                    RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Found project-specific template in cache");
                }
                else
                {
                    RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Reading project-specific template file");

                    // Look in the user-defined portion
                    string user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\user\\standard\\project.xml";
                    if (!File.Exists(user_template))
                        user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\default\\standard\\project.xml";

                    // Read this CompleteTemplate
                    Template_XML_Reader reader = new Template_XML_Reader();
                    completeTemplate = new CompleteTemplate();
                    reader.Read_XML(user_template, completeTemplate, true);

                    // Save this into the cache
                    Template_MemoryMgmt_Utility.Store_Template(template_code, completeTemplate, RequestSpecificValues.Tracer);
                }
            }
            else
            {
                completeTemplate = Template_MemoryMgmt_Utility.Retrieve_Template(template_code, RequestSpecificValues.Tracer);
                if (completeTemplate != null)
                {
                    RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Found template in cache");
                }
                else
                {
                    RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Reading template file");

                    // Look in the user-defined portion
                    string user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\user\\edit\\" + template_code + ".xml";
                    if (!File.Exists(user_template))
                        user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\default\\edit\\" + template_code + ".xml";

                    // Read this CompleteTemplate
                    Template_XML_Reader reader = new Template_XML_Reader();
                    completeTemplate = new CompleteTemplate();
                    reader.Read_XML(user_template, completeTemplate, true);
                    if ( completeTemplate != null ) completeTemplate.Build_Final_Adjustment_And_Checks();

                    // Save this into the cache
                    Template_MemoryMgmt_Utility.Store_Template(template_code, completeTemplate, RequestSpecificValues.Tracer);
                }
            }

            // Get the current page number, or default to 1
            page = 1;
            if (!String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.My_Sobek_SubMode))
            {
                if ((RequestSpecificValues.Current_Mode.My_Sobek_SubMode == "preview") || (RequestSpecificValues.Current_Mode.My_Sobek_SubMode == "marc") || (RequestSpecificValues.Current_Mode.My_Sobek_SubMode == "mets"))
                {
                    page = 0;
                }
                else
                {
                    page = 1;
                    bool isNumber = RequestSpecificValues.Current_Mode.My_Sobek_SubMode.All(Char.IsNumber);
                    if (isNumber)
                    {
                        if (isProject)
                            Double.TryParse(RequestSpecificValues.Current_Mode.My_Sobek_SubMode[0].ToString(), out page);
                        else
                            Double.TryParse(RequestSpecificValues.Current_Mode.My_Sobek_SubMode, out page);
                    }
                    else if ( isProject )
                    {
                        if ( Char.IsNumber(RequestSpecificValues.Current_Mode.My_Sobek_SubMode[0]))
                            Double.TryParse(RequestSpecificValues.Current_Mode.My_Sobek_SubMode[0].ToString(), out page);
                    }
                }
            }

            // Handle post backs
            if (RequestSpecificValues.Current_Mode.isPostBack)
            {
                // See if there was a hidden request
                string hidden_request = HttpContext.Current.Request.Form["new_element_requested"] ?? String.Empty;

                // If this was a cancel request do that
                if (hidden_request == "cancel")
                {
                    if (isProject)
                    {
                        CachedDataManager.Remove_Project(RequestSpecificValues.Current_User.UserID, currentItem.BibID, null);

                        RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Administrative;
                        RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Default_Metadata;
                        RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty;
                        UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                    }
                    else
                    {
                        CachedDataManager.Items.Remove_Digital_Resource_Object(RequestSpecificValues.Current_User.UserID, currentItem.BibID, currentItem.VID, null);

                        // Also clear the engine
                        SobekEngineClient.Items.Clear_Item_Cache(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer);

                        RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display;
                        UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                    }
                    return;
                }

                // Save these changes to bib
                completeTemplate.Save_To_Bib(currentItem, RequestSpecificValues.Current_User, ((int) page));

                // See if the RequestSpecificValues.Current_User asked for a new element of a complex form type
                delayed_popup = String.Empty;
                switch (hidden_request.Trim())
                {
                    case "name":
                        delayed_popup = "name";
                        currentItem.Bib_Info.Add_Named_Entity(String.Empty).Name_Type = Name_Info_Type_Enum.Personal;
                        break;

                    case "title":
                        delayed_popup = "title";
                        currentItem.Bib_Info.Add_Other_Title(String.Empty, Title_Type_Enum.Alternative);
                        break;

                    case "subject":
                        delayed_popup = "subject";
                        currentItem.Bib_Info.Add_Subject();
                        break;

                    case "spatial":
                        delayed_popup = "spatial";
                        currentItem.Bib_Info.Add_Hierarchical_Geographic_Subject();
                        break;

                    case "relateditem":
                        delayed_popup = "relateditem";
                        currentItem.Bib_Info.Add_Related_Item(new Related_Item_Info());
                        break;

                    case "save":
                        Complete_Item_Save();
                        break;

                    case "complicate":
                        currentItem.Using_Complex_Template = true;
                        HttpContext.Current.Response.Redirect( "?" + HttpContext.Current.Request.QueryString, false);
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        RequestSpecificValues.Current_Mode.Request_Completed = true;
                        return;

                    case "simplify":
                        currentItem.Using_Complex_Template = false;
                        HttpContext.Current.Response.Redirect( "?" + HttpContext.Current.Request.QueryString, false);
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        RequestSpecificValues.Current_Mode.Request_Completed = true;
                        return;
                }

                // Was this for a new page?
                if (hidden_request.IndexOf("newpage") == 0)
                {
                    string page_requested = hidden_request.Replace("newpage", "");
                    if (page_requested != RequestSpecificValues.Current_Mode.My_Sobek_SubMode)
                    {
                        // forward to requested page
                        RequestSpecificValues.Current_Mode.My_Sobek_SubMode = page_requested;
                        if (RequestSpecificValues.Current_Mode.My_Sobek_SubMode == "0")
                            RequestSpecificValues.Current_Mode.My_Sobek_SubMode = "preview";
                        if (isProject)
                            RequestSpecificValues.Current_Mode.My_Sobek_SubMode = page_requested + currentItem.BibID;

                        HttpContext.Current.Response.Redirect(UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "#CompleteTemplate", false);
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        RequestSpecificValues.Current_Mode.Request_Completed = true;
                    }
                }
            }
        }