Example #1
0
        /// <summary> Add new root node to this tree </summary>
        /// <param name="Name"> Display name for this new root node (title of the item group at the root node level) </param>
        /// <param name="Link"> Link for this new root node of the tree, or empty if no link </param>
        /// <param name="Value"> Value of this new root node (actually the BibID + '_' + VID) </param>
        /// <returns> Built sorted tree node object </returns>
        public Search_Result_Item_TreeNode Add_Root_Node(string Name, string Link, string Value)
        {
            Search_Result_Item_TreeNode newRootNode = new Search_Result_Item_TreeNode(Name, Link, Value);

            rootNodes.Add(newRootNode);
            return(newRootNode);
        }
Example #2
0
 private void recurse_and_set_values(Search_Result_Item_TreeNode parent_node, string parent_value)
 {
     foreach (Search_Result_Item_TreeNode childNode in parent_node.ChildNodes)
     {
         childNode.Value           = parent_value + "_" + childNode.Name;
         nodeHash[childNode.Value] = childNode;
         recurse_and_set_values(childNode, childNode.Value);
     }
 }
Example #3
0
        /// <summary> Builds the tree of items under this title, for multiple item titles </summary>
        public void Build_Item_Tree(string ResultsIndex)
        {
            // Create the tree
            itemTree = new Search_Result_Item_Tree();

            // Add a root node
            Search_Result_Item_TreeNode myRootNode = itemTree.Add_Root_Node("ROOT", String.Empty, BibID);

            // Is this a newspaper type (handles display slightly differently)
            string materialType = MaterialType ?? String.Empty;
            bool   newspaper    = materialType.ToUpper().IndexOf("NEWSPAPER") >= 0;

            // Placeholders for the day that we begin having four levels of serial hierarchy
            string    thischildLevel4Text    = String.Empty;
            const int THISCHILD_LEVEL4_INDEX = -1;

            // Add each seperate child row to the Items_Within_Title set
            Dictionary <string, Search_Result_Item_TreeNode> level1Nodes = new Dictionary <string, Search_Result_Item_TreeNode>();
            Dictionary <string, Search_Result_Item_TreeNode> level2Nodes = new Dictionary <string, Search_Result_Item_TreeNode>();
            Dictionary <string, Search_Result_Item_TreeNode> level3Nodes = new Dictionary <string, Search_Result_Item_TreeNode>();

            foreach (iSearch_Item_Result thisChild in Items)
            {
                // Determine the final link for this item
                string itemLink = BibID + "/" + thisChild.VID;

                string level1Text = thisChild.Level1_Text;
                string level2Text = thisChild.Level2_Text;
                string level3Text = thisChild.Level3_Text;
                string level4Text = thischildLevel4Text;

                // The logic to add all the nodes for this item.  This is large in an attempt to make it
                // frighteningly quick
                if (!String.IsNullOrEmpty(level4Text))
                {
                    if (level3Nodes.ContainsKey(level1Text + "_" + level2Text + "_" + level3Text))
                    {
                        level3Nodes[level1Text + "_" + level2Text + "_" + level3Text].Add_Child_Node(level4Text, itemLink, THISCHILD_LEVEL4_INDEX);
                    }
                    else
                    {
                        if (level2Nodes.ContainsKey(level1Text + "_" + level2Text))
                        {
                            level3Nodes[level1Text + "_" + level2Text + "_" + level3Text] = level2Nodes[level1Text + "_" + level2Text].Add_Child_Node(level3Text, String.Empty, thisChild.Level3_Index);
                        }
                        else
                        {
                            if (level1Nodes.ContainsKey(level1Text))
                            {
                                level2Nodes[level1Text + "_" + level2Text] = level1Nodes[level1Text].Add_Child_Node(level2Text, String.Empty, thisChild.Level2_Index);
                            }
                            else
                            {
                                level1Nodes[level1Text] = myRootNode.Add_Child_Node(level1Text, String.Empty, 0);
                                level2Nodes[level1Text + "_" + level2Text] = level1Nodes[level1Text].Add_Child_Node(level2Text, String.Empty, thisChild.Level2_Index);
                            }
                            level3Nodes[level1Text + "_" + level2Text + "_" + level3Text] = level2Nodes[level1Text + "_" + level2Text].Add_Child_Node(level3Text, String.Empty, thisChild.Level3_Index);
                        }
                        level3Nodes[level1Text + "_" + level2Text + "_" + level3Text].Add_Child_Node(level4Text, itemLink, THISCHILD_LEVEL4_INDEX);
                    }
                }
                else
                {
                    if (!String.IsNullOrEmpty(level3Text))
                    {
                        if ((newspaper) && (level3Text.IndexOf(level2Text) < 0) && (level3Text.IndexOf(level1Text) < 0))
                        {
                            string date = level2Text + " " + level3Text + ", " + level1Text;
                            if (level2Nodes.ContainsKey(level1Text + "_" + level2Text))
                            {
                                level3Nodes[level1Text + "_" + level2Text + "_" + level3Text] = level2Nodes[level1Text + "_" + level2Text].Add_Child_Node(date, itemLink, thisChild.Level3_Index);
                            }
                            else
                            {
                                if (level1Nodes.ContainsKey(level1Text))
                                {
                                    level2Nodes[level1Text + "_" + level2Text] = level1Nodes[level1Text].Add_Child_Node(level2Text, String.Empty, thisChild.Level2_Index);
                                }
                                else
                                {
                                    level1Nodes[level1Text] = myRootNode.Add_Child_Node(level1Text, String.Empty, thisChild.Level1_Index);
                                    level2Nodes[level1Text + "_" + level2Text] = level1Nodes[level1Text].Add_Child_Node(level2Text, String.Empty, thisChild.Level2_Index);
                                }
                                level3Nodes[level1Text + "_" + level2Text + "_" + level3Text] = level2Nodes[level1Text + "_" + level2Text].Add_Child_Node(date, itemLink, thisChild.Level3_Index);
                            }
                        }
                        else
                        {
                            if (level2Nodes.ContainsKey(level1Text + "_" + level2Text))
                            {
                                level3Nodes[level1Text + "_" + level2Text + "_" + level3Text] = level2Nodes[level1Text + "_" + level2Text].Add_Child_Node(level3Text, itemLink, thisChild.Level3_Index);
                            }
                            else
                            {
                                if (level1Nodes.ContainsKey(level1Text))
                                {
                                    level2Nodes[level1Text + "_" + level2Text] = level1Nodes[level1Text].Add_Child_Node(level2Text, String.Empty, thisChild.Level2_Index);
                                }
                                else
                                {
                                    level1Nodes[level1Text] = myRootNode.Add_Child_Node(level1Text, String.Empty, thisChild.Level1_Index);
                                    level2Nodes[level1Text + "_" + level2Text] = level1Nodes[level1Text].Add_Child_Node(level2Text, String.Empty, thisChild.Level2_Index);
                                }
                                level3Nodes[level1Text + "_" + level2Text + "_" + level3Text] = level2Nodes[level1Text + "_" + level2Text].Add_Child_Node(level3Text, itemLink, thisChild.Level3_Index);
                            }
                        }
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(level2Text))
                        {
                            if (level1Nodes.ContainsKey(level1Text))
                            {
                                level2Nodes[level1Text + "_" + level2Text] = level1Nodes[level1Text].Add_Child_Node(level2Text, itemLink, thisChild.Level2_Index);
                            }
                            else
                            {
                                level1Nodes[level1Text] = myRootNode.Add_Child_Node(level1Text, String.Empty, thisChild.Level1_Index);
                                level2Nodes[level1Text + "_" + level2Text] = level1Nodes[level1Text].Add_Child_Node(level2Text, itemLink, thisChild.Level2_Index);
                            }
                        }
                        else
                        {
                            if (!String.IsNullOrEmpty(level1Text))
                            {
                                level1Nodes[level1Text] = myRootNode.Add_Child_Node(level1Text, itemLink, thisChild.Level1_Index);
                            }
                            else
                            {
                                level1Nodes[thisChild.Title] = myRootNode.Add_Child_Node(thisChild.Title, itemLink, 0);
                            }
                        }
                    }
                }
            }

            // Set the hash values, for lookup by id
            itemTree.Set_Values();
        }