[Erp5-report] r34616 kazuhiko - /erp5/trunk/products/ERP5/Document/BusinessPath.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Apr 16 13:26:30 CEST 2010


Author: kazuhiko
Date: Fri Apr 16 13:26:30 2010
New Revision: 34616

URL: http://svn.erp5.org?rev=34616&view=rev
Log:
optimise BusinessPath.isMovementRelatedWithMovement().

Modified:
    erp5/trunk/products/ERP5/Document/BusinessPath.py

Modified: erp5/trunk/products/ERP5/Document/BusinessPath.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessPath.py?rev=34616&r1=34615&r2=34616&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessPath.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessPath.py [utf8] Fri Apr 16 13:26:30 2010
@@ -338,30 +338,21 @@
     return return_list
 
   def isMovementRelatedWithMovement(self, movement_value_a, movement_value_b):
-    """Documentation in IBusinessPath"""
-    movement_a_path_list = movement_value_a.getRelativeUrl().split('/')
-    movement_b_path_list = movement_value_b.getRelativeUrl().split('/')
-
-    if len(movement_a_path_list) == len(movement_b_path_list):
-      if movement_value_a == movement_value_b:
-        # same is related
-        return True
-      # same level, cannot be related
-      return False
-
-    index = 0
-    for movement_a_part in movement_a_path_list:
-      try:
-        movement_b_part = movement_b_path_list[index]
-      except IndexError:
-        # so far was good, they are related
-        return True
-      if movement_a_part != movement_b_part:
-        return False
-      index += 1
-    # movement_a_path_list was shorter than movement_b_path_list and matched
-    # so they are related
-    return True
+    """Checks if self is parent or children to movement_value
+
+    This logic is Business Process specific for Simulation Movements, as
+    sequence of Business Process is not related appearance of Simulation Tree
+
+    movement_value_a, movement_value_b - movements to check relation between
+    """
+    movement_a_path = '%s/' % movement_value_a.getRelativeUrl()
+    movement_b_path = '%s/' % movement_value_b.getRelativeUrl()
+
+    if movement_a_path == movement_b_path or \
+       movement_a_path.startswith(movement_b_path) or \
+       movement_b_path.startswith(movement_a_path):
+      return True
+    return False
 
   def _isDeliverySimulationMovementRelated(self, delivery, simulation_movement):
     """Helper method, which checks if simulation_movement is BPM like related




More information about the Erp5-report mailing list