Commit b1f4f161 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Removed legacy code.

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@36068 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 098e4dcf
......@@ -401,197 +401,3 @@ class BusinessPath(Path, Predicate):
'business_path': self,
'explanation_cache': explanation_cache,
})
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX GARBAGE FROM HERE - all code will be removed
# _LEGACY_ prefix is used to make sure nobody will call methods
def _LEGACY_getExpectedStartDate(self, explanation, predecessor_date=None, *args, **kwargs):
"""
Returns the expected start date for this
path based on the explanation.
predecessor_date -- if provided, computes the date base on the
date value provided
"""
return self._getExpectedDate(explanation,
self._getRootExplanationExpectedStartDate,
self._getPredecessorExpectedStartDate,
self._getSuccessorExpectedStartDate,
predecessor_date=predecessor_date,
*args, **kwargs)
def _LEGACY__getRootExplanationExpectedStartDate(self, explanation, *args, **kwargs):
if self.getParentValue().isStartDateReferential():
return explanation.getStartDate()
else:
expected_date = self.getExpectedStopDate(explanation, *args, **kwargs)
if expected_date is not None:
return expected_date - self.getLeadTime()
def _LEGACY__getPredecessorExpectedStartDate(self, explanation, predecessor_date=None, *args, **kwargs):
if predecessor_date is None:
node = self.getPredecessorValue()
if node is not None:
predecessor_date = self.getParentValue().getExpectedStateCompletionDate(
explanation, node, *args, **kwargs)
if predecessor_date is not None:
return predecessor_date + self.getWaitTime()
def _LEGACY__getSuccessorExpectedStartDate(self, explanation, *args, **kwargs):
node = self.getSuccessorValue()
if node is not None:
expected_date = self.getParentValue().getExpectedStateBeginningDate(
explanation, node, *args, **kwargs)
if expected_date is not None:
return expected_date - self.getLeadTime()
def _LEGACY_getExpectedStopDate(self, explanation, predecessor_date=None, *args, **kwargs):
"""
Returns the expected stop date for this
path based on the explanation.
predecessor_date -- if provided, computes the date base on the
date value provided
"""
return self._getExpectedDate(explanation,
self._getRootExplanationExpectedStopDate,
self._getPredecessorExpectedStopDate,
self._getSuccessorExpectedStopDate,
predecessor_date=predecessor_date,
*args, **kwargs)
def _LEGACY__getRootExplanationExpectedStopDate(self, explanation, *args, **kwargs):
if self.getParentValue().isStopDateReferential():
return explanation.getStopDate()
else:
expected_date = self.getExpectedStartDate(explanation, *args, **kwargs)
if expected_date is not None:
return expected_date + self.getLeadTime()
def _LEGACY__getPredecessorExpectedStopDate(self, explanation, *args, **kwargs):
node = self.getPredecessorValue()
if node is not None:
expected_date = self.getParentValue().getExpectedStateCompletionDate(
explanation, node, *args, **kwargs)
if expected_date is not None:
return expected_date + self.getWaitTime() + self.getLeadTime()
def _LEGACY__getSuccessorExpectedStopDate(self, explanation, *args, **kwargs):
node = self.getSuccessorValue()
if node is not None:
return self.getParentValue().getExpectedStateBeginningDate(
explanation, node, *args, **kwargs)
def _LEGACY__getExpectedDate(self, explanation, root_explanation_method,
predecessor_method, successor_method,
visited=None, *args, **kwargs):
"""
Returns the expected stop date for this
path based on the explanation.
root_explanation_method -- used when the path is root explanation
predecessor_method --- used to get expected date of side of predecessor
successor_method --- used to get expected date of side of successor
visited -- only used to prevent infinite recursion internally
"""
if visited is None:
visited = []
# mark the path as visited
if self not in visited:
visited.append(self)
if self.isDeliverable():
return root_explanation_method(
explanation, visited=visited, *args, **kwargs)
predecessor_expected_date = predecessor_method(
explanation, visited=visited, *args, **kwargs)
successor_expected_date = successor_method(
explanation, visited=visited, *args, **kwargs)
if successor_expected_date is not None or \
predecessor_expected_date is not None:
# return minimum expected date but it is not None
if successor_expected_date is None:
return predecessor_expected_date
elif predecessor_expected_date is None:
return successor_expected_date
else:
if predecessor_expected_date < successor_expected_date:
return predecessor_expected_date
else:
return successor_expected_date
def _LEGACY__recurseGetValueList(self, document, portal_type):
"""Helper method to recurse documents as deep as possible and returns
list of document values matching portal_type"""
return_list = []
for subdocument in document.contentValues():
if subdocument.getPortalType() == portal_type:
return_list.append(subdocument)
return_list.extend(self._recurseGetValueList(subdocument, portal_type))
return return_list
def _LEGACY__isMovementRelatedWithMovement(self, movement_value_a, movement_value_b): # XXX-JPS not in API
"""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 _LEGACY__isDeliverySimulationMovementRelated(self, simulation_movement,
delivery_simulation_movement_list):
"""Helper method, which checks if simulation_movement is BPM like related
with delivery"""
for delivery_simulation_movement in delivery_simulation_movement_list:
if self.isMovementRelatedWithMovement(delivery_simulation_movement,
simulation_movement):
return True
return False
# IBusinessPath implementation
def _LEGACY__getRelatedSimulationMovementValueList(self, explanation): # XXX-JPS purpose ? NOT IN API
"""
Returns recursively all Simulation Movements indirectly related to explanation and self
As business sequence is not related to simulation tree need to built
full simulation trees per applied rule
"""
portal_catalog = self.getPortalObject().portal_catalog
root_applied_rule_list = []
if getattr(self, 'getMovementList', None) is None: # XXX-JPS temp hack
return []
delivery_simulation_movement_list = portal_catalog(
delivery_uid=[x.getUid() for x in explanation.getMovementList()]) # XXX-JPS it seems explanation is not understood as it should - only the root
for simulation_movement in delivery_simulation_movement_list:
applied_rule = simulation_movement.getRootAppliedRule().getPath()
if applied_rule not in root_applied_rule_list:
root_applied_rule_list.append(applied_rule)
simulation_movement_list = portal_catalog(
portal_type='Simulation Movement', causality_uid=self.getUid(),
path=['%s/%%' % x for x in root_applied_rule_list])
return [simulation_movement.getObject() for simulation_movement
in simulation_movement_list
# related with explanation
if self._isDeliverySimulationMovementRelated(
simulation_movement, delivery_simulation_movement_list)]
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