added a min-depth function for a group of orgs, changed some variable names to be...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 4 Feb 2008 16:48:55 +0000 (16:48 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 4 Feb 2008 16:48:55 +0000 (16:48 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8607 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index 7344636..c37c9c7 100644 (file)
@@ -98,18 +98,18 @@ class OrgUtil(object):
         return root
 
     @staticmethod
-    def get_union_tree(org_list):
-        ''' Returns the smallest org tree which encompases all of the orgs in org_list '''
+    def get_union_tree(org_id_list):
+        ''' Returns the smallest org tree which encompases all of the orgs in org_id_list '''
 
         OrgUtil._verify_tree()
-        if len(org_list) == 0:
+        if len(org_id_list) == 0:
             return None
-        main_tree = OrgUtil.get_related_tree(OrgUtil.get_org_unit(org_list[0]))
+        main_tree = OrgUtil.get_related_tree(OrgUtil.get_org_unit(org_id_list[0]))
 
-        if len(org_list) == 1:
+        if len(org_id_list) == 1:
             return main_tree
 
-        for org in org_list[1:]:
+        for org in org_id_list[1:]:
             node = OrgUtil.get_related_tree(OrgUtil.get_org_unit(org))
             main_node = main_tree
 
@@ -139,6 +139,18 @@ class OrgUtil(object):
         return orglist
 
     @staticmethod
+    def get_min_depth(org_id_list):
+        ''' Returns the minimun depth (highest tree position) of all orgs in the list '''
+        depth = None
+        for org in org_id_list:
+            new_depth = OrgUtil.get_org_type(OrgUtil.get_org_unit(org)).depth()
+            if depth is None:
+                depth = new_depth
+            elif new_depth < depth:
+                depth = new_depth
+        return depth
+
+    @staticmethod
     def debug_tree(org_unit, indent=0):
         ''' Simple function to print the tree of orgs provided '''
         for i in range(indent):