Commit 1a06287d authored by Łukasz Nowak's avatar Łukasz Nowak

- expose getRelatedSimulationMovementValueList, make it public and update business path interface

 - follow this change in classes using private version


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28064 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f5151430
......@@ -186,7 +186,7 @@ class BusinessPath(Path):
result = False
if self.isCompleted(explanation) or self.isFrozen(explanation):
return False # No need to build what was already built or frozen
for simulation_movement in self._getRelatedSimulationMovementValueList(
for simulation_movement in self.getRelatedSimulationMovementValueList(
explanation):
if simulation_movement.getDeliveryValue() is None:
result = True
......@@ -225,53 +225,41 @@ class BusinessPath(Path):
'explanation_uid': self._getExplanationUidList(explanation)
})
def _getRelatedSimulationMovementValueList(self, explanation): # XXX - What API ?
"""
Returns all Simulation Movements related to explanation
"""
simulation_movement_value_list = []
# first simulation movements related to explanation itself by its applied rule
for applied_rule in explanation.getCausalityRelatedValueList(
portal_type='Applied Rule'):
simulation_movement_value_list.extend([x.getObject() for x in
applied_rule.contentValues() if x.getCausalityValue() == self])
# now simulation movements which were used to build this delivery
for movement in explanation.getMovementList():
simulation_movement_value_list.extend([x.getObject() for x in
movement.getDeliveryRelatedValueList(
portal_type='Simulation Movement') if x \
.getCausalityValue() == self])
return simulation_movement_value_list
# IBusinessCompletable implementation
security.declareProtected(Permissions.AccessContentsInformation,
'isCompleted')
def isCompleted(self, explanation):
"""
Looks at all simulation related movements
and checks the simulation_state of the delivery
"""
acceptable_state_list = self.getCompletedStateList()
for movement in self._getRelatedSimulationMovementValueList(explanation):
for movement in self.getRelatedSimulationMovementValueList(explanation):
if movement.getSimulationState() not in acceptable_state_list:
return False
return True
security.declareProtected(Permissions.AccessContentsInformation,
'isPartiallyCompleted')
def isPartiallyCompleted(self, explanation):
"""
Looks at all simulation related movements
and checks the simulation_state of the delivery
"""
acceptable_state_list = self.getCompletedStateList()
for movement in self._getRelatedSimulationMovementValueList(explanation):
for movement in self.getRelatedSimulationMovementValueList(explanation):
if movement.getSimulationState() in acceptable_state_list:
return True
return False
security.declareProtected(Permissions.AccessContentsInformation,
'isFrozen')
def isFrozen(self, explanation):
"""
Looks at all simulation related movements
and checks if frozen
"""
movement_list = self._getRelatedSimulationMovementValueList(explanation)
movement_list = self.getRelatedSimulationMovementValueList(explanation)
if len(movement_list) == 0:
return False # Nothing to be considered as Frozen
for movement in movement_list:
......@@ -280,6 +268,26 @@ class BusinessPath(Path):
return True
# IBusinessPath implementation
security.declareProtected(Permissions.AccessContentsInformation,
'getRelatedSimulationMovementValueList')
def getRelatedSimulationMovementValueList(self, explanation):
"""
Returns all Simulation Movements related to explanation
"""
simulation_movement_value_list = []
# first simulation movements related to explanation itself by its applied rule
for applied_rule in explanation.getCausalityRelatedValueList(
portal_type='Applied Rule'):
simulation_movement_value_list.extend([x.getObject() for x in
applied_rule.contentValues() if x.getCausalityValue() == self])
# now simulation movements which were used to build this delivery
for movement in explanation.getMovementList():
simulation_movement_value_list.extend([x.getObject() for x in
movement.getDeliveryRelatedValueList(
portal_type='Simulation Movement') if x \
.getCausalityValue() == self])
return simulation_movement_value_list
def getExpectedStartDate(self, explanation, predecessor_date=None, *args, **kwargs):
"""
Returns the expected start date for this
......
......@@ -170,7 +170,7 @@ class BusinessState(XMLObject):
for path in self.getPredecessorRelatedValueList():
# XXX When no simulations related to path, what should path.isCompleted return?
# if True we don't have way to add remaining trade phases to new movement
if not (path._getRelatedSimulationMovementValueList(explanation) and
if not (path.getRelatedSimulationMovementValueList(explanation) and
path.isCompleted(explanation)):
remaining_trade_phase_list += path.getTradePhaseValueList()
......
......@@ -55,3 +55,11 @@ class IBusinessPath(IBusinessCompletable, IBusinessBuildable):
'predecessor_date' can be provided as predecessor date and
to override the date provided in the task
"""
def getRelatedSimulationMovementValueList(explanation):
"""Returns list of values of Simulation Movements related to self
and delivery
explanation - any document related to business path - which bootstraped
process or is related to build of one paths
"""
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