repaired logic error in union-tree builder
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 4 Feb 2008 15:39:01 +0000 (15:39 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 4 Feb 2008 15:39:01 +0000 (15:39 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8593 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/python/oils/org.py

index 431fc6d..0a4ad96 100644 (file)
@@ -105,11 +105,14 @@ class OrgUtil(object):
             main_node = main_tree
 
             while node.id() == main_node.id():
-                node = node.children()[0]
-                main_node = main_node.children()[0]
+                child = node.children()[0]
+                main_child_node = main_node.children()[0]
+                child.parent_ou(node)
+                main_child_node.parent_ou(main_node)
+                node = child
+                main_node = main_child_node
 
-            print main_node.id()
-            OrgUtil.get_org_unit(main_node.parent_ou()).children().append(node)
+            main_node.parent_ou().children().append(node)
 
         return main_tree
 
@@ -127,14 +130,14 @@ class OrgUtil(object):
         return orglist
 
     @staticmethod
-    def debug_org(org_unit, indent=0):
+    def debug_tree(org_unit, indent=0):
         ''' Simple function to print the tree of orgs provided '''
         import sys
         for i in range(indent):
-            sys.stdout.write('-')
-        print org_unit.shortname()
+            sys.stdout.write('_')
+        print '%s id=%s depth=%s' % (org_unit.shortname(), str(org_unit.id()), str(OrgUtil.get_org_type(org_unit).depth()))
         indent += 1
         for child in org_unit.children():
-            OrgUtil.debug_org(child, indent)
+            OrgUtil.debug_tree(child, indent)