/// <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)
            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 thischildLevel4Index = -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 itemList )
            {
                // 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 (level4Text.Length > 0)
                {
                    if (level3Nodes.ContainsKey(level1Text + "_" + level2Text + "_" + level3Text))
                    {
                        level3Nodes[level1Text + "_" + level2Text + "_" + level3Text].Add_Child_Node(level4Text, itemLink, thischildLevel4Index);
                    }
                    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, thischildLevel4Index);
                    }
                }
                else
                {
                    if (level3Text.Length > 0)
                    {
                        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 (level2Text.Length > 0)
                        {
                            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 (level1Text.Length > 0)
                            {
                                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();
        }
Example #2
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();
        }