Commit 08559955 authored by Yusuke Muraoka's avatar Yusuke Muraoka

remove exception for algorithm

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27209 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent feb60907
...@@ -33,7 +33,6 @@ from AccessControl import ClassSecurityInfo ...@@ -33,7 +33,6 @@ from AccessControl import ClassSecurityInfo
from Products.CMFCore.PortalFolder import ContentFilter from Products.CMFCore.PortalFolder import ContentFilter
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.Path import Path from Products.ERP5.Document.Path import Path
from Products.ERP5.Document.BusinessProcess import BackTrack
import zope.interface import zope.interface
...@@ -265,8 +264,9 @@ class BusinessPath(Path): ...@@ -265,8 +264,9 @@ class BusinessPath(Path):
if self.getParentValue().isStartDateReferential(): if self.getParentValue().isStartDateReferential():
return explanation.getStartDate() return explanation.getStartDate()
else: else:
return self.getExpectedStopDate(explanation, *args, **kwargs)\ expected_date = self.getExpectedStopDate(explanation, *args, **kwargs)
- self.getLeadTime() if expected_date is not None:
return expected_date - self.getLeadTime()
def _getPredecessorExpectedStartDate(self, explanation, predecessor_date=None, *args, **kwargs): def _getPredecessorExpectedStartDate(self, explanation, predecessor_date=None, *args, **kwargs):
if predecessor_date is None: if predecessor_date is None:
...@@ -279,8 +279,9 @@ class BusinessPath(Path): ...@@ -279,8 +279,9 @@ class BusinessPath(Path):
def _getSuccessorExpectedStartDate(self, explanation, *args, **kwargs): def _getSuccessorExpectedStartDate(self, explanation, *args, **kwargs):
node = self.getSuccessorValue() node = self.getSuccessorValue()
if node is not None: if node is not None:
return node.getExpectedBeginningDate(explanation, *args, **kwargs)\ expected_date = node.getExpectedBeginningDate(explanation, *args, **kwargs)
- self.getLeadTime() if expected_date is not None:
return expected_date - self.getLeadTime()
def getExpectedStopDate(self, explanation, predecessor_date=None, *args, **kwargs): def getExpectedStopDate(self, explanation, predecessor_date=None, *args, **kwargs):
""" """
...@@ -301,14 +302,16 @@ class BusinessPath(Path): ...@@ -301,14 +302,16 @@ class BusinessPath(Path):
if self.getParentValue().isStopDateReferential(): if self.getParentValue().isStopDateReferential():
return explanation.getStopDate() return explanation.getStopDate()
else: else:
return self.getExpectedStartDate(explanation, *args, **kwargs)\ expected_date = self.getExpectedStartDate(explanation, *args, **kwargs)
+ self.getLeadTime() if expected_date is not None:
return expected_date + self.getLeadTime()
def _getPredecessorExpectedStopDate(self, explanation, *args, **kwargs): def _getPredecessorExpectedStopDate(self, explanation, *args, **kwargs):
node = self.getPredecessorValue() node = self.getPredecessorValue()
if node is not None: if node is not None:
return node.getExpectedCompletionDate(explanation, *args, **kwargs)\ expected_date = node.getExpectedCompletionDate(explanation, *args, **kwargs)
+ self.getWaitTime() + self.getLeadTime() if expected_date is not None:
return expected_date + self.getWaitTime() + self.getLeadTime()
def _getSuccessorExpectedStopDate(self, explanation, *args, **kwargs): def _getSuccessorExpectedStopDate(self, explanation, *args, **kwargs):
node = self.getSuccessorValue() node = self.getSuccessorValue()
...@@ -338,19 +341,11 @@ class BusinessPath(Path): ...@@ -338,19 +341,11 @@ class BusinessPath(Path):
return root_explanation_method( return root_explanation_method(
explanation, visited=visited, *args, **kwargs) explanation, visited=visited, *args, **kwargs)
predecessor_expected_date = None predecessor_expected_date = predecessor_method(
try: explanation, visited=visited, *args, **kwargs)
predecessor_expected_date = predecessor_method(
explanation, visited=visited, *args, **kwargs)
except BackTrack:
pass
successor_expected_date = None successor_expected_date = successor_method(
try: explanation, visited=visited, *args, **kwargs)
successor_expected_date = successor_method(
explanation, visited=visited, *args, **kwargs)
except BackTrack:
pass
if successor_expected_date is not None or \ if successor_expected_date is not None or \
predecessor_expected_date is not None: predecessor_expected_date is not None:
......
...@@ -34,12 +34,6 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface ...@@ -34,12 +34,6 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.Document.Path import Path from Products.ERP5.Document.Path import Path
class BackTrack(Exception):
# XXX this defined here until refactor
"""
This is a utility Exception for tree back tracking.
"""
class BusinessProcess(Path, XMLObject): class BusinessProcess(Path, XMLObject):
""" """
The BusinessProcess class is a container class which is used The BusinessProcess class is a container class which is used
......
...@@ -32,7 +32,6 @@ from AccessControl import ClassSecurityInfo ...@@ -32,7 +32,6 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.Document.BusinessProcess import BackTrack
class BusinessState(XMLObject): class BusinessState(XMLObject):
""" """
...@@ -89,11 +88,13 @@ class BusinessState(XMLObject): ...@@ -89,11 +88,13 @@ class BusinessState(XMLObject):
# Should be re-calculated? # Should be re-calculated?
if 'predecessor_date' in kwargs: if 'predecessor_date' in kwargs:
del kwargs['predecessor_date'] del kwargs['predecessor_date']
return min(self._getExpectedDateList(explanation, date_list = self._getExpectedDateList(explanation,
self.getSuccessorRelatedValueList(), self.getSuccessorRelatedValueList(),
self._getExpectedCompletionDate, self._getExpectedCompletionDate,
*args, *args,
**kwargs)) **kwargs)
if len(date_list) > 0:
return min(date_list)
def _getExpectedCompletionDate(self, path, *args, **kwargs): def _getExpectedCompletionDate(self, path, *args, **kwargs):
return path.getExpectedStopDate(*args, **kwargs) return path.getExpectedStopDate(*args, **kwargs)
...@@ -108,11 +109,13 @@ class BusinessState(XMLObject): ...@@ -108,11 +109,13 @@ class BusinessState(XMLObject):
# Should be re-calculated? # Should be re-calculated?
if 'predecessor_date' in kwargs: if 'predecessor_date' in kwargs:
del kwargs['predecessor_date'] del kwargs['predecessor_date']
return min(self._getExpectedDateList(explanation, date_list = self._getExpectedDateList(explanation,
self.getPredecessorRelatedValueList(), self.getPredecessorRelatedValueList(),
self._getExpectedBeginningDate, self._getExpectedBeginningDate,
*args, *args,
**kwargs)) **kwargs)
if len(date_list) > 0:
return min(date_list)
def _getExpectedBeginningDate(self, path, *args, **kwargs): def _getExpectedBeginningDate(self, path, *args, **kwargs):
expected_date = path.getExpectedStartDate(*args, **kwargs) expected_date = path.getExpectedStartDate(*args, **kwargs)
...@@ -141,11 +144,7 @@ class BusinessState(XMLObject): ...@@ -141,11 +144,7 @@ class BusinessState(XMLObject):
if expected_date is not None: if expected_date is not None:
expected_date_list.append(expected_date) expected_date_list.append(expected_date)
# if visiting leaf of tree return expected_date_list
if len(expected_date_list) == 0:
raise BackTrack
else:
return expected_date_list
def getExpectedCompletionDuration(self, explanation): def getExpectedCompletionDuration(self, explanation):
""" """
......
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