//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private SPONMigrationUtil(String paramString1, String paramString2) throws Exception private SPONMigrationUtil(string paramString1, string paramString2) { initializeRateConverter(); this.sponLineItemList = SponLineTimeLoader.loadLineItems(paramString1, paramString2); System.Collections.IEnumerator iterator1 = this.sponLineItemList.GetEnumerator(); this.rootNode = new DefaultMutableTreeNode(); sbyte b; for (b = 0; iterator1.MoveNext(); b++) { SponLineItem sponLineItem = (SponLineItem)iterator1.Current; sponLineItem.Index = b; DefaultMutableTreeNode defaultMutableTreeNode = findParentForLineItem(sponLineItem, b); defaultMutableTreeNode.add(sponLineItem); } System.Collections.IEnumerator enumeration = this.rootNode.children(); LinkedList linkedList = new LinkedList(); while (enumeration.MoveNext()) { linkedList.AddLast(enumeration.Current); } Hashtable hashMap = new Hashtable(); foreach (SponLineItem sponLineItem1 in linkedList) { SponLineItem sponLineItem2 = null; LinkedList linkedList1 = null; System.Collections.IEnumerator enumeration1 = sponLineItem1.children(); Console.WriteLine("" + sponLineItem1); while (enumeration1.MoveNext()) { SponLineItem sponLineItem = (SponLineItem)enumeration1.Current; string str = sponLineItem.Code; if (str.IndexOf("/", StringComparison.Ordinal) != -1) { if (str.IndexOf("N", StringComparison.Ordinal) == -1) { str = StringHelper.SubstringSpecial(str, str.IndexOf("/", StringComparison.Ordinal) + 1, str.Length); } else { str = StringHelper.SubstringSpecial(str, str.IndexOf("/", StringComparison.Ordinal), str.Length); } } if (str.Length == 3) { sponLineItem2 = sponLineItem; linkedList1 = new LinkedList(); hashMap[sponLineItem2] = linkedList1; Console.WriteLine(" " + sponLineItem); continue; } if (linkedList1 == null) { Console.WriteLine("I was trying;" + sponLineItem); } linkedList1.AddLast(sponLineItem); } } foreach (SponLineItem sponLineItem in hashMap.Keys) { foreach (SponLineItem sponLineItem1 in (System.Collections.IList)hashMap[sponLineItem]) { sponLineItem1.removeFromParent(); } foreach (SponLineItem sponLineItem1 in (System.Collections.IList)hashMap[sponLineItem]) { sponLineItem.add(sponLineItem1); } } Session session = DatabaseDBUtil.currentSession(); Transaction transaction = session.beginTransaction(); try { Console.WriteLine("\n\n\n\n"); enumeration = this.rootNode.preorderEnumeration(); b = 0; while (enumeration.MoveNext()) { DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode)enumeration.Current; if (defaultMutableTreeNode.Root) { continue; } SponLineItem sponLineItem = (SponLineItem)defaultMutableTreeNode; string str1 = null; string str2 = sponLineItem.Code; if (++b % 'Ǵ' == '\x0000') { Console.WriteLine("PROCESSED: " + b + " lines"); transaction.commit(); DatabaseDBUtil.closeSession(); session = DatabaseDBUtil.currentSession(); transaction = session.beginTransaction(); } if (b % '✐' == '\x0000') { Thread.Sleep(2000L); } if (sponLineItem.Composite) { if (defaultMutableTreeNode.Path.length == 2) { str1 = str2; } else if (defaultMutableTreeNode.Path.length == 3) { str1 = str2.Substring(0, 1) + "." + str2.Substring(1, str2.Length - 1); } else if (defaultMutableTreeNode.Path.length == 4) { string str4 = ((SponLineItem)defaultMutableTreeNode.Parent).WbsCode; string str5 = StringHelper.SubstringSpecial(str2, str4.Length - 1 - "C".Length, str2.Length); str1 = str4 + "." + str5; } else { SponLineItem sponLineItem1 = (SponLineItem)defaultMutableTreeNode.Parent; string str = sponLineItem1.WbsCode; sbyte b2 = 1; System.Collections.IEnumerator enumeration1 = sponLineItem1.children(); while (enumeration1.MoveNext()) { SponLineItem sponLineItem2 = (SponLineItem)enumeration1.Current; if (sponLineItem2.Equals(sponLineItem)) { break; } b2++; } str1 = str + "." + b2; } } string str3 = ""; for (sbyte b1 = 1; b1 < defaultMutableTreeNode.Path.length; b1++) { str3 = str3 + " "; } if (sponLineItem.Composite) { if (sponLineItem.Depth == 1) { System.Collections.IEnumerator enumeration1 = sponLineItem.children(); while (enumeration1.MoveNext()) { SponLineItem sponLineItem1 = (SponLineItem)enumeration1.Current; sponLineItem1.MoreDescription.Add(sponLineItem.Description); if (!string.ReferenceEquals(sponLineItem.SecondDescription, null)) { sponLineItem1.MoreSecondDescription.Add(sponLineItem.SecondDescription); } } continue; } if (sponLineItem.ChildCount == 0) { bool @bool = sponLineItem.NoteItem; SponLineItem sponLineItem1 = (SponLineItem)defaultMutableTreeNode.Parent; System.Collections.IEnumerator enumeration1 = sponLineItem1.children(); bool bool1 = false; while (enumeration1.MoveNext()) { SponLineItem sponLineItem2 = (SponLineItem)enumeration1.Current; if (sponLineItem2.Equals(sponLineItem)) { bool1 = true; continue; } if (bool1 == true) { if (@bool) { sponLineItem2.Notes = sponLineItem.Description; setNotesToAllSubItems(sponLineItem2, sponLineItem2.Notes); continue; } if (sponLineItem2.NoteItem) { string str = sponLineItem2.Description; sponLineItem2.Description = sponLineItem.Description; sponLineItem2.Notes = str; setNotesToAllSubItems(sponLineItem2, sponLineItem2.Notes); sponLineItem.Notes = sponLineItem2.Description; } } } continue; } if (sponLineItem.NoteItem) { setNotesToAllSubItems(sponLineItem, sponLineItem.Description); } } if (!string.ReferenceEquals(str1, null)) { if (!str1.StartsWith("C", StringComparison.Ordinal)) { sponLineItem.WbsCode = "C" + str1; } else { sponLineItem.WbsCode = str1; } GroupCodeTable groupCodeTable = new GroupCodeTable(); groupCodeTable.GroupCode = sponLineItem.WbsCode; groupCodeTable.Title = sponLineItem.makeShortTitle(); groupCodeTable.Unit = ""; groupCodeTable.UnitFactor = BigDecimalMath.ONE; groupCodeTable.Description = sponLineItem.Description + "\n" + sponLineItem.Notes; groupCodeTable.Notes = sponLineItem.Code; groupCodeTable.EditorId = "spon"; session.save(groupCodeTable); continue; } processSponCostItem(sponLineItem, session); } transaction.commit(); } catch (Exception exception) { Console.WriteLine(exception.ToString()); Console.Write(exception.StackTrace); transaction.rollback(); } DatabaseDBUtil.closeSession(); Console.WriteLine("\n\n\n\nUNIT MAP TO CONVERT:"); System.Collections.IEnumerator iterator2 = this.unitMap.Values.GetEnumerator(); while (iterator2.MoveNext()) { Console.WriteLine(iterator2.Current); } }
public virtual TreeNode constructCodingTreeStructure(GroupCode[] codes, bool alwaysShowGroupPrefix) { if (codes == null) { codes = SortedCodes; } DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(); Dictionary <string, DefaultMutableTreeNode> level1NodesMap = new Dictionary <string, DefaultMutableTreeNode>(); Dictionary <string, DefaultMutableTreeNode> level2NodesMap = new Dictionary <string, DefaultMutableTreeNode>(); Dictionary <string, DefaultMutableTreeNode> level3NodesMap = new Dictionary <string, DefaultMutableTreeNode>(); Dictionary <string, DefaultMutableTreeNode> level4NodesMap = new Dictionary <string, DefaultMutableTreeNode>(); Dictionary <string, DefaultMutableTreeNode> level5NodesMap = new Dictionary <string, DefaultMutableTreeNode>(); Dictionary <string, DefaultMutableTreeNode> level6NodesMap = new Dictionary <string, DefaultMutableTreeNode>(); Dictionary <string, DefaultMutableTreeNode> level7NodesMap = new Dictionary <string, DefaultMutableTreeNode>(); Dictionary <string, DefaultMutableTreeNode> level8NodesMap = new Dictionary <string, DefaultMutableTreeNode>(); Dictionary <string, DefaultMutableTreeNode> level9NodesMap = new Dictionary <string, DefaultMutableTreeNode>(); int treeTableRowCount = 0; //System.out.println("--RECONSRUCTUING --"); List <object> level1List = new List <object>(); // to keep correct indices // We must sort the vector by groupCode string groupCodeStyle = CodingSystem; // boolean isAlphabetic = false; bool isRichardson = false; bool isNumeric5 = false; bool isNumeric6 = false; bool isDotted = false; // if ( groupCodeStyle.equals(UIProperties.ALPHABETIC_GC_STYLE)) { // isAlphabetic = true; // } if (groupCodeStyle.Equals(RICHARDSON_GC_STYLE)) { isRichardson = true; } if (groupCodeStyle.Equals(NUMERIC5_GC_STYLE)) { isNumeric5 = true; } if (groupCodeStyle.Equals(NUMERIC6_GC_STYLE)) { isNumeric6 = true; } if (groupCodeStyle.Equals(DOTTED_GC_STYLE)) { isDotted = true; } foreach (GroupCode code in codes) { DefaultMutableTreeNode currentNode = new WBSTreeNode(this, code, alwaysShowGroupPrefix); string groupCode = code.GroupCode; bool isLevel1 = false; bool isLevel2 = false; bool isLevel3 = false; bool isLevel4 = false; bool isLevel5 = false; bool isLevel6 = false; bool isLevel7 = false; bool isLevel8 = false; bool isLevel9 = false; string level1 = null; string level2 = null; string level3 = null; string level4 = null; string level5 = null; string level6 = null; string level7 = null; string level8 = null; string level9 = null; // we put less than four due to sync errors :S if ((groupCode.Length < 4) && !isDotted) { // get level 1 groupCode node: if (groupCode.Length >= 1) { isLevel1 = true; level1 = "" + groupCode[0]; level1NodesMap[level1] = currentNode; } if (groupCode.Length >= 2) { isLevel2 = true; level2 = "" + groupCode[0] + groupCode[1]; level2NodesMap[level2] = currentNode; } if (groupCode.Length >= 3) { isLevel3 = true; level3 = "" + groupCode[0] + groupCode[1] + groupCode[2]; level3NodesMap[level3] = currentNode; } if (groupCode.Length >= 4) { isLevel4 = true; level4 = "" + groupCode[0] + groupCode[1] + groupCode[2] + groupCode[3]; level4NodesMap[level4] = currentNode; } if (groupCode.Length >= 5) { isLevel5 = true; level5 = "" + groupCode[0] + groupCode[1] + groupCode[2] + groupCode[3] + groupCode[4]; level5NodesMap[level5] = currentNode; } if (groupCode.Length >= 6) { isLevel6 = true; level6 = "" + groupCode[0] + groupCode[1] + groupCode[2] + groupCode[3] + groupCode[4] + groupCode[5]; level6NodesMap[level6] = currentNode; } if (groupCode.Length >= 7) { isLevel7 = true; level7 = "" + groupCode[0] + groupCode[1] + groupCode[2] + groupCode[3] + groupCode[4] + groupCode[5] + groupCode[6]; level7NodesMap[level7] = currentNode; } if (groupCode.Length >= 8) { isLevel8 = true; level8 = "" + groupCode[0] + groupCode[1] + groupCode[2] + groupCode[3] + groupCode[4] + groupCode[5] + groupCode[6] + groupCode[7]; level8NodesMap[level8] = currentNode; } if (groupCode.Length >= 9) { isLevel9 = true; level9 = "" + groupCode[0] + groupCode[1] + groupCode[2] + groupCode[3] + groupCode[4] + groupCode[5] + groupCode[6] + groupCode[7] + groupCode[8]; level9NodesMap[level8] = currentNode; } } else if (isRichardson) { level1 = groupCode.Substring(0, 3) + "000000000"; level2 = groupCode.Substring(0, 6) + "000000"; level3 = groupCode; if (groupCode.EndsWith("000000000", StringComparison.Ordinal) && groupCode.Length == 12) { // only level1: isLevel1 = true; level1NodesMap[level1] = currentNode; } else if (groupCode.EndsWith("000000", StringComparison.Ordinal) && groupCode.Length == 12) { // only level 1,2 isLevel2 = true; level2NodesMap[level2] = currentNode; } else if (groupCode.Length == 12) { isLevel3 = true; level3NodesMap[level3] = currentNode; } } else if (isNumeric5) { level1 = groupCode.Substring(0, 2) + "000000"; level2 = groupCode.Substring(0, 4) + "0000"; level3 = groupCode.Substring(0, 6) + "00"; level4 = groupCode; if (groupCode.EndsWith("000000", StringComparison.Ordinal) && groupCode.Length == 8) { // only level1: isLevel1 = true; level1NodesMap[groupCode] = currentNode; } else if (groupCode.EndsWith("0000", StringComparison.Ordinal) && groupCode.Length == 8) { // only level 1,2 isLevel2 = true; level2NodesMap[groupCode] = currentNode; } else if (groupCode.EndsWith("00", StringComparison.Ordinal) && groupCode.Length == 8) { // only level 1,2 isLevel3 = true; level3NodesMap[groupCode] = currentNode; } else if (groupCode.Length == 8) { // only level 1,2 isLevel4 = true; level4NodesMap[groupCode] = currentNode; } } else if (isNumeric6) { level1 = groupCode.Substring(0, 2) + "00000000"; level2 = groupCode.Substring(0, 4) + "000000"; level3 = groupCode.Substring(0, 6) + "0000"; level4 = groupCode.Substring(0, 8) + "00"; level5 = groupCode; if (groupCode.EndsWith("00000000", StringComparison.Ordinal) && groupCode.Length == 10) { // only level1: isLevel1 = true; level1NodesMap[groupCode] = currentNode; } else if (groupCode.EndsWith("000000", StringComparison.Ordinal) && groupCode.Length == 10) { // only level 1,2 isLevel2 = true; level2NodesMap[groupCode] = currentNode; } else if (groupCode.EndsWith("0000", StringComparison.Ordinal) && groupCode.Length == 10) { // only level 1,2 isLevel3 = true; level3NodesMap[groupCode] = currentNode; } else if (groupCode.EndsWith("00", StringComparison.Ordinal) && groupCode.Length == 10) { // only level 1,2 isLevel4 = true; level4NodesMap[groupCode] = currentNode; } else if (groupCode.Length == 10) { // only level 1,2 isLevel5 = true; level5NodesMap[groupCode] = currentNode; } } else if (isDotted && groupCode.Length > 0) { string[] gcs = groupCode.Split("\\.", 9); if (gcs.Length == 1) { isLevel1 = true; level1 = groupCode; level1NodesMap[groupCode] = currentNode; } else if (gcs.Length == 2) { isLevel2 = true; level1 = gcs[0]; level2 = groupCode; level2NodesMap[groupCode] = currentNode; } else if (gcs.Length == 3) { isLevel3 = true; level1 = gcs[0]; level2 = level1 + DOT + gcs[1]; level3 = groupCode; level3NodesMap[groupCode] = currentNode; } else if (gcs.Length == 4) { isLevel4 = true; level1 = gcs[0]; level2 = level1 + DOT + gcs[1]; level3 = level2 + DOT + gcs[2]; level4 = groupCode; level4NodesMap[groupCode] = currentNode; } else if (gcs.Length == 5) { isLevel5 = true; level1 = gcs[0]; level2 = level1 + DOT + gcs[1]; level3 = level2 + DOT + gcs[2]; level4 = level3 + DOT + gcs[3]; level5 = groupCode; level5NodesMap[groupCode] = currentNode; } else if (gcs.Length == 6) { isLevel6 = true; level1 = gcs[0]; level2 = level1 + DOT + gcs[1]; level3 = level2 + DOT + gcs[2]; level4 = level3 + DOT + gcs[3]; level5 = level4 + DOT + gcs[4]; level6 = groupCode; level6NodesMap[groupCode] = currentNode; } else if (gcs.Length == 7) { isLevel7 = true; level1 = gcs[0]; level2 = level1 + DOT + gcs[1]; level3 = level2 + DOT + gcs[2]; level4 = level3 + DOT + gcs[3]; level5 = level4 + DOT + gcs[4]; level6 = level5 + DOT + gcs[5]; level7 = groupCode; level7NodesMap[groupCode] = currentNode; } else if (gcs.Length == 8) { isLevel8 = true; level1 = gcs[0]; level2 = level1 + DOT + gcs[1]; level3 = level2 + DOT + gcs[2]; level4 = level3 + DOT + gcs[3]; level5 = level4 + DOT + gcs[4]; level6 = level5 + DOT + gcs[5]; level7 = level6 + DOT + gcs[6]; level8 = groupCode; level8NodesMap[groupCode] = currentNode; } else if (gcs.Length >= 9) { isLevel9 = true; level1 = gcs[0]; level2 = level1 + DOT + gcs[1]; level3 = level2 + DOT + gcs[2]; level4 = level3 + DOT + gcs[3]; level5 = level4 + DOT + gcs[4]; level6 = level5 + DOT + gcs[5]; level7 = level6 + DOT + gcs[6]; level8 = level7 + DOT + gcs[7]; level9 = groupCode; level9NodesMap[groupCode] = currentNode; } } else { level1 = groupCode.Substring(0, 2) + "00"; level2 = groupCode.Substring(0, 3) + "0"; level3 = groupCode; if (groupCode.EndsWith("00", StringComparison.Ordinal)) { // only level1: isLevel1 = true; level1NodesMap[groupCode] = currentNode; } else if (groupCode.EndsWith("0", StringComparison.Ordinal)) { // only level 1,2 isLevel2 = true; level2NodesMap[groupCode] = currentNode; } else { isLevel3 = true; level3NodesMap[groupCode] = currentNode; } } if (isLevel9) { DefaultMutableTreeNode parentNode = level8NodesMap[level8]; if (parentNode == null) { Console.WriteLine("CODE SYSTEM ERROR LEVEL: " + level8 + " NOT FOUND!"); } else { parentNode.insert(currentNode, parentNode.ChildCount); } } else if (isLevel8) { DefaultMutableTreeNode parentNode = level7NodesMap[level7]; if (parentNode == null) { Console.WriteLine("CODE SYSTEM ERROR LEVEL: " + level7 + " NOT FOUND!"); } else { parentNode.insert(currentNode, parentNode.ChildCount); } } else if (isLevel7) { DefaultMutableTreeNode parentNode = level6NodesMap[level6]; if (parentNode == null) { Console.WriteLine("CODE SYSTEM ERROR LEVEL: " + level6 + " NOT FOUND!"); } else { parentNode.insert(currentNode, parentNode.ChildCount); } } else if (isLevel6) { DefaultMutableTreeNode parentNode = level5NodesMap[level5]; if (parentNode == null) { Console.WriteLine("CODE SYSTEM ERROR LEVEL: " + level5 + " NOT FOUND!"); } else { parentNode.insert(currentNode, parentNode.ChildCount); } } else if (isLevel5) { DefaultMutableTreeNode parentNode = level4NodesMap[level4]; if (parentNode == null) { Console.WriteLine("CODE SYSTEM ERROR LEVEL: " + level4 + " NOT FOUND!"); } else { parentNode.add(currentNode); } } else if (isLevel4) { DefaultMutableTreeNode parentNode = level3NodesMap[level3]; if (parentNode == null) { Console.WriteLine("CODE SYSTEM ERROR LEVEL: " + level3 + " NOT FOUND!"); } else { parentNode.add(currentNode); } } else if (isLevel3) { DefaultMutableTreeNode parentNode = level2NodesMap[level2]; if (parentNode == null) { Console.WriteLine("CODE SYSTEM ERROR LEVEL: " + level2 + " NOT FOUND!"); } else { parentNode.add(currentNode); } } else if (isLevel2) { DefaultMutableTreeNode parentNode = level1NodesMap[level1]; if (parentNode == null) { Console.WriteLine("CODE SYSTEM ERROR LEVEL: " + level1 + " NOT FOUND!"); } else { parentNode.add(currentNode); } } else if (isLevel1) { DefaultMutableTreeNode parentNode = rootNode; parentNode.add(currentNode); } } return(rootNode); }