Commit 1058f2bc authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

* make getRelatedSimulationMovementValueList() faster by using catalog.

* fix a bug in getRelatedSimulationMovementValueList() that can return duplicated values.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34621 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 023363d9
...@@ -354,29 +354,16 @@ class BusinessPath(Path, Predicate): ...@@ -354,29 +354,16 @@ class BusinessPath(Path, Predicate):
return True return True
return False return False
def _isDeliverySimulationMovementRelated(self, delivery, simulation_movement): def _isDeliverySimulationMovementRelated(self, simulation_movement,
delivery_simulation_movement_list):
"""Helper method, which checks if simulation_movement is BPM like related """Helper method, which checks if simulation_movement is BPM like related
with delivery""" with delivery"""
for delivery_simulation_movement in self \ for delivery_simulation_movement in delivery_simulation_movement_list:
._getDeliverySimulationMovementList(delivery):
if self.isMovementRelatedWithMovement(delivery_simulation_movement, if self.isMovementRelatedWithMovement(delivery_simulation_movement,
simulation_movement): simulation_movement):
return True return True
return False return False
def _getDeliverySimulationMovementList(self, delivery):
"""Returns list of simulation movements related to delivery by applied rule
or delivery's movements"""
movement_list = []
for applied_rule in delivery.getCausalityRelatedValueList(
portal_type='Applied Rule'):
movement_list.extend(applied_rule.contentValues(
portal_type='Simulation Movement'))
for movement in delivery.getMovementList():
movement_list.extend(movement.getDeliveryRelatedValueList(
portal_type='Simulation Movement'))
return movement_list
# IBusinessPath implementation # IBusinessPath implementation
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getRelatedSimulationMovementValueList') 'getRelatedSimulationMovementValueList')
...@@ -387,34 +374,28 @@ class BusinessPath(Path, Predicate): ...@@ -387,34 +374,28 @@ class BusinessPath(Path, Predicate):
As business sequence is not related to simulation tree need to built As business sequence is not related to simulation tree need to built
full simulation trees per applied rule full simulation trees per applied rule
""" """
# FIXME: Needed better implementation, maybe use catalog? root_applied_rule_list = [explanation.getCausalityRelatedValueList(
simulation_movement_value_list = [] portal_type='Applied Rule')]
# first tree from root Applied Rules related to delivery itself delivery_simulation_movement_list = []
for applied_rule in explanation.getCausalityRelatedValueList(
portal_type='Applied Rule'):
simulation_movement_value_list.extend(self._recurseGetValueList(
applied_rule, 'Simulation Movement'))
# now tree from root Applied Rules related to movements used to build delivery
root_applied_rule_list = []
for movement in explanation.getMovementList(): for movement in explanation.getMovementList():
for simulation_movement in movement.getDeliveryRelatedValueList( simulation_movement_list = movement.getDeliveryRelatedValueList(
portal_type='Simulation Movement'): portal_type='Simulation Movement')
delivery_simulation_movement_list.extend(simulation_movement_list)
for simulation_movement in simulation_movement_list:
applied_rule = simulation_movement.getRootAppliedRule() applied_rule = simulation_movement.getRootAppliedRule()
if applied_rule not in root_applied_rule_list: if applied_rule not in root_applied_rule_list:
root_applied_rule_list.append( root_applied_rule_list.append(
simulation_movement.getRootAppliedRule()) simulation_movement.getRootAppliedRule())
for applied_rule in root_applied_rule_list: simulation_movement_list = self.getPortalObject().portal_catalog(
simulation_movement_value_list.extend(self._recurseGetValueList( portal_type='Simulation Movement', causality_uid=self.getUid(),
applied_rule, 'Simulation Movement')) path=['%s/%%' % x for x in root_applied_rule_list])
return [simulation_movement.getObject() for simulation_movement return [simulation_movement.getObject() for simulation_movement
in simulation_movement_value_list in simulation_movement_list
# this business path
if simulation_movement.getCausalityValue() == self
# related with explanation # related with explanation
and self._isDeliverySimulationMovementRelated( if self._isDeliverySimulationMovementRelated(
explanation, simulation_movement)] simulation_movement, delivery_simulation_movement_list)]
def getExpectedQuantity(self, explanation, *args, **kwargs): def getExpectedQuantity(self, explanation, *args, **kwargs):
""" """
......
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