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.
......@@ -39,39 +40,27 @@ import zope.interface
class BusinessPath(Path):
"""
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.
BusinessPath are also used as helper to build buildable movements.
Here is the typical code of an alarm:
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
BusinessPath are also used as helper to build deliveries from
buildable movements. Here is the typical code of an alarm
in charge of the building process.
Approach 2: isBuildable is indexed for SimulationMovements
isBuildable() method is added to SimulationMovement
The idea is to invoke isBuildable() on the collected simulation
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
for path in builder.getSpecialiseRelatedValueList() # or wharever category
builder.build(causality_uid=path.getUid(),) # Select movemenents
Pros: global select is possible
Cons: global select retrieves long lists
slow build
Pros: global select is possible by not providing a causality_uid
Cons: global select retrieves long lists of orphan movements which
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'
portal_type = 'Business Path'
......@@ -95,16 +84,20 @@ class BusinessPath(Path):
# Declarative interfaces
zope.interface.implements(interfaces.ICategoryAccessProvider,
interfaces.IArrow)
interfaces.IArrowBase,
interfaces.IBusinessPath,
interfaces.IBusinessBuildable,
interfaces.IBusinessCompletable
)
# IBusinessPath Interface
# IArrowBase implementation
security.declareProtected(Permissions.AccessContentsInformation, 'getSourceBaseCategoryList')
def getSourceBaseCategoryList(self):
"""
Returns all categories which are used to define the source
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', )
security.declareProtected(Permissions.AccessContentsInformation, 'getDestinationBaseCategoryList')
......@@ -113,7 +106,7 @@ class BusinessPath(Path):
Returns all categories which are used to define the destination
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', )
# ICategoryAccessProvider overriden methods
......@@ -172,7 +165,7 @@ class BusinessPath(Path):
return method(context)
return []
# Core API
# IBusinessBuildable implementation
def isBuildable(self, explanation):
"""
"""
......@@ -192,13 +185,24 @@ class BusinessPath(Path):
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',
explanation_uid=explanation.getUid())
# IBusinessCompletable implementation
def isCompleted(self, explanation):
"""
Looks at all simulation related movements
......@@ -234,17 +238,7 @@ class BusinessPath(Path):
return False
return True
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
# Date calculation
# IBusinessPath implementation
def getExpectedStartDate(self, explanation, predecessor_date=None, *args, **kwargs):
"""
Returns the expected start date for this
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
......@@ -34,11 +35,16 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.Document.Path import Path
import zope.interface
class BusinessProcess(Path, XMLObject):
"""
The BusinessProcess class is a container class which is used
to describe business processes in the area of trade, payroll
and production.
TODO:
- finish interface implementation
"""
meta_type = 'ERP5 Business Process'
portal_type = 'Business Process'
......@@ -59,6 +65,10 @@ class BusinessProcess(Path, XMLObject):
, PropertySheet.BusinessProcess
)
# Declarative interfaces
zope.interface.implements(interfaces.IBusinessProcess,
interfaces.IArrowBase)
# Access to path and states of the business process
security.declareProtected(Permissions.AccessContentsInformation, 'getPathValueList')
def getPathValueList(self, trade_phase, context=None, **kw):
......@@ -180,10 +190,10 @@ class BusinessProcess(Path, XMLObject):
for path in self.getBuildablePathValueList(explanation):
path.build(explanation)
def isStartDateReferential(self):
def isStartDateReferential(self): # XXX - not in interface
return self.getReferentialDate() == 'start_date'
def isStopDateReferential(self):
def isStopDateReferential(self): # XXX - not in interface
return self.getReferentialDate() == 'stop_date'
def getTradePhaseList(self):
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
......@@ -33,11 +34,13 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces
from Products.ERP5Type.XMLObject import XMLObject
import zope.interface
class BusinessState(XMLObject):
"""
The BusinessProcess class is a container class which is used
to describe business processes in the area of trade, payroll
and production.
The BusinessState class defines the various states in
a Business Process. It defines the synchronisation milestones
between movements related to the trade phases of business.
"""
meta_type = 'ERP5 Business State'
portal_type = 'Business State'
......@@ -55,7 +58,11 @@ class BusinessState(XMLObject):
, PropertySheet.Comment
)
# Core API
# Declarative interfaces
zope.interface.implements(interfaces.IBusinessState
)
# IBusinessCompletable implementation
def isCompleted(self, explanation):
"""
If all path which reach this state are completed
......@@ -77,7 +84,7 @@ class BusinessState(XMLObject):
return False
return True
# Duration calculation
# IBusinessCompletable - duration calculation
def getExpectedCompletionDate(self, explanation, *args, **kwargs):
"""
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.
......@@ -30,6 +31,10 @@ from zope.interface import Interface
class IBusinessBuildable(Interface):
"""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):
"""Returns True if any of the related Simulation Movement
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
......@@ -30,4 +31,7 @@ from Products.ERP5.interfaces.business_completable import IBusinessCompletable
class IBusinessState(IBusinessCompletable):
"""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