Commit e3595307 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

optimise BusinessPath.isMovementRelatedWithMovement().


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34616 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6fab801b
...@@ -338,30 +338,21 @@ class BusinessPath(Path, Predicate): ...@@ -338,30 +338,21 @@ class BusinessPath(Path, Predicate):
return return_list return return_list
def isMovementRelatedWithMovement(self, movement_value_a, movement_value_b): def isMovementRelatedWithMovement(self, movement_value_a, movement_value_b):
"""Documentation in IBusinessPath""" """Checks if self is parent or children to movement_value
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): This logic is Business Process specific for Simulation Movements, as
if movement_value_a == movement_value_b: sequence of Business Process is not related appearance of Simulation Tree
# same is related
return True
# same level, cannot be related
return False
index = 0 movement_value_a, movement_value_b - movements to check relation between
for movement_a_part in movement_a_path_list: """
try: movement_a_path = '%s/' % movement_value_a.getRelativeUrl()
movement_b_part = movement_b_path_list[index] movement_b_path = '%s/' % movement_value_b.getRelativeUrl()
except IndexError:
# so far was good, they are related 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 True
if movement_a_part != movement_b_part:
return False return False
index += 1
# movement_a_path_list was shorter than movement_b_path_list and matched
# so they are related
return True
def _isDeliverySimulationMovementRelated(self, delivery, simulation_movement): def _isDeliverySimulationMovementRelated(self, delivery, simulation_movement):
"""Helper method, which checks if simulation_movement is BPM like related """Helper method, which checks if simulation_movement is BPM like related
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment