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