Commit 945c158f authored by Jean-Paul Smets's avatar Jean-Paul Smets

Updated interface definition for business process related classes

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27509 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e4c05ab8
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
...@@ -39,39 +40,27 @@ import zope.interface ...@@ -39,39 +40,27 @@ import zope.interface
class BusinessPath(Path): class BusinessPath(Path):
""" """
The BusinessPath class embeds all information related to The BusinessPath class embeds all information related to
lead times and parties involved at a give phase of a business lead times and parties involved at a given phase of a business
process. process.
BusinessPath are also used as helper to build buildable movements. BusinessPath are also used as helper to build deliveries from
Here is the typical code of an alarm: buildable movements. Here is the typical code of an alarm
in charge of the building process.
Approach 1: explanation per explanation
builder = portal_deliveries.default_order_builder
for path in builder.getSpecialiseRelatedValueList() # or wharever category
for explanation in portal_catalog(buildable=1, portal_type='Order'):
path.build(explanation)
Pros: easy explanation based approach
Cons: buildable column added in delivery table
reexpand of a finished order might generate remaining buildable
Approach 2: isBuildable is indexed for SimulationMovements The idea is to invoke isBuildable() on the collected simulation
isBuildable() method is added to SimulationMovement movements (which are orphan) during build "after select" process
Pros: global select is possible
Cons: reindex of simulation is required
slow indexing
Approach 3: isBuildable is invoked during build "after select" process
builder = portal_deliveries.default_order_builder builder = portal_deliveries.default_order_builder
for path in builder.getSpecialiseRelatedValueList() # or wharever category for path in builder.getSpecialiseRelatedValueList() # or wharever category
builder.build(causality_uid=path.getUid(),) # Select movemenents builder.build(causality_uid=path.getUid(),) # Select movemenents
Pros: global select is possible Pros: global select is possible by not providing a causality_uid
Cons: global select retrieves long lists Cons: global select retrieves long lists of orphan movements which
slow build are not yet buildable
the build process could be rather slow or require activities
Method 3 is best TODO:
- finish build process implementation
""" """
meta_type = 'ERP5 Business Path' meta_type = 'ERP5 Business Path'
portal_type = 'Business Path' portal_type = 'Business Path'
...@@ -95,16 +84,20 @@ class BusinessPath(Path): ...@@ -95,16 +84,20 @@ class BusinessPath(Path):
# Declarative interfaces # Declarative interfaces
zope.interface.implements(interfaces.ICategoryAccessProvider, zope.interface.implements(interfaces.ICategoryAccessProvider,
interfaces.IArrow) interfaces.IArrowBase,
interfaces.IBusinessPath,
interfaces.IBusinessBuildable,
interfaces.IBusinessCompletable
)
# IBusinessPath Interface # IArrowBase implementation
security.declareProtected(Permissions.AccessContentsInformation, 'getSourceBaseCategoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getSourceBaseCategoryList')
def getSourceBaseCategoryList(self): def getSourceBaseCategoryList(self):
""" """
Returns all categories which are used to define the source Returns all categories which are used to define the source
of this Arrow of this Arrow
""" """
# Naive implementation - we must use category groups instead # Naive implementation - we must use category groups instead - XXX
return ('source', 'source_section', 'source_payment', 'source_project', ) return ('source', 'source_section', 'source_payment', 'source_project', )
security.declareProtected(Permissions.AccessContentsInformation, 'getDestinationBaseCategoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getDestinationBaseCategoryList')
...@@ -113,7 +106,7 @@ class BusinessPath(Path): ...@@ -113,7 +106,7 @@ class BusinessPath(Path):
Returns all categories which are used to define the destination Returns all categories which are used to define the destination
of this Arrow of this Arrow
""" """
# Naive implementation - we must use category groups instead # Naive implementation - we must use category groups instead - XXX
return ('destination', 'destination_section', 'destination_payment', 'destination_project', ) return ('destination', 'destination_section', 'destination_payment', 'destination_project', )
# ICategoryAccessProvider overriden methods # ICategoryAccessProvider overriden methods
...@@ -172,7 +165,7 @@ class BusinessPath(Path): ...@@ -172,7 +165,7 @@ class BusinessPath(Path):
return method(context) return method(context)
return [] return []
# Core API # IBusinessBuildable implementation
def isBuildable(self, explanation): def isBuildable(self, explanation):
""" """
""" """
...@@ -192,13 +185,24 @@ class BusinessPath(Path): ...@@ -192,13 +185,24 @@ class BusinessPath(Path):
Not sure if this will exist some day XXX Not sure if this will exist some day XXX
""" """
def _getRelatedSimulationMovementList(self, explanation): def build(self, explanation):
"""
Build
"""
builder_list = self.getBuilderList() # Missing method
for builder in builder_list:
builder.build(causality_uid=self.getUid()) # This is one way of doing
builder.build(movement_relative_url_list=
self._getRelatedSimulationMovementList(explanation)) # Another way
def _getRelatedSimulationMovementList(self, explanation): # XXX - What API ?
""" """
""" """
return self.getCausalityRelatedValueList(portal_type='Simulation Movement', return self.getCausalityRelatedValueList(portal_type='Simulation Movement',
explanation_uid=explanation.getUid()) explanation_uid=explanation.getUid())
# IBusinessCompletable implementation
def isCompleted(self, explanation): def isCompleted(self, explanation):
""" """
Looks at all simulation related movements Looks at all simulation related movements
...@@ -234,17 +238,7 @@ class BusinessPath(Path): ...@@ -234,17 +238,7 @@ class BusinessPath(Path):
return False return False
return True return True
def build(self, explanation): # IBusinessPath implementation
"""
Build
"""
builder_list = self.getBuilderList() # Missing method
for builder in builder_list:
builder.build(causality_uid=self.getUid()) # This is one way of doing
builder.build(movement_relative_url_list=
self._getRelatedSimulationMovementList(explanation)) # Another way
# Date calculation
def getExpectedStartDate(self, explanation, predecessor_date=None, *args, **kwargs): def getExpectedStartDate(self, explanation, predecessor_date=None, *args, **kwargs):
""" """
Returns the expected start date for this Returns the expected start date for this
......
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
...@@ -34,11 +35,16 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces ...@@ -34,11 +35,16 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces
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
import zope.interface
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
to describe business processes in the area of trade, payroll to describe business processes in the area of trade, payroll
and production. and production.
TODO:
- finish interface implementation
""" """
meta_type = 'ERP5 Business Process' meta_type = 'ERP5 Business Process'
portal_type = 'Business Process' portal_type = 'Business Process'
...@@ -59,6 +65,10 @@ class BusinessProcess(Path, XMLObject): ...@@ -59,6 +65,10 @@ class BusinessProcess(Path, XMLObject):
, PropertySheet.BusinessProcess , PropertySheet.BusinessProcess
) )
# Declarative interfaces
zope.interface.implements(interfaces.IBusinessProcess,
interfaces.IArrowBase)
# Access to path and states of the business process # Access to path and states of the business process
security.declareProtected(Permissions.AccessContentsInformation, 'getPathValueList') security.declareProtected(Permissions.AccessContentsInformation, 'getPathValueList')
def getPathValueList(self, trade_phase, context=None, **kw): def getPathValueList(self, trade_phase, context=None, **kw):
...@@ -180,10 +190,10 @@ class BusinessProcess(Path, XMLObject): ...@@ -180,10 +190,10 @@ class BusinessProcess(Path, XMLObject):
for path in self.getBuildablePathValueList(explanation): for path in self.getBuildablePathValueList(explanation):
path.build(explanation) path.build(explanation)
def isStartDateReferential(self): def isStartDateReferential(self): # XXX - not in interface
return self.getReferentialDate() == 'start_date' return self.getReferentialDate() == 'start_date'
def isStopDateReferential(self): def isStopDateReferential(self): # XXX - not in interface
return self.getReferentialDate() == 'stop_date' return self.getReferentialDate() == 'stop_date'
def getTradePhaseList(self): def getTradePhaseList(self):
......
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
...@@ -33,11 +34,13 @@ from AccessControl import ClassSecurityInfo ...@@ -33,11 +34,13 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
import zope.interface
class BusinessState(XMLObject): class BusinessState(XMLObject):
""" """
The BusinessProcess class is a container class which is used The BusinessState class defines the various states in
to describe business processes in the area of trade, payroll a Business Process. It defines the synchronisation milestones
and production. between movements related to the trade phases of business.
""" """
meta_type = 'ERP5 Business State' meta_type = 'ERP5 Business State'
portal_type = 'Business State' portal_type = 'Business State'
...@@ -55,7 +58,11 @@ class BusinessState(XMLObject): ...@@ -55,7 +58,11 @@ class BusinessState(XMLObject):
, PropertySheet.Comment , PropertySheet.Comment
) )
# Core API # Declarative interfaces
zope.interface.implements(interfaces.IBusinessState
)
# IBusinessCompletable implementation
def isCompleted(self, explanation): def isCompleted(self, explanation):
""" """
If all path which reach this state are completed If all path which reach this state are completed
...@@ -77,7 +84,7 @@ class BusinessState(XMLObject): ...@@ -77,7 +84,7 @@ class BusinessState(XMLObject):
return False return False
return True return True
# Duration calculation # IBusinessCompletable - duration calculation
def getExpectedCompletionDate(self, explanation, *args, **kwargs): def getExpectedCompletionDate(self, explanation, *args, **kwargs):
""" """
Returns the expected completion date for this Returns the expected completion date for this
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from zope.interface import Interface
class IArrowBase(Interface):
"""Arrow Base interface specification
Defines methods to get the list of base categories
which define the source and destination of an Arrow
"""
def getSourceArrowBaseCategoryList():
"""Returns all categories which are used to define the source
of this Arrow
"""
def getDestinationArrowBaseCategoryList():
"""Returns all categories which are used to define the destination
of this Arrow
"""
\ No newline at end of file
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
...@@ -30,6 +31,10 @@ from zope.interface import Interface ...@@ -30,6 +31,10 @@ from zope.interface import Interface
class IBusinessBuildable(Interface): class IBusinessBuildable(Interface):
"""Business Buildable interface specification """Business Buildable interface specification
TODO:
- is isFrozen useful ? is it the same as isCompleted ?
- why isFrozen is here and not in Completable
""" """
def isBuildable(explanation): def isBuildable(explanation):
"""Returns True if any of the related Simulation Movement """Returns True if any of the related Simulation Movement
......
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
...@@ -30,4 +31,7 @@ from Products.ERP5.interfaces.business_completable import IBusinessCompletable ...@@ -30,4 +31,7 @@ from Products.ERP5.interfaces.business_completable import IBusinessCompletable
class IBusinessState(IBusinessCompletable): class IBusinessState(IBusinessCompletable):
"""Business State interface specification """Business State interface specification
TODO:
- add methods if any or remove if nothing specific to Business State
""" """
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