Commit 694c9fee authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Before migrating Interfaces from FS, there must be one...

ZODB Components: Before migrating Interfaces from FS, there must be one Interface class per source file matching its name.

Same as Document class: this avoids registering Interfaces at startup and just do it
when using the Interface. In assuming that portal_components/XXX has a class
name equals to XXX.getRference(), it is easier to:
 * List all existing Interfaces (for example in Portal Type Class view): getReference()
   on all validated 'Interface Component' in portal_components.
 * Lookup for an 'Interface Component': 'from erp5.component.interfaces.XXX import XXX'.
parent d9627917
# -*- 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 Products.ERP5.interfaces.asset_movement import IAssetMovement
class IAccountingMovement(IAssetMovement):
"""
Accounting Movement private interface specification
The notion of debit and credit is used in accounting instead of signed
quantity. The following calculation rules apply:
Credit/Debit
if quantity > 0
source_credit = quantity
source_debit = 0
destination_credit = 0
destination_debit = quantity
if quantity < 0
source_credit = 0
source_debit = - quantity
destination_credit = - quantity
destination_debit = 0
The cancellation amount concept from IAmount interface also applies for debit
and credit. For a cancellation amount, the calculation rule are different:
if quantity > 0
source_credit = 0
source_debit = - quantity
destination_credit = - quantity
destination_debit = 0
if quantity < 0
source_credit = quantity
source_debit = 0
destination_credit = 0
destination_debit = quantity
"""
# We must a find a way to use property sheets in or as interfaces
# property_sheets = (PropertySheet.Price, )
# Helper methods for single currency Accounting (debit / credit)
def getSourceDebit():
"""
Returns the source debit in the transaction currency
"""
def getSourceCredit():
"""
Returns the source credit in the transaction currency
"""
def getDestinationDebit():
"""
Returns the destination debit in the transaction currency
"""
def getDestinationCredit():
"""
Returns the destination credit in the transaction currency
"""
# Helper methods for multi currency Accounting (debit / credit)
def getSourceAssetDebit():
"""
Returns the source debit in the source section management currency
based on the source_total_asset price property
"""
def getSourceAssetCredit():
"""
Returns the source credit in the source section management currency
based on the source_total_asset price property
"""
def getDestinationAssetDebit():
"""
Returns the destination debit in the destination section management currency
based on the destination_total_asset price property
"""
def getDestinationAssetCredit():
"""
Returns the destination credit in the destination section management currency
based on the destination_total_asset price property
"""
# The following is really unclear -
# It uses getSourceInventoriatedTotalAssetPrice instead of
# of getSourceInventoriatedTotalAssetPrice instead of getSourceTotalAssetPrice
# I can only see one purpose: presentation of reports in predictive accounting
# ie. in transactions generated by simulation which do not yet have
# well defined source_total_asset/destination_total_asset
def getSourceInventoriatedTotalAssetDebit():
"""
Unclear - XXX
"""
def getSourceInventoriatedTotalAssetCredit():
"""
Unclear - XXX
"""
def getDestinationInventoriatedTotalAssetDebit():
"""
Unclear - XXX
"""
def getDestinationInventoriatedTotalAssetCredit():
"""
Unclear - XXX
"""
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
...@@ -30,196 +31,10 @@ ...@@ -30,196 +31,10 @@
Products.ERP5.interfaces.amount Products.ERP5.interfaces.amount
""" """
from zope.interface import Interface from Products.ERP5.interfaces.amount_core import IAmountCore
from Products.ERP5.interfaces.amount_conversion import IAmountConversion
class IAmountCore(Interface): from Products.ERP5.interfaces.amount_price import IAmountPrice
"""Amount Core private interface specification from Products.ERP5.interfaces.amount_arithmetic import IAmountArithmetic
IAmountCore defines the minimal set of getters required
to implement an amount.
"""
def getQuantity():
"""
Returns the quantity of the resource
in the unit specified by the Amount
NOTE: declaration is redundant with IAmountGetter
"""
def getResource():
"""
Returns the resource category relative URL
of the Amount
NOTE: declaration is redundant with IAmountGetter
"""
def getQuantityUnit():
"""
Returns the quantity unit category relative URL
of the Amount
NOTE: declaration is redundant with IAmountGetter
"""
def isCancellationAmount():
"""
A cancellation amount must be interpreted
reversely wrt. to the sign of quantity.
For example, a negative credit for a cancellation
amount is a negative credit, not a positive
debit.
A negative production quantity for a cancellation
amount is a cancelled production, not
a consumption
NOTE: declaration is redundant with IAmountGetter
"""
def getEfficiency():
"""
Returns the ratio of loss for the given amount. This
is only used in Path such as Transformation. In other
words, efficiency of movements is always 100%.
NOTE: declaration is redundant with IAmountGetter
"""
def getBaseContributionList():
"""
The list of bases this amount contributes to.
XXX: explain better
"""
def getBaseApplicationList():
"""
The list of bases this amount has been applied on. Only set if the
amount comes from a transformation.
XXX: explain better
"""
class IAmountConversion(Interface):
"""Amount Conversion private interface specification
IAmountConversion defines methods which can be used
to convert an amount from one quantity unit and to another,
taking into account efficiency.
"""
def getNetQuantity():
"""
Take into account efficiency in quantity. This is
only useful in Path which define a loss ratio, such
as Transformation.
Formula:
net_quantity = quantity / efficiency
"""
def getConvertedQuantity(quantity_unit=None, measure=None):
"""
Returns the quantity of the resource converted in the
default management unit of the resource.
quantity_unit -- optional quantity unit to use
for conversion.
measure -- optional quantity unit to use
for conversion.
"""
def getNetConvertedQuantity(quantity_unit=None, measure=None):
"""
Returns the net quantity of the resource converted in the
default management unit of the resource.
quantity_unit -- optional quantity unit to use
for conversion.
measure -- optional quantity unit to use
for conversion.
"""
class IAmountPrice(Interface):
"""Amount Price private interface specification
IAmountPrice defines methods to compute total price
and unit price of a resource, taking into account
contributions and roundings.
"""
def getPrice():
"""
Returns the input unit price of the resource
NOTE: redundant with IPriceGetter
"""
def getUnitPrice(base_contribution=None, rounding=False):
"""
Returns the unit price of the resource, taking into
account rounding and contributions (ex. taxes).
base_contribution -- optional base_contribution.
If defined, a complex process is launched
to add or remove to the price various amounts
calculated from applicable trade models if
any.
rounding -- optional rounding parameter. If set to True,
find and applies appropriate rounding model.
"""
def getTotalPrice(base_contribution=None, rounding=False):
"""
Returns total price ie. the unit price of the resource
multiplied by the quantity, taking into
account rounding and contributions (ex. taxes).
base_contribution -- optional base_contribution.
If defined, a complex process is launched
to add or remove to the price various amounts
calculated from applicable trade models if
any.
rounding -- optional rounding parameter. If set to True,
find and applies appropriate rounding model.
"""
class IAmountArithmetic(Interface):
"""Amount Arithmetic private interface specification
IAmountArithmetic defines methods to add, substract,
multiply or device amounts of resources. No rounding
should happen. All amounts should be converted to
the default management unit using getNetConvertedQuantity.
"""
def __add__(value):
"""Add an amount to another amount
'value' is an IAmount document
"""
def __sub__(value):
"""Substract an amount from another amount
'value' is an IAmount document
"""
def __mul__(value):
"""Multiply an Amount by a float
'value' is a float
"""
def __div__(value):
"""Divide an Amount by a float
'value' is a float
"""
class IAmount(IAmountCore, IAmountConversion, IAmountPrice, IAmountArithmetic): class IAmount(IAmountCore, IAmountConversion, IAmountPrice, IAmountArithmetic):
"""Amount interface specification """Amount interface specification
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SARL 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.
#
##############################################################################
"""
Products.ERP5.interfaces.amount_arithmetic
"""
from zope.interface import Interface
class IAmountArithmetic(Interface):
"""Amount Arithmetic private interface specification
IAmountArithmetic defines methods to add, substract,
multiply or device amounts of resources. No rounding
should happen. All amounts should be converted to
the default management unit using getNetConvertedQuantity.
"""
def __add__(value):
"""Add an amount to another amount
'value' is an IAmount document
"""
def __sub__(value):
"""Substract an amount from another amount
'value' is an IAmount document
"""
def __mul__(value):
"""Multiply an Amount by a float
'value' is a float
"""
def __div__(value):
"""Divide an Amount by a float
'value' is a float
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SARL 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.
#
##############################################################################
"""
Products.ERP5.interfaces.amount_conversion
"""
from zope.interface import Interface
class IAmountConversion(Interface):
"""Amount Conversion private interface specification
IAmountConversion defines methods which can be used
to convert an amount from one quantity unit and to another,
taking into account efficiency.
"""
def getNetQuantity():
"""
Take into account efficiency in quantity. This is
only useful in Path which define a loss ratio, such
as Transformation.
Formula:
net_quantity = quantity / efficiency
"""
def getConvertedQuantity(quantity_unit=None, measure=None):
"""
Returns the quantity of the resource converted in the
default management unit of the resource.
quantity_unit -- optional quantity unit to use
for conversion.
measure -- optional quantity unit to use
for conversion.
"""
def getNetConvertedQuantity(quantity_unit=None, measure=None):
"""
Returns the net quantity of the resource converted in the
default management unit of the resource.
quantity_unit -- optional quantity unit to use
for conversion.
measure -- optional quantity unit to use
for conversion.
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SARL 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.
#
##############################################################################
"""
Products.ERP5.interfaces.amount_core
"""
from zope.interface import Interface
class IAmountCore(Interface):
"""Amount Core private interface specification
IAmountCore defines the minimal set of getters required
to implement an amount.
"""
def getQuantity():
"""
Returns the quantity of the resource
in the unit specified by the Amount
NOTE: declaration is redundant with IAmountGetter
"""
def getResource():
"""
Returns the resource category relative URL
of the Amount
NOTE: declaration is redundant with IAmountGetter
"""
def getQuantityUnit():
"""
Returns the quantity unit category relative URL
of the Amount
NOTE: declaration is redundant with IAmountGetter
"""
def isCancellationAmount():
"""
A cancellation amount must be interpreted
reversely wrt. to the sign of quantity.
For example, a negative credit for a cancellation
amount is a negative credit, not a positive
debit.
A negative production quantity for a cancellation
amount is a cancelled production, not
a consumption
NOTE: declaration is redundant with IAmountGetter
"""
def getEfficiency():
"""
Returns the ratio of loss for the given amount. This
is only used in Path such as Transformation. In other
words, efficiency of movements is always 100%.
NOTE: declaration is redundant with IAmountGetter
"""
def getBaseContributionList():
"""
The list of bases this amount contributes to.
XXX: explain better
"""
def getBaseApplicationList():
"""
The list of bases this amount has been applied on. Only set if the
amount comes from a transformation.
XXX: explain better
"""
...@@ -83,32 +83,5 @@ class IAmountGenerator(Interface): ...@@ -83,32 +83,5 @@ class IAmountGenerator(Interface):
simplistic) simplistic)
""" """
# For backward compatibility only
class IAmountGeneratorLine(Interface): from Products.ERP5.interfaces.amount_generator_line import IAmountGeneratorLine
"""Amount Generator Line interface specification
"""
def getCellAggregateKey():
"""Define a key in order to aggregate amounts at cell level
Transformed Resource (Transformation)
key must be None because:
- quantity and variation are defined in different cells so that the
user does not need to enter values depending on all axes
- amount_generator_cell.test should filter only 1 variant
current key = (acquired resource, acquired variation)
Assorted Resource (Transformation)
key = (assorted resource, assorted resource variation)
usually resource and quantity provided together
Payroll
key = (payroll resource, payroll resource variation)
Tax
key = (tax resource, tax resource variation)
"""
def getBaseAmountQuantity(delivery_amount, base_application, rounding):
"""Default method to compute quantity for the given base_application
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
# Lukasz Nowak <luke@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility 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
# guarantees and support are strongly advised 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
"""
Products.ERP5.interfaces.amount_generator_line
"""
from zope.interface import Interface
class IAmountGeneratorLine(Interface):
"""Amount Generator Line interface specification
"""
def getCellAggregateKey():
"""Define a key in order to aggregate amounts at cell level
Transformed Resource (Transformation)
key must be None because:
- quantity and variation are defined in different cells so that the
user does not need to enter values depending on all axes
- amount_generator_cell.test should filter only 1 variant
current key = (acquired resource, acquired variation)
Assorted Resource (Transformation)
key = (assorted resource, assorted resource variation)
usually resource and quantity provided together
Payroll
key = (payroll resource, payroll resource variation)
Tax
key = (tax resource, tax resource variation)
"""
def getBaseAmountQuantity(delivery_amount, base_application, rounding):
"""Default method to compute quantity for the given base_application
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SARL 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.
#
##############################################################################
"""
Products.ERP5.interfaces.amount_price
"""
from zope.interface import Interface
class IAmountPrice(Interface):
"""Amount Price private interface specification
IAmountPrice defines methods to compute total price
and unit price of a resource, taking into account
contributions and roundings.
"""
def getPrice():
"""
Returns the input unit price of the resource
NOTE: redundant with IPriceGetter
"""
def getUnitPrice(base_contribution=None, rounding=False):
"""
Returns the unit price of the resource, taking into
account rounding and contributions (ex. taxes).
base_contribution -- optional base_contribution.
If defined, a complex process is launched
to add or remove to the price various amounts
calculated from applicable trade models if
any.
rounding -- optional rounding parameter. If set to True,
find and applies appropriate rounding model.
"""
def getTotalPrice(base_contribution=None, rounding=False):
"""
Returns total price ie. the unit price of the resource
multiplied by the quantity, taking into
account rounding and contributions (ex. taxes).
base_contribution -- optional base_contribution.
If defined, a complex process is launched
to add or remove to the price various amounts
calculated from applicable trade models if
any.
rounding -- optional rounding parameter. If set to True,
find and applies appropriate rounding model.
"""
# -*- 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 Products.ERP5.interfaces.amount import IAmount
class IAssetMovement(IAmount):
"""Asset Movement private interface specification
Asset movements are use to represent the asset
value of a movement of resources leaving a
source and reach a destination.
"""
# We must a find a way to use property sheets in or as interfaces
# property_sheets = (PropertySheet.Price, )
def getSourceAssetPrice():
"""
Return the asset price for the source section,
usually the price of the movement converted to
the currency of the source section using the currency
rate of the day. If no price is defined, an internal
price may be looked up. It is also possible for
a movement to have 'None' source asset price,
for example for a movement with positive quantity
going from one warehouse to another warehouse of
the same company.
"""
def getDestinationAssetPrice():
"""
Return the asset price for the destination section,
usually the price of the movement converted to
the currency of the destination section using the currency
rate of the day. If no price is defined, an internal
price may be looked up first. It is also possible for
a movement to have 'None' destination asset price,
for example for a movement with negative quantity
going from one warehouse to another warehouse of
the same company.
"""
def getSourceInventoriatedTotalAssetPrice():
"""
Returns the total asset price for the source section, either
defined explicitely by the source_asset_price property
(as in accounting) or by calling getSourceAssetPrice and
multiplying it by the quantity. If no asset price
is defined, return None. Asset calculation methods
(SimulationTool.getInventoryAssetPrice) interprete
None using FIFO, FILO or Average algorithm.
"""
def getDestinationInventoriatedTotalAssetPrice():
"""
Returns the total asset price for the destination section, either
defined explicitely by the destination_asset_price property
(as in accounting) or by calling getDestinationAssetPrice and
multiplying it by the quantity. If no asset price
is defined, return None. Asset calculation methods
(SimulationTool.getInventoryAssetPrice) interprete
None using FIFO, FILO or Average algorithm.
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009-2010 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 IBuildableBusinessLinkProcess(Interface):
"""Buildable Business Link Process interface specification
IBuildableBusinessLinkProcess defines an API to build
simulation movements related to business link in the context
of a given explanation.
"""
def getBuildableBusinessLinkValueList(explanation):
"""Returns the list of Business Link which are buildable
by taking into account trade state dependencies between
Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def getPartiallyBuildableBusinessLinkValueList(explanation):
"""Returns the list of Business Link which are partially buildable
by taking into account trade state dependencies between
Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def isBusinessLinkBuildable(explanation, business_link):
"""Returns True if any of the related Simulation Movement
is buildable and if the predecessor trade state is completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
business_link -- a Business Link document
"""
def isBusinessPatPartiallyBuildable(explanation, business_link):
"""Returns True if any of the related Simulation Movement
is buildable and if the predecessor trade state is partially completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
business_link -- a Business Link document
"""
def isBuildable(explanation):
"""Returns True is this business process has at least one
Business Link which is buildable
"""
def isPartiallyBuildable(explanation):
"""Returns True is this business process has at least one
Business Link which is partially buildable
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009-2010 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 IBusinessLinkProcess(Interface):
"""Business Link Process interface specification
IBusinessLinkProcess defines Business Process APIs related
to Business Link completion status and expected completion dates.
IMPORTANT:
- explanation implicitely defines a subtree of the simulation
Order, Order Line, Delivery or Delivery Line are simple cases
which consider all children of delivery related movements
+ all parent simulation movement
Applied rule is another form of explanation, which defines
implicitely all children + all parent simulation movements
TODO:
- find a way in getTradePhaseMovementList to narrow down
parameters to be copied (this used to be done through rule
parameter in provivate method)
- Is there a reason why trade_phase should be a list in
getBusinessLinkValueList ? (for rules ?)
"""
def getBusinessLinkValueList(trade_phase=None, context=None,
predecessor=None, successor=None, **kw):
"""Returns all Business Links of the current BusinessProcess which
are matching the given trade_phase and the optional context.
trade_phase -- filter by trade phase
context -- a context to test each Business Link on
and filter out Business Link which do not match
predecessor -- filter by trade state predecessor
successor -- filter by trade state successor
**kw -- same arguments as those passed to searchValues / contentValues
"""
def isBusinessLinkCompleted(explanation, business_link):
"""Returns True if given Business Link document
is completed in the context of provided explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
business_link -- a Business Link document
"""
def isBusinessLinkPartiallyCompleted(explanation, business_link):
"""Returns True if given Business Link document
is partially completed in the context of provided explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
business_link -- a Business Link document
"""
...@@ -26,425 +26,13 @@ ...@@ -26,425 +26,13 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
"""
Products.ERP5.interfaces.business_process
"""
from zope.interface import Interface from Products.ERP5.interfaces.trade_model_path_process import ITradeModelPathProcess
from Products.ERP5.interfaces.business_link_process import IBusinessLinkProcess
class ITradeModelPathProcess(Interface): from Products.ERP5.interfaces.buildable_business_link_process import IBuildableBusinessLinkProcess
"""Trade Model Path Process interface specification from Products.ERP5.interfaces.trade_state_process import ITradeStateProcess
from Products.ERP5.interfaces.trade_phase_process import ITradePhaseProcess
ITradeModelPathProcess defines Business Process APIs related from Products.ERP5.interfaces.simulation_movement_process import ISimulationMovementProcess
to Trade Model Path access and to the evaluation of start_date,
stop date, quantity shares and arrows of an Amount.
"""
def getTradeModelPathValueList(trade_phase=None, context=None, **kw):
"""Returns all Trade Model Path of the current Business Process which
are matching the given trade_phase and the optional context.
trade_phase -- filter by trade phase
context -- a context to test each Business Link on
and filter out Business Link which do not match
**kw -- same arguments as those passed to searchValues / contentValues
"""
def getExpectedTradeModelPathStartAndStopDate(explanation, trade_model_path,
delay_mode=None):
"""Returns the expected start and stop dates of given Trade Model Path
document in the context of provided explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_model_path -- a Trade Model Path document
delay_mode -- optional value to specify calculation mode ('min', 'max')
if no value specified use average delay
"""
class IBusinessLinkProcess(Interface):
"""Business Link Process interface specification
IBusinessLinkProcess defines Business Process APIs related
to Business Link completion status and expected completion dates.
IMPORTANT:
- explanation implicitely defines a subtree of the simulation
Order, Order Line, Delivery or Delivery Line are simple cases
which consider all children of delivery related movements
+ all parent simulation movement
Applied rule is another form of explanation, which defines
implicitely all children + all parent simulation movements
TODO:
- find a way in getTradePhaseMovementList to narrow down
parameters to be copied (this used to be done through rule
parameter in provivate method)
- Is there a reason why trade_phase should be a list in
getBusinessLinkValueList ? (for rules ?)
"""
def getBusinessLinkValueList(trade_phase=None, context=None,
predecessor=None, successor=None, **kw):
"""Returns all Business Links of the current BusinessProcess which
are matching the given trade_phase and the optional context.
trade_phase -- filter by trade phase
context -- a context to test each Business Link on
and filter out Business Link which do not match
predecessor -- filter by trade state predecessor
successor -- filter by trade state successor
**kw -- same arguments as those passed to searchValues / contentValues
"""
def isBusinessLinkCompleted(explanation, business_link):
"""Returns True if given Business Link document
is completed in the context of provided explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
business_link -- a Business Link document
"""
def isBusinessLinkPartiallyCompleted(explanation, business_link):
"""Returns True if given Business Link document
is partially completed in the context of provided explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
business_link -- a Business Link document
"""
class IBuildableBusinessLinkProcess(Interface):
"""Buildable Business Link Process interface specification
IBuildableBusinessLinkProcess defines an API to build
simulation movements related to business link in the context
of a given explanation.
"""
def getBuildableBusinessLinkValueList(explanation):
"""Returns the list of Business Link which are buildable
by taking into account trade state dependencies between
Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def getPartiallyBuildableBusinessLinkValueList(explanation):
"""Returns the list of Business Link which are partially buildable
by taking into account trade state dependencies between
Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def isBusinessLinkBuildable(explanation, business_link):
"""Returns True if any of the related Simulation Movement
is buildable and if the predecessor trade state is completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
business_link -- a Business Link document
"""
def isBusinessPatPartiallyBuildable(explanation, business_link):
"""Returns True if any of the related Simulation Movement
is buildable and if the predecessor trade state is partially completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
business_link -- a Business Link document
"""
def isBuildable(explanation):
"""Returns True is this business process has at least one
Business Link which is buildable
"""
def isPartiallyBuildable(explanation):
"""Returns True is this business process has at least one
Business Link which is partially buildable
"""
class ITradeStateProcess(Interface):
"""Trade State Process interface specification
ITradeStateProcess defines Business Process APIs related
to Trade State completion status and expected completion dates.
ITradeStateProcess APIs recursively browse trade states and business
links to provide completion status and expected completion dates.
For example, a complete trade state is a trade state for
which all predecessor trade states are completed and for
which all business links applicable to the given explanation
are also completed.
"""
def getTradeStateList():
"""Returns list of all trade_state of this Business Process
by looking at successor and predecessor values of contained
Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def isInitialTradeState(trade_state):
"""Returns True if given 'trade_state' has no successor related
Business Link.
trade_state -- a Trade State category
"""
def isFinalTradeState(trade_state):
"""Returns True if given 'trade_state' has no predecessor related
Business Link.
trade_state -- a Trade State category
"""
def getSuccessorTradeStateList(explanation, trade_state):
"""Returns the list of successor states in the
context of given explanation. This list is built by looking
at all successor of business link involved in given explanation
and which predecessor is the given trade_phase.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_state -- a Trade State category
"""
def getPredecessorTradeStateList(explanation, trade_state):
"""Returns the list of predecessor states in the
context of given explanation. This list is built by looking
at all predecessor of business link involved in given explanation
and which sucessor is the given trade_phase.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_state -- a Trade State category
"""
def getCompletedTradeStateList(explanation):
"""Returns the list of Trade States which are completed
in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def getPartiallyCompletedTradeStateList(explanation):
"""Returns the list of Trade States which are partially
completed in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def getLatestCompletedTradeStateList(explanation):
"""Returns the list of completed trade states which predecessor
states are completed and for which no successor state
is completed in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def getLatestPartiallyCompletedTradeStateList(explanation):
"""Returns the list of completed trade states which predecessor
states are completed and for which no successor state
is partially completed in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def isTradeStateCompleted(explanation, trade_state):
"""Returns True if all predecessor trade states are
completed and if the provided trade state is also completed
in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_state -- a Trade State category
"""
def isTradeStatePartiallyCompleted(explanation, trade_state):
"""Returns True if all predecessor trade states are
completed and if no successor trade state is partially completed
in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_state -- a Trade State category
"""
class ITradePhaseProcess(Interface):
"""Trade Phase Process interface specification
ITradePhaseProcess defines Business Process APIs related
to Trade Phase completion status and expected completion dates.
Unlike ITradeStateProcess, ITradePhaseProcess APIs related to completion
do not take into account relations between trade states and
business link.
For example, a completed trade phase is a trade phase for which all
business link applicable to the given explanation are completed.
It does not matter whether the predecessor trade state of related
business link is completed or not.
"""
def getTradePhaseList():
"""Returns list of all trade_phase of this Business Process
by looking at trade_phase values of contained Business Link.
"""
def getCompletedTradePhaseList(explanation):
"""Returns the list of Trade Phases which are completed
in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def getPartiallyCompletedTradePhaseList(explanation):
"""Returns the list of Trade Phases which are partially completed
in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def isTradePhaseCompleted(explanation, trade_phase):
"""Returns True if all business link with given trade_phase
applicable to given explanation are completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_phase -- a Trade Phase category
"""
def isTradePhasePartiallyCompleted(explanation, trade_phase):
"""Returns True at least one business link with given trade_phase
applicable to given explanation is partially completed
or completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_phase -- a Trade Phase category
"""
def getRemainingTradePhaseList(business_link):
"""Returns the list of remaining trade phases which to be achieved
as part of a business process. This list is calculated by analysing
the graph of business link and trade states, starting from a given
business link. The result if filtered by a list of trade phases. This
method is useful mostly for production and MRP to manage a distributed
supply and production chain.
business_link -- a Business Link document
NOTE: explanation is not involved here because we consider here that
self is the result of asUnionBusinessProcess and thus only contains
applicable Business Link to a given simulation subtree. Since the list
of remaining trade phases does not depend on exact values in the
simulation, we did not include the explanation. However, this makes the
API less uniform.
"""
def getTradePhaseMovementList(explanation, amount, trade_phase=None, delay_mode=None):
"""Returns a list of movement with appropriate arrow and dates,
based on the Business Link definitions, provided 'amount' and optional
trade phases. If no trade_phase is provided, the trade_phase defined
on the Amount is used instead.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
amount -- Amount (quantity, resource)
trade_phase -- optional Trade Phase category
delay_mode -- optional value to specify calculation mode ('min', 'max')
if no value specified use average delay
"""
class ISimulationMovementProcess(Interface):
"""Simulation Movemnt Process interface specification
ISimulationMovementProcess provides help methods to
access simulation movements of an explanation and
gather statistics about them. It is useful to find
out min dates or max dates related to a business link,
to a trade phase, to a trade model path, to a
trade_model_line, etc.
"""
def getSimulationMovementList(explanation, trade_phase=None,
business_link=None, trade_model_path=None, trade_model_line=None, **kw):
"""Returns a list of movement part of the simulation subtrees
defined by explanation and which match provided parameters. This
method can be useful for example to list all simulation movements
related to a phase such as payment, and inspect them.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_phase -- optional Trade Phase category
business_link -- optional Business Link document
trade_model_path -- optional Trade Model Path document
trade_model_line --optional Trade Model Line document
**kw -- other optional parameters which are passed to Catalog API
"""
def getSimulationMovementStat(explanation, trade_phase=None,
business_link=None, trade_model_path=None, trade_model_line=None, **kw):
"""Returns statistics for movements part of the simulation subtrees
defined by explanation and which match provided parameters. This
method can be useful for example to find the max date of simulation movements
related to a phase such as payment.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_phase -- optional Trade Phase category
business_link -- optional Business Link document
trade_model_path -- optional Trade Model Path document
trade_model_line --optional Trade Model Line document
**kw -- other optional parameters which are passed to Catalog API
"""
class IBusinessProcess(ITradeModelPathProcess, IBusinessLinkProcess, IBuildableBusinessLinkProcess, class IBusinessProcess(ITradeModelPathProcess, IBusinessLinkProcess, IBuildableBusinessLinkProcess,
ITradeStateProcess, ITradePhaseProcess, ISimulationMovementProcess): ITradeStateProcess, ITradePhaseProcess, ISimulationMovementProcess):
......
...@@ -27,67 +27,7 @@ ...@@ -27,67 +27,7 @@
# #
############################################################################## ##############################################################################
from zope.interface import Interface from Products.ERP5.interfaces.format_convertable import IFormatConvertable
class IFormatConvertable(Interface):
"""
Format Convertable interface specification
IFormatConvertable provides methods to list possible formats which documents can
be converted to.
"""
def isTargetFormatAllowed(format):
"""
Checks if the current document can be converted
to the specified target format.
format -- the target conversion format specified either as an
extension (ex. 'png') or as a mime type
string (ex. 'text/plain')
"""
def isTargetFormatPermitted(format):
"""
Checks if the current user can convert the current
document to the specified target format.
This method can be used to restrict the list of possible
formats to deliver a document to a certain group of
users (ex. read-only PDF only for anonymous users)
format -- the target conversion format specified either as an
extension (ex. 'png') or as a mime type
string (ex. 'text/plain')
"""
def getTargetFormatItemList():
"""
Returns the list of acceptable formats for conversion
in the form of tuples which can be used for example for
listfield in ERP5Form. Each tuple in the list has the form
(title, format) where format is an extension (ex. 'png')
which can be passed to IConvertable.convert or to
IDownloadable.index_html and title is a string which
can be translated and displayed to the user.
Example of result:
[('ODF Drawing', 'odg'), ('ODF Drawing Template', 'otg'),
('OpenOffice.org 1.0 Drawing', 'sxd')]
"""
def getTargetFormatTitleList():
"""
Returns the list of titles of acceptable formats for conversion
as a list of strings which can be translated and displayed
to the user.
"""
def getTargetFormatList():
"""
Returns the list of acceptable formats for conversion
where format is an extension (ex. 'png') which can be
passed to IConvertable.convert or to IDownloadable.index_html
"""
class IConvertable(IFormatConvertable): class IConvertable(IFormatConvertable):
""" """
......
...@@ -27,14 +27,7 @@ ...@@ -27,14 +27,7 @@
# #
############################################################################## ##############################################################################
from zope.interface import Interface from Products.ERP5.interfaces.legacy_document_proxy import ILegacyDocumentProxy
class ILegacyDocumentProxy(Interface):
def getProxiedDocument(self, **kw):
"""
Get the proxied document
"""
class IDocumentProxy(ILegacyDocumentProxy): class IDocumentProxy(ILegacyDocumentProxy):
""" """
......
...@@ -27,17 +27,7 @@ ...@@ -27,17 +27,7 @@
# #
############################################################################## ##############################################################################
from zope.interface import Interface from Products.ERP5.interfaces.legacy_extensible_traversable import ILegacyExtensibleTraversable
class ILegacyExtensibleTraversable(Interface):
"""
Extensible Traversable legacy interface specification
"""
def _getExtensibleContent(request, name):
"""
Return extensible subcontent of context document during traversal.
"""
class IExtensibleTraversable(ILegacyExtensibleTraversable): class IExtensibleTraversable(ILegacyExtensibleTraversable):
""" """
......
# -*- 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 IFormatConvertable(Interface):
"""
Format Convertable interface specification
IFormatConvertable provides methods to list possible formats which documents can
be converted to.
"""
def isTargetFormatAllowed(format):
"""
Checks if the current document can be converted
to the specified target format.
format -- the target conversion format specified either as an
extension (ex. 'png') or as a mime type
string (ex. 'text/plain')
"""
def isTargetFormatPermitted(format):
"""
Checks if the current user can convert the current
document to the specified target format.
This method can be used to restrict the list of possible
formats to deliver a document to a certain group of
users (ex. read-only PDF only for anonymous users)
format -- the target conversion format specified either as an
extension (ex. 'png') or as a mime type
string (ex. 'text/plain')
"""
def getTargetFormatItemList():
"""
Returns the list of acceptable formats for conversion
in the form of tuples which can be used for example for
listfield in ERP5Form. Each tuple in the list has the form
(title, format) where format is an extension (ex. 'png')
which can be passed to IConvertable.convert or to
IDownloadable.index_html and title is a string which
can be translated and displayed to the user.
Example of result:
[('ODF Drawing', 'odg'), ('ODF Drawing Template', 'otg'),
('OpenOffice.org 1.0 Drawing', 'sxd')]
"""
def getTargetFormatTitleList():
"""
Returns the list of titles of acceptable formats for conversion
as a list of strings which can be translated and displayed
to the user.
"""
def getTargetFormatList():
"""
Returns the list of acceptable formats for conversion
where format is an extension (ex. 'png') which can be
passed to IConvertable.convert or to IDownloadable.index_html
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@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 ILegacyDocumentProxy(Interface):
def getProxiedDocument(self, **kw):
"""
Get the proxied document
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@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 ILegacyExtensibleTraversable(Interface):
"""
Extensible Traversable legacy interface specification
"""
def _getExtensibleContent(request, name):
"""
Return extensible subcontent of context document during traversal.
"""
...@@ -26,221 +26,9 @@ ...@@ -26,221 +26,9 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
"""
Products.ERP5.interfaces.movement
"""
from Products.ERP5.interfaces.amount import IAmount
from Products.ERP5.interfaces.arrow_base import IArrowBase
class IAssetMovement(IAmount):
"""Asset Movement private interface specification
Asset movements are use to represent the asset
value of a movement of resources leaving a
source and reach a destination.
"""
# We must a find a way to use property sheets in or as interfaces
# property_sheets = (PropertySheet.Price, )
def getSourceAssetPrice():
"""
Return the asset price for the source section,
usually the price of the movement converted to
the currency of the source section using the currency
rate of the day. If no price is defined, an internal
price may be looked up. It is also possible for
a movement to have 'None' source asset price,
for example for a movement with positive quantity
going from one warehouse to another warehouse of
the same company.
"""
def getDestinationAssetPrice():
"""
Return the asset price for the destination section,
usually the price of the movement converted to
the currency of the destination section using the currency
rate of the day. If no price is defined, an internal
price may be looked up first. It is also possible for
a movement to have 'None' destination asset price,
for example for a movement with negative quantity
going from one warehouse to another warehouse of
the same company.
"""
def getSourceInventoriatedTotalAssetPrice():
"""
Returns the total asset price for the source section, either
defined explicitely by the source_asset_price property
(as in accounting) or by calling getSourceAssetPrice and
multiplying it by the quantity. If no asset price
is defined, return None. Asset calculation methods
(SimulationTool.getInventoryAssetPrice) interprete
None using FIFO, FILO or Average algorithm.
"""
def getDestinationInventoriatedTotalAssetPrice():
"""
Returns the total asset price for the destination section, either
defined explicitely by the destination_asset_price property
(as in accounting) or by calling getDestinationAssetPrice and
multiplying it by the quantity. If no asset price
is defined, return None. Asset calculation methods
(SimulationTool.getInventoryAssetPrice) interprete
None using FIFO, FILO or Average algorithm.
"""
class IProductionMovement(IAmount):
"""Production Movement private interface specification
Production movements have a source or a destination equal
to None. They are used to represent productions or
consumptions or resources according to the following
specification:
(A -> B)
production_quantity means nothing
consumption_quantity means nothing
(A -> Nothing)
if quantity > 0
consumption_quantity = quantity
production_quantity = 0
if quantity < 0
consumption_quantity = 0
production_quantity = - quantity
(Nothing -> B)
if quantity > 0
consumption_quantity = 0
production_quantity = quantity
if quantity < 0
consumption_quantity = - quantity
production_quantity = 0
"""
def getConsumptionQuantity():
"""
Returns the consumed quantity during production
"""
def getProductionQuantity():
"""
Returns the produced quantity during production
"""
class IAccountingMovement(IAssetMovement):
"""
Accounting Movement private interface specification
The notion of debit and credit is used in accounting instead of signed
quantity. The following calculation rules apply:
Credit/Debit
if quantity > 0
source_credit = quantity
source_debit = 0
destination_credit = 0
destination_debit = quantity
if quantity < 0
source_credit = 0
source_debit = - quantity
destination_credit = - quantity
destination_debit = 0
The cancellation amount concept from IAmount interface also applies for debit
and credit. For a cancellation amount, the calculation rule are different:
if quantity > 0
source_credit = 0
source_debit = - quantity
destination_credit = - quantity
destination_debit = 0
if quantity < 0
source_credit = quantity
source_debit = 0
destination_credit = 0
destination_debit = quantity
""" from Products.ERP5.interfaces.production_movement import IProductionMovement
# We must a find a way to use property sheets in or as interfaces from Products.ERP5.interfaces.arrow_base import IArrowBase
# property_sheets = (PropertySheet.Price, )
# Helper methods for single currency Accounting (debit / credit)
def getSourceDebit():
"""
Returns the source debit in the transaction currency
"""
def getSourceCredit():
"""
Returns the source credit in the transaction currency
"""
def getDestinationDebit():
"""
Returns the destination debit in the transaction currency
"""
def getDestinationCredit():
"""
Returns the destination credit in the transaction currency
"""
# Helper methods for multi currency Accounting (debit / credit)
def getSourceAssetDebit():
"""
Returns the source debit in the source section management currency
based on the source_total_asset price property
"""
def getSourceAssetCredit():
"""
Returns the source credit in the source section management currency
based on the source_total_asset price property
"""
def getDestinationAssetDebit():
"""
Returns the destination debit in the destination section management currency
based on the destination_total_asset price property
"""
def getDestinationAssetCredit():
"""
Returns the destination credit in the destination section management currency
based on the destination_total_asset price property
"""
# The following is really unclear -
# It uses getSourceInventoriatedTotalAssetPrice instead of
# of getSourceInventoriatedTotalAssetPrice instead of getSourceTotalAssetPrice
# I can only see one purpose: presentation of reports in predictive accounting
# ie. in transactions generated by simulation which do not yet have
# well defined source_total_asset/destination_total_asset
def getSourceInventoriatedTotalAssetDebit():
"""
Unclear - XXX
"""
def getSourceInventoriatedTotalAssetCredit():
"""
Unclear - XXX
"""
def getDestinationInventoriatedTotalAssetDebit():
"""
Unclear - XXX
"""
def getDestinationInventoriatedTotalAssetCredit():
"""
Unclear - XXX
"""
class IMovement(IProductionMovement, IArrowBase): class IMovement(IProductionMovement, IArrowBase):
"""Movement interface specification """Movement interface specification
...@@ -267,3 +55,6 @@ class IMovement(IProductionMovement, IArrowBase): ...@@ -267,3 +55,6 @@ class IMovement(IProductionMovement, IArrowBase):
point of view. point of view.
""" """
# For backward compatibility only
from Products.ERP5.interfaces.accounting_movement import IAccountingMovement
from Products.ERP5.interfaces.asset_movement import IAssetMovement
# -*- 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 Products.ERP5.interfaces.amount import IAmount
class IProductionMovement(IAmount):
"""Production Movement private interface specification
Production movements have a source or a destination equal
to None. They are used to represent productions or
consumptions or resources according to the following
specification:
(A -> B)
production_quantity means nothing
consumption_quantity means nothing
(A -> Nothing)
if quantity > 0
consumption_quantity = quantity
production_quantity = 0
if quantity < 0
consumption_quantity = 0
production_quantity = - quantity
(Nothing -> B)
if quantity > 0
consumption_quantity = 0
production_quantity = quantity
if quantity < 0
consumption_quantity = - quantity
production_quantity = 0
"""
def getConsumptionQuantity():
"""
Returns the consumed quantity during production
"""
def getProductionQuantity():
"""
Returns the produced quantity during production
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009-2010 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 ISimulationMovementProcess(Interface):
"""Simulation Movemnt Process interface specification
ISimulationMovementProcess provides help methods to
access simulation movements of an explanation and
gather statistics about them. It is useful to find
out min dates or max dates related to a business link,
to a trade phase, to a trade model path, to a
trade_model_line, etc.
"""
def getSimulationMovementList(explanation, trade_phase=None,
business_link=None, trade_model_path=None, trade_model_line=None, **kw):
"""Returns a list of movement part of the simulation subtrees
defined by explanation and which match provided parameters. This
method can be useful for example to list all simulation movements
related to a phase such as payment, and inspect them.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_phase -- optional Trade Phase category
business_link -- optional Business Link document
trade_model_path -- optional Trade Model Path document
trade_model_line --optional Trade Model Line document
**kw -- other optional parameters which are passed to Catalog API
"""
def getSimulationMovementStat(explanation, trade_phase=None,
business_link=None, trade_model_path=None, trade_model_line=None, **kw):
"""Returns statistics for movements part of the simulation subtrees
defined by explanation and which match provided parameters. This
method can be useful for example to find the max date of simulation movements
related to a phase such as payment.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_phase -- optional Trade Phase category
business_link -- optional Business Link document
trade_model_path -- optional Trade Model Path document
trade_model_line --optional Trade Model Line document
**kw -- other optional parameters which are passed to Catalog API
"""
...@@ -27,23 +27,7 @@ ...@@ -27,23 +27,7 @@
# #
############################################################################## ##############################################################################
from zope.interface import Interface from Products.ERP5.interfaces.text_convertable_legacy import ITextConvertableLegacy
class ITextConvertableLegacy(Interface):
"""
Legacy ITextConvertable interface specification
Documents which implement the ITextConvertable interface
can be converted to plain text.
"""
def asTextContent(**kw):
"""
Converts the current document to plain text
kw -- optional parameters which can be passed to the
conversion engine
"""
class ITextConvertable(ITextConvertableLegacy): class ITextConvertable(ITextConvertableLegacy):
""" """
......
# -*- 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 ITextConvertableLegacy(Interface):
"""
Legacy ITextConvertable interface specification
Documents which implement the ITextConvertable interface
can be converted to plain text.
"""
def asTextContent(**kw):
"""
Converts the current document to plain text
kw -- optional parameters which can be passed to the
conversion engine
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009-2010 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 ITradeModelPathProcess(Interface):
"""Trade Model Path Process interface specification
ITradeModelPathProcess defines Business Process APIs related
to Trade Model Path access and to the evaluation of start_date,
stop date, quantity shares and arrows of an Amount.
"""
def getTradeModelPathValueList(trade_phase=None, context=None, **kw):
"""Returns all Trade Model Path of the current Business Process which
are matching the given trade_phase and the optional context.
trade_phase -- filter by trade phase
context -- a context to test each Business Link on
and filter out Business Link which do not match
**kw -- same arguments as those passed to searchValues / contentValues
"""
def getExpectedTradeModelPathStartAndStopDate(explanation, trade_model_path,
delay_mode=None):
"""Returns the expected start and stop dates of given Trade Model Path
document in the context of provided explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_model_path -- a Trade Model Path document
delay_mode -- optional value to specify calculation mode ('min', 'max')
if no value specified use average delay
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009-2010 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 ITradePhaseProcess(Interface):
"""Trade Phase Process interface specification
ITradePhaseProcess defines Business Process APIs related
to Trade Phase completion status and expected completion dates.
Unlike ITradeStateProcess, ITradePhaseProcess APIs related to completion
do not take into account relations between trade states and
business link.
For example, a completed trade phase is a trade phase for which all
business link applicable to the given explanation are completed.
It does not matter whether the predecessor trade state of related
business link is completed or not.
"""
def getTradePhaseList():
"""Returns list of all trade_phase of this Business Process
by looking at trade_phase values of contained Business Link.
"""
def getCompletedTradePhaseList(explanation):
"""Returns the list of Trade Phases which are completed
in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def getPartiallyCompletedTradePhaseList(explanation):
"""Returns the list of Trade Phases which are partially completed
in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def isTradePhaseCompleted(explanation, trade_phase):
"""Returns True if all business link with given trade_phase
applicable to given explanation are completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_phase -- a Trade Phase category
"""
def isTradePhasePartiallyCompleted(explanation, trade_phase):
"""Returns True at least one business link with given trade_phase
applicable to given explanation is partially completed
or completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_phase -- a Trade Phase category
"""
def getRemainingTradePhaseList(business_link):
"""Returns the list of remaining trade phases which to be achieved
as part of a business process. This list is calculated by analysing
the graph of business link and trade states, starting from a given
business link. The result if filtered by a list of trade phases. This
method is useful mostly for production and MRP to manage a distributed
supply and production chain.
business_link -- a Business Link document
NOTE: explanation is not involved here because we consider here that
self is the result of asUnionBusinessProcess and thus only contains
applicable Business Link to a given simulation subtree. Since the list
of remaining trade phases does not depend on exact values in the
simulation, we did not include the explanation. However, this makes the
API less uniform.
"""
def getTradePhaseMovementList(explanation, amount, trade_phase=None, delay_mode=None):
"""Returns a list of movement with appropriate arrow and dates,
based on the Business Link definitions, provided 'amount' and optional
trade phases. If no trade_phase is provided, the trade_phase defined
on the Amount is used instead.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
amount -- Amount (quantity, resource)
trade_phase -- optional Trade Phase category
delay_mode -- optional value to specify calculation mode ('min', 'max')
if no value specified use average delay
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009-2010 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 ITradeStateProcess(Interface):
"""Trade State Process interface specification
ITradeStateProcess defines Business Process APIs related
to Trade State completion status and expected completion dates.
ITradeStateProcess APIs recursively browse trade states and business
links to provide completion status and expected completion dates.
For example, a complete trade state is a trade state for
which all predecessor trade states are completed and for
which all business links applicable to the given explanation
are also completed.
"""
def getTradeStateList():
"""Returns list of all trade_state of this Business Process
by looking at successor and predecessor values of contained
Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def isInitialTradeState(trade_state):
"""Returns True if given 'trade_state' has no successor related
Business Link.
trade_state -- a Trade State category
"""
def isFinalTradeState(trade_state):
"""Returns True if given 'trade_state' has no predecessor related
Business Link.
trade_state -- a Trade State category
"""
def getSuccessorTradeStateList(explanation, trade_state):
"""Returns the list of successor states in the
context of given explanation. This list is built by looking
at all successor of business link involved in given explanation
and which predecessor is the given trade_phase.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_state -- a Trade State category
"""
def getPredecessorTradeStateList(explanation, trade_state):
"""Returns the list of predecessor states in the
context of given explanation. This list is built by looking
at all predecessor of business link involved in given explanation
and which sucessor is the given trade_phase.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_state -- a Trade State category
"""
def getCompletedTradeStateList(explanation):
"""Returns the list of Trade States which are completed
in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def getPartiallyCompletedTradeStateList(explanation):
"""Returns the list of Trade States which are partially
completed in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def getLatestCompletedTradeStateList(explanation):
"""Returns the list of completed trade states which predecessor
states are completed and for which no successor state
is completed in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def getLatestPartiallyCompletedTradeStateList(explanation):
"""Returns the list of completed trade states which predecessor
states are completed and for which no successor state
is partially completed in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def isTradeStateCompleted(explanation, trade_state):
"""Returns True if all predecessor trade states are
completed and if the provided trade state is also completed
in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_state -- a Trade State category
"""
def isTradeStatePartiallyCompleted(explanation, trade_state):
"""Returns True if all predecessor trade states are
completed and if no successor trade state is partially completed
in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
trade_state -- a Trade State category
"""
...@@ -26,36 +26,7 @@ ...@@ -26,36 +26,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
from zope.interface import Interface
class ISmsSendingGateway(Interface):
"""SMS Gateway allow sending Short Messages to phones.
"""
def send(text, recipient, sender):
"""Send a message.
* text: the message as an utf-8 encoded string
* recipient: relative URL of recipient person or organisation. Recipient must have a defaut mobile phone
* sender: relative URL of sender person or organisation.
On most implementations, returns a message-id that can be later passed to
getMessageStatus to check the status of the message.
"""
def getMessageStatus(message_id):
"""Retrieve the status of a message
Should return x in ['sent', 'delivered', 'queued', 'failed']"""
class ISmsReceivingGateway(Interface):
"""Gateway to subscribe to events fired when Short Messages are send to SMS interface.
"""
def receive(REQUEST):
"""Public handler to push notifications from the gateway
REQUEST parameters are service provider dependent.
"""
# This file has been kept for backward compatiblity only
from Products.ERP5ShortMessage.interfaces.sms_receiving_gateway import ISmsReceivingGateway
from Products.ERP5ShortMessage.interfaces.sms_sending_gateway import ISmsSendingGateway
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# François-Xavier Algrain <fxalgrain@tiolive.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 ISmsReceivingGateway(Interface):
"""Gateway to subscribe to events fired when Short Messages are send to SMS interface.
"""
def receive(REQUEST):
"""Public handler to push notifications from the gateway
REQUEST parameters are service provider dependent.
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# François-Xavier Algrain <fxalgrain@tiolive.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 ISmsSendingGateway(Interface):
"""SMS Gateway allow sending Short Messages to phones.
"""
def send(text, recipient, sender):
"""Send a message.
* text: the message as an utf-8 encoded string
* recipient: relative URL of recipient person or organisation. Recipient must have a defaut mobile phone
* sender: relative URL of sender person or organisation.
On most implementations, returns a message-id that can be later passed to
getMessageStatus to check the status of the message.
"""
def getMessageStatus(message_id):
"""Retrieve the status of a message
Should return x in ['sent', 'delivered', 'queued', 'failed']"""
##############################################################################
#
# Copyright (c) 2009 Nexedi SARL and Contributors. All Rights Reserved.
#
# 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
# guarantees and support are strongly advised 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 IAction(Interface):
"""
"""
def __getitem__(attr):
"""Return any information independant of the context
The following keys must have a value:
- id (string)
- category (string)
- priority (numeric)
"""
def test(ec):
"""Test if the action should be displayed or not for the given context
"""
def cook(ec):
"""Return a dict with information required to display the action
The dict must contain the following keys:
- id (string)
- name (string)
- description (string)
- url (string)
- icon (string)
- category (string)
- priority (numeric)
"""
##############################################################################
#
# Copyright (c) 2009 Nexedi SARL and Contributors. All Rights Reserved.
#
# 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
# guarantees and support are strongly advised 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 IActionContainer(Interface):
"""
"""
def getCacheableActionList():
"""Return a cacheable list of enabled actions
"""
def getActionList():
"""Return the list of enabled actions from cache, sorted by priority
"""
...@@ -25,44 +25,6 @@ ...@@ -25,44 +25,6 @@
# #
############################################################################## ##############################################################################
"""Action Interfaces. # This file has been kept for backward compatibility only
""" from Products.ERP5Type.interfaces.action_container import IActionContainer
from Products.ERP5Type.interfaces.action import IAction
from zope.interface import Interface
class IAction(Interface):
"""
"""
def __getitem__(attr):
"""Return any information independant of the context
The following keys must have a value:
- id (string)
- category (string)
- priority (numeric)
"""
def test(ec):
"""Test if the action should be displayed or not for the given context
"""
def cook(ec):
"""Return a dict with information required to display the action
The dict must contain the following keys:
- id (string)
- name (string)
- description (string)
- url (string)
- icon (string)
- category (string)
- priority (numeric)
"""
class IActionContainer(Interface):
"""
"""
def getCacheableActionList():
"""Return a cacheable list of enabled actions
"""
def getActionList():
"""Return the list of enabled actions from cache, sorted by priority
"""
##############################################################################
#
# Copyright (c) 2009 Nexedi SARL and Contributors. All Rights Reserved.
#
# 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
# guarantees and support are strongly advised 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.
#
##############################################################################
"""Role Interfaces.
"""
from zope.interface import Interface
class ILocalRoleAssignor(Interface):
"""
"""
def updateLocalRolesOnDocument(ob, user_name=None, reindex=True):
"""Assign Local Roles to Groups on a document
"""
def getFilteredRoleListFor(ob=None):
"""Return all role generators applicable to the object
"""
##############################################################################
#
# Copyright (c) 2009 Nexedi SARL and Contributors. All Rights Reserved.
#
# 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
# guarantees and support are strongly advised 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.
#
##############################################################################
"""Role Interfaces.
"""
from zope.interface import Interface
class ILocalRoleGenerator(Interface):
"""
"""
def getLocalRolesFor(ob, user_name=None):
"""Compute the security that should be applied on an object
Returned value is a dict: {groud_id: role_name_set, ...}
"""
...@@ -28,24 +28,6 @@ ...@@ -28,24 +28,6 @@
"""Role Interfaces. """Role Interfaces.
""" """
from zope.interface import Interface # This file has been kept for backward compatibility only
from Products.ERP5Type.interfaces.local_role_generator import ILocalRoleGenerator
class ILocalRoleGenerator(Interface): from Products.ERP5Type.interfaces.local_role_assignor import ILocalRoleAssignor
"""
"""
def getLocalRolesFor(ob, user_name=None):
"""Compute the security that should be applied on an object
Returned value is a dict: {groud_id: role_name_set, ...}
"""
class ILocalRoleAssignor(Interface):
"""
"""
def updateLocalRolesOnDocument(ob, user_name=None, reindex=True):
"""Assign Local Roles to Groups on a document
"""
def getFilteredRoleListFor(ob=None):
"""Return all role generators applicable to the object
"""
##############################################################################
#
# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
#
# 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
# guarantees and support are strongly advised 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.
#
##############################################################################
"""Types Tool Interfaces.
"""
from Products.CMFCore.interfaces import ITypesTool as ICMFCoreTypesTool
class ITypeProvider(ICMFCoreTypesTool):
"""A type provider contains type information, and conforms to CMF's
TypesTool interface, especially listTypeInfo and getTypeInfo methods.
"""
...@@ -40,8 +40,5 @@ class ITypesTool(ICMFCoreTypesTool): ...@@ -40,8 +40,5 @@ class ITypesTool(ICMFCoreTypesTool):
type_provider_list = Attribute('type_provider_list', type_provider_list = Attribute('type_provider_list',
'List of ids of types providers') 'List of ids of types providers')
class ITypeProvider(ICMFCoreTypesTool): # For backward compatibility only
"""A type provider contains type information, and conforms to CMF's from Products.ERP5Type.interfaces.type_provider import ITypeProvider
TypesTool interface, especially listTypeInfo and getTypeInfo methods.
"""
# This file is kept for backward compatibility only
from Products.Localizer.interfaces.localizer import ILocalizer
from Products.Localizer.interfaces.message_catalog import IMessageCatalog
# -*- coding: UTF-8 -*-
# Copyright (C) 2010 Juan David Ibáñez Palomar <jdavid@itaapy.com>
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
# Import from Zope
from zope.interface import Interface
class ILocalizer(Interface):
pass
...@@ -15,14 +15,7 @@ ...@@ -15,14 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# Import from Zope # Import from Zope
from zope.interface import Interface
from zope.i18n.interfaces import ITranslationDomain from zope.i18n.interfaces import ITranslationDomain
class ILocalizer(Interface):
pass
class IMessageCatalog(ITranslationDomain): class IMessageCatalog(ITranslationDomain):
pass pass
# This file is kept for backward compatibility only
from Products.PortalTransforms.interfaces.portal_transforms_tool import IPortalTransformsTool
from Products.PortalTransforms.interfaces.data_stream import IDataStream
from Products.PortalTransforms.interfaces.transform import ITransform
from Products.PortalTransforms.interfaces.chain import IChain
from Products.PortalTransforms.interfaces.engine import IEngine
# BBB
idatastream = IDataStream
ichain = IChain
iengine = IEngine
itransform = ITransform
from Products.PortalTransforms.interfaces.transform import ITransform
class IChain(ITransform):
def registerTransform(transform, condition=None):
"""Append a transform to the chain"""
from zope.interface import Interface
class IDataStream(Interface):
"""data stream, is the result of a transform"""
def setData(value):
"""set the main data produced by a transform, i.e. usually a string"""
def getData():
"""provide access to the transformed data object, i.e. usually a string.
This data may references subobjects.
"""
def setSubObjects(objects):
"""set a dict-like object containing subobjects.
keys should be object's identifier (e.g. usually a filename) and
values object's content.
"""
def getSubObjects():
"""return a dict-like object with any optional subobjects associated
with the data"""
def getMetadata():
"""return a dict-like object with any optional metadata from
the transform
You can modify the returned dictionnary to add/change metadata
"""
def isCacheable():
"""Return a bool which indicates wether the result should be cached
Default is true
"""
def setCachable(value):
"""Set cacheable flag to yes or no
"""
from zope.interface import Interface from zope.interface import Interface
class IPortalTransformsTool(Interface):
"""Marker interface for the portal_transforms tool."""
class IDataStream(Interface):
"""data stream, is the result of a transform"""
def setData(value):
"""set the main data produced by a transform, i.e. usually a string"""
def getData():
"""provide access to the transformed data object, i.e. usually a string.
This data may references subobjects.
"""
def setSubObjects(objects):
"""set a dict-like object containing subobjects.
keys should be object's identifier (e.g. usually a filename) and
values object's content.
"""
def getSubObjects():
"""return a dict-like object with any optional subobjects associated
with the data"""
def getMetadata():
"""return a dict-like object with any optional metadata from
the transform
You can modify the returned dictionnary to add/change metadata
"""
def isCacheable():
"""Return a bool which indicates wether the result should be cached
Default is true
"""
def setCachable(value):
"""Set cacheable flag to yes or no
"""
class ITransform(Interface):
"""A transformation plugin -- tranform data somehow
must be threadsafe and stateless"""
def name(self):
"""return the name of the transform instance"""
def convert(data, idata, filename=None, **kwargs):
"""convert the data, store the result in idata and return that
optional argument filename may give the original file name of received data
additional arguments given to engine's convert, convertTo or __call__ are
passed back to the transform
The object on which the translation was invoked is available as context
(default: None)
"""
class IChain(ITransform):
def registerTransform(transform, condition=None):
"""Append a transform to the chain"""
class IEngine(Interface): class IEngine(Interface):
def registerTransform(transform): def registerTransform(transform):
...@@ -115,9 +49,3 @@ class IEngine(Interface): ...@@ -115,9 +49,3 @@ class IEngine(Interface):
return an encoded string. return an encoded string.
see convert docstring for more info on additional arguments. see convert docstring for more info on additional arguments.
""" """
# BBB
idatastream = IDataStream
ichain = IChain
iengine = IEngine
itransform = ITransform
from zope.interface import Interface
class IPortalTransformsTool(Interface):
"""Marker interface for the portal_transforms tool."""
from zope.interface import Interface
class ITransform(Interface):
"""A transformation plugin -- tranform data somehow
must be threadsafe and stateless"""
def name(self):
"""return the name of the transform instance"""
def convert(data, idata, filename=None, **kwargs):
"""convert the data, store the result in idata and return that
optional argument filename may give the original file name of received data
additional arguments given to engine's convert, convertTo or __call__ are
passed back to the transform
The object on which the translation was invoked is available as context
(default: None)
"""
...@@ -27,73 +27,8 @@ ...@@ -27,73 +27,8 @@
# #
############################################################################## ##############################################################################
from zope.interface import Interface # This file has been kept for backward compatibility only
from Products.ZSQLCatalog.interfaces.node import INode
class INode(Interface): from Products.ZSQLCatalog.interfaces.value_node import IValueNode
""" from Products.ZSQLCatalog.interfaces.logical_node import ILogicalNode
Any kind of node in an Abstract Syntax Tree. from Products.ZSQLCatalog.interfaces.column_node import IColumnNode
"""
def isLeaf():
"""
Returns True if current node is a leaf in node tree.
Returns False otherwise.
"""
def isColumn():
"""
Returns True if current node is a column in node tree.
Returns False otherwise.
"""
class IValueNode(INode):
"""
Value- and comparison-operator-containig node.
They are leaf nodes in the syntax tree.
"""
def getValue():
"""
Returns node's value.
"""
def getComparisonOperator():
"""
Returns node's comparison operator.
"""
class ILogicalNode(INode):
"""
Logical-operator-containing node.
They are internal tree nodes.
"""
def getLogicalOperator():
"""
Returns node's logical operator.
"""
def getNodeList():
"""
Returns the list of subnodes.
"""
class IColumnNode(INode):
"""
Column-name-containing node.
They are internal tree nodes.
Their value applies to any contained ValueNode, except if there is another
ColumnNode between current one and a ValueNode, for which the other
ColumnNode will take precedence.
"""
def getColumnName():
"""
Returns node's column name.
"""
def getSubNode():
"""
Returns node's (only) subnode.
"""
##############################################################################
#
# Copyright (c) 2002-2009 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
# Vincent Pelletier <vincent@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 Products.ZSQLCatalog.interfaces.node import INode
class IColumnNode(INode):
"""
Column-name-containing node.
They are internal tree nodes.
Their value applies to any contained ValueNode, except if there is another
ColumnNode between current one and a ValueNode, for which the other
ColumnNode will take precedence.
"""
def getColumnName():
"""
Returns node's column name.
"""
def getSubNode():
"""
Returns node's (only) subnode.
"""
##############################################################################
#
# Copyright (c) 2002-2009 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
# Vincent Pelletier <vincent@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 Products.ZSQLCatalog.interfaces.node import INode
class ILogicalNode(INode):
"""
Logical-operator-containing node.
They are internal tree nodes.
"""
def getLogicalOperator():
"""
Returns node's logical operator.
"""
def getNodeList():
"""
Returns the list of subnodes.
"""
##############################################################################
#
# Copyright (c) 2002-2009 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
# Vincent Pelletier <vincent@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 INode(Interface):
"""
Any kind of node in an Abstract Syntax Tree.
"""
def isLeaf():
"""
Returns True if current node is a leaf in node tree.
Returns False otherwise.
"""
def isColumn():
"""
Returns True if current node is a column in node tree.
Returns False otherwise.
"""
...@@ -27,238 +27,5 @@ ...@@ -27,238 +27,5 @@
# #
############################################################################## ##############################################################################
from zope.interface import Interface # This file has been kept for backward compatibility only
from Products.ZSQLCatalog.interfaces.search_key_catalog import ISearchKeyCatalog
class ISearchKeyCatalog(Interface):
def buildQuery(kw, ignore_empty_string=True, operator='and'):
"""
Build a ComplexQuery from kw values.
kw (dict: string keys, any value)
A query will be emited based on its value. Depending on the type of
the value it is handled differently. Query values will be passed
through to result (key is ignored). For all other types, their key
must be either a known column of a sql_search_tables table, or a
related key name.
- String values will be parsed according to the default SearchKey of
their real column (even for related keys). If parsing was
successful, Queries will be generated from its output.
Otherwise, that value will be taken as such.
- Dictionary values can be composed of the following keys:
'query': Their payload value, considered as empty if not given.
'key': The SearchKey to use for this value, overriding default
column configuration.
(for other possible keys, see SearchKeys)
They will be taken as such.
- All other types will be taken as such, and no "empty" check will be
performed on them.
ignore_empty_string (boolean)
If True, values from kw which are empty will be skipped.
This parameter should ultimately disapear *and* be disabled by
default, as it is bad to ignore parameters based on their value if
that value has a meaning in SQL.
operator (string)
Used to explicit the logical relation between kw entries.
It must be a valid ComplexQuery logical operator ('and', 'or').
"""
def buildEntireQuery(kw, query_table='catalog', ignore_empty_string=1,
limit=None, extra_column_list=None):
"""
Construct and return an instance of EntireQuery class from given
parameters by calling buildQuery.
ignore_empty_string (boolean)
See buildQuery.
limit (1-tuple, 2-tuple)
If given, will emit SQL to limit the number of result lines.
group_by_list (list of strings)
If given, will emit SQL to group found lines on given parameter names
(their column if they are column names, corresponding virtual columns
otherwise - as for related keys).
select_dict (dict, key: string, value: string, None)
Given values describe columns to make available in SQL result.
If column is aliased in result set, key is the alias and value is the
column.
Otherwise, key is the column, and value can be None or the same as
key.
select_list (list of strings)
Same as providing select_dict with select_list items as keys, and None
values.
order_by_list (list of 1-, 2-, or 3-tuples of strings)
If given, will emit SQL to sort result lines.
Sort will happen with decreasing precedence in list order.
Given n-tuples can contain those values, always in this order:
- parameter name
- sort order (see SQL documentation of 'ORDER BY')
- type cast (see SQL documentation of 'CAST')
Sort will happen on given parameter name (its column if it's a column
name, corresponding virtual column otherwise - as for related keys).
Extra parameters are passed through to buildQuery.
Backward compatibility parameters:
Those parameters are deprecated and should not be used. They are present
to provide backward compatibility with former ZSQLCatalog version.
REQUEST
Ignored.
extra_column_list (list)
query_table (string, None)
The table to use as catalog table.
If given and None, no catalog table will be used. Use this when you
are using SQLCatalog to generate manualy a part of another query.
That table has a special position in returned query:
- all other tables are joined on this one (when it is required to use
other tables)
- it is expected to have some columns (uid, path)
It is strongly discouraged to use this parameter for any value other
than None.
group_by
Use group_by_list instead.
group_by_expression
Use group_by_list instead.
select_expression
Use select_list or select_dict instead.
sort_on
Use order_by_list instead.
sort_order
Use order_by_list instead.
from_expression
This value will be emited in SQL directly in addition to computed
value.
There is no replacement.
where_expression
This value will be emited in SQL directly in addition to computed
value.
Use Query instances instead.
select_expression_key
This prevents given column from being ignored even if they could not
be mapped.
There is no replacement.
"""
def buildSQLQuery(query_table='catalog', REQUEST=None,
ignore_empty_string=1, only_group_columns=False,
limit=None, extra_column_list=None,
**kw):
"""
Return an SQLExpression-generated dictionary (see
SQLExpression.asSQLExpressionDict). That SQLExpression is generated by
an EntireQuery, itself generated by buildEntireQuery from given
parameters.
only_group_columns
Replaces former stat__ parameter.
Used to globally disalow use of non-group columns in SQL.
For other parameters, see buildEntireQuery.
"""
def getSearchKey(column, search_key=None):
"""
Returns the default SearchKey instance for the
requested column. There is one instance per
search_key (incl. virtual keys surch as
source_title) and we try to compute it once
only and cache it.
If search_key is provided, it is used as the
name of the search key class to return.
"""
def getComparisonOperator(operator):
"""
Return a comparison operator matching given string.
String must be a valid SQL comparison operator (=, LIKE, IN, ...).
String case does not matter.
There is one comparison operator instance per possible string value.
"""
def hasColumn(column):
"""
Check if the given column or virtual column (in case
of related keys) exists or not
"""
# TODO: add support for other operators (logical, ensemblist (?))
def searchResults(REQUEST=None, **kw):
"""
Invokes queryResults with the appropriate
ZSQL Method to return a list of results
"""
def countResults(REQUEST=None, **kw):
"""
Invokes queryResults with the appropriate
ZSQL Method to return a statistics for
a list of results
"""
def queryResults(sql_method, REQUEST=None, src__=0, build_sql_query_method=None, **kw):
"""
Return the result of the given 'sql_method' ZSQL Method after
processing all parameters to build a Query object passed to
that method.
The implementation should do the following.
1- Use **kw parameters to build a Query object
by invoking buildQuery
2- Build a ColumnMap instance by invoking
the buildColumnMap on the Query. Some
optmisation may happen here to try
to build the best possible ColumnMap and
use the best possible indices for joining.
During the ColumnMap build process, the
Search Key associated to each Query node
in the Query tree registers the columns
which are used (ex. to search) or provided
(ex. MATCH value for full text search,
interleave expression or parameter in a
UNION Query)
3- Render the query object as an SQLExpression
instance. This instance contains all necessary
parts to generate:
- where_expression
- sort_expression
- group_by_expression
- select_expression
4- Invoke sql_method
"""
def isAdvancedSearchText(search_text):
"""
Returns True if given value follows Search Text "advanced" syntax,
False otherwise.
"""
def parseSearchText(search_text, column=None, search_key=None, is_valid=None):
"""
Parses given SearchText expression using given column's parser
(determined by the SearchKey it is configured to use by default), or
given SearchKey name.
search_text (string)
SearchText to parse.
column (string)
Column to use to determine which SearchKey to use for parsing.
Either this parameter or search_key must be provided.
search_key (string)
Name of the SearchKey to use for parsing.
Either this parameter or column must be provided.
if_valid (callback)
Callback method to use to decide wether an encountered column-ish
identifier in SearchText is a valid column.
If not provided, catalog schema will be used.
"""
def isValidColumn(column_id):
"""
Returns wether given string is a known column.
Note: related keys and scriptable keys are considered columns.
"""
##############################################################################
#
# Copyright (c) 2002-2009 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
# Vincent Pelletier <vincent@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 Products.ZSQLCatalog.interfaces.search_key import ISearchKey
class IRelatedKey(ISearchKey):
"""
A RelatedKey is a special variation of a SearchKey.
Only a small set of methods differ. They are defined in this class.
"""
def registerColumnMap(column_map, table_alias_list=None):
"""
This is slightly different for regular registerColumnMap in that it must
register multiple tables (and not columns, since RelatedKeys do not
provide this information).
Also, it must register namely "catalog" table and resolve its alias,
angain since it's hardcoded in RelatedKey ZSQLMethods and not provided
by their definitions.
column_map (ColumnMap)
Deprecated:
table_alias_list (None, list of 2-tuples of strings)
This list must have the exact same length as the list of tables
"""
def buildSQLExpression(sql_catalog, column_map, only_group_columns, group):
"""
operator and value parameters are useless, since this type of SearhKey
does not compare a value to any column, but uses a ZSQLMethod.
To reach that ZSQLMethod, it also required a new sql_catalog parameter.
sql_catalog (SQLCatalog)
Used to retrieve related key's ZSQLMethod.
"""
def buildQuery(sql_catalog, related_key_definition, search_value=None):
"""
group is useless here, since group is determined by ColumnMap at
registration time. search_value becomes optional.
sql_catalog (SQLCatalog)
Used to retrieve real column's SearchKey. For example, a RelatedKey
used to compare with a "title" column will retrieve title's default
SearchKey (which should be a KeywordKey).
related_key_definition (string)
Describes parameters of a RelatedKey. It is composed of 3 mains parts,
separated by '/':
- a list of table names
Table names are separated by ','
- a column name
- the name of the related key ZSQLMethod
search_value (None or Query)
If given, a condition on real column will be generated.
Otherwise, only the SQL required to reach that column will be
generated. This is useful when sorting on a virtual column, for
example.
"""
...@@ -129,58 +129,5 @@ class ISearchKey(Interface): ...@@ -129,58 +129,5 @@ class ISearchKey(Interface):
AbstratSyntaxNode complies with the IAbstractSyntaxNode interface. AbstratSyntaxNode complies with the IAbstractSyntaxNode interface.
""" """
class IRelatedKey(ISearchKey): # For backward compatibility only
""" from Products.ZSQLCatalog.interfaces.related_key import IRelatedKey
A RelatedKey is a special variation of a SearchKey.
Only a small set of methods differ. They are defined in this class.
"""
def registerColumnMap(column_map, table_alias_list=None):
"""
This is slightly different for regular registerColumnMap in that it must
register multiple tables (and not columns, since RelatedKeys do not
provide this information).
Also, it must register namely "catalog" table and resolve its alias,
angain since it's hardcoded in RelatedKey ZSQLMethods and not provided
by their definitions.
column_map (ColumnMap)
Deprecated:
table_alias_list (None, list of 2-tuples of strings)
This list must have the exact same length as the list of tables
"""
def buildSQLExpression(sql_catalog, column_map, only_group_columns, group):
"""
operator and value parameters are useless, since this type of SearhKey
does not compare a value to any column, but uses a ZSQLMethod.
To reach that ZSQLMethod, it also required a new sql_catalog parameter.
sql_catalog (SQLCatalog)
Used to retrieve related key's ZSQLMethod.
"""
def buildQuery(sql_catalog, related_key_definition, search_value=None):
"""
group is useless here, since group is determined by ColumnMap at
registration time. search_value becomes optional.
sql_catalog (SQLCatalog)
Used to retrieve real column's SearchKey. For example, a RelatedKey
used to compare with a "title" column will retrieve title's default
SearchKey (which should be a KeywordKey).
related_key_definition (string)
Describes parameters of a RelatedKey. It is composed of 3 mains parts,
separated by '/':
- a list of table names
Table names are separated by ','
- a column name
- the name of the related key ZSQLMethod
search_value (None or Query)
If given, a condition on real column will be generated.
Otherwise, only the SQL required to reach that column will be
generated. This is useful when sorting on a virtual column, for
example.
"""
##############################################################################
#
# Copyright (c) 2002-2009 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
# Vincent Pelletier <vincent@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 ISearchKeyCatalog(Interface):
def buildQuery(kw, ignore_empty_string=True, operator='and'):
"""
Build a ComplexQuery from kw values.
kw (dict: string keys, any value)
A query will be emited based on its value. Depending on the type of
the value it is handled differently. Query values will be passed
through to result (key is ignored). For all other types, their key
must be either a known column of a sql_search_tables table, or a
related key name.
- String values will be parsed according to the default SearchKey of
their real column (even for related keys). If parsing was
successful, Queries will be generated from its output.
Otherwise, that value will be taken as such.
- Dictionary values can be composed of the following keys:
'query': Their payload value, considered as empty if not given.
'key': The SearchKey to use for this value, overriding default
column configuration.
(for other possible keys, see SearchKeys)
They will be taken as such.
- All other types will be taken as such, and no "empty" check will be
performed on them.
ignore_empty_string (boolean)
If True, values from kw which are empty will be skipped.
This parameter should ultimately disapear *and* be disabled by
default, as it is bad to ignore parameters based on their value if
that value has a meaning in SQL.
operator (string)
Used to explicit the logical relation between kw entries.
It must be a valid ComplexQuery logical operator ('and', 'or').
"""
def buildEntireQuery(kw, query_table='catalog', ignore_empty_string=1,
limit=None, extra_column_list=None):
"""
Construct and return an instance of EntireQuery class from given
parameters by calling buildQuery.
ignore_empty_string (boolean)
See buildQuery.
limit (1-tuple, 2-tuple)
If given, will emit SQL to limit the number of result lines.
group_by_list (list of strings)
If given, will emit SQL to group found lines on given parameter names
(their column if they are column names, corresponding virtual columns
otherwise - as for related keys).
select_dict (dict, key: string, value: string, None)
Given values describe columns to make available in SQL result.
If column is aliased in result set, key is the alias and value is the
column.
Otherwise, key is the column, and value can be None or the same as
key.
select_list (list of strings)
Same as providing select_dict with select_list items as keys, and None
values.
order_by_list (list of 1-, 2-, or 3-tuples of strings)
If given, will emit SQL to sort result lines.
Sort will happen with decreasing precedence in list order.
Given n-tuples can contain those values, always in this order:
- parameter name
- sort order (see SQL documentation of 'ORDER BY')
- type cast (see SQL documentation of 'CAST')
Sort will happen on given parameter name (its column if it's a column
name, corresponding virtual column otherwise - as for related keys).
Extra parameters are passed through to buildQuery.
Backward compatibility parameters:
Those parameters are deprecated and should not be used. They are present
to provide backward compatibility with former ZSQLCatalog version.
REQUEST
Ignored.
extra_column_list (list)
query_table (string, None)
The table to use as catalog table.
If given and None, no catalog table will be used. Use this when you
are using SQLCatalog to generate manualy a part of another query.
That table has a special position in returned query:
- all other tables are joined on this one (when it is required to use
other tables)
- it is expected to have some columns (uid, path)
It is strongly discouraged to use this parameter for any value other
than None.
group_by
Use group_by_list instead.
group_by_expression
Use group_by_list instead.
select_expression
Use select_list or select_dict instead.
sort_on
Use order_by_list instead.
sort_order
Use order_by_list instead.
from_expression
This value will be emited in SQL directly in addition to computed
value.
There is no replacement.
where_expression
This value will be emited in SQL directly in addition to computed
value.
Use Query instances instead.
select_expression_key
This prevents given column from being ignored even if they could not
be mapped.
There is no replacement.
"""
def buildSQLQuery(query_table='catalog', REQUEST=None,
ignore_empty_string=1, only_group_columns=False,
limit=None, extra_column_list=None,
**kw):
"""
Return an SQLExpression-generated dictionary (see
SQLExpression.asSQLExpressionDict). That SQLExpression is generated by
an EntireQuery, itself generated by buildEntireQuery from given
parameters.
only_group_columns
Replaces former stat__ parameter.
Used to globally disalow use of non-group columns in SQL.
For other parameters, see buildEntireQuery.
"""
def getSearchKey(column, search_key=None):
"""
Returns the default SearchKey instance for the
requested column. There is one instance per
search_key (incl. virtual keys surch as
source_title) and we try to compute it once
only and cache it.
If search_key is provided, it is used as the
name of the search key class to return.
"""
def getComparisonOperator(operator):
"""
Return a comparison operator matching given string.
String must be a valid SQL comparison operator (=, LIKE, IN, ...).
String case does not matter.
There is one comparison operator instance per possible string value.
"""
def hasColumn(column):
"""
Check if the given column or virtual column (in case
of related keys) exists or not
"""
# TODO: add support for other operators (logical, ensemblist (?))
def searchResults(REQUEST=None, **kw):
"""
Invokes queryResults with the appropriate
ZSQL Method to return a list of results
"""
def countResults(REQUEST=None, **kw):
"""
Invokes queryResults with the appropriate
ZSQL Method to return a statistics for
a list of results
"""
def queryResults(sql_method, REQUEST=None, src__=0, build_sql_query_method=None, **kw):
"""
Return the result of the given 'sql_method' ZSQL Method after
processing all parameters to build a Query object passed to
that method.
The implementation should do the following.
1- Use **kw parameters to build a Query object
by invoking buildQuery
2- Build a ColumnMap instance by invoking
the buildColumnMap on the Query. Some
optmisation may happen here to try
to build the best possible ColumnMap and
use the best possible indices for joining.
During the ColumnMap build process, the
Search Key associated to each Query node
in the Query tree registers the columns
which are used (ex. to search) or provided
(ex. MATCH value for full text search,
interleave expression or parameter in a
UNION Query)
3- Render the query object as an SQLExpression
instance. This instance contains all necessary
parts to generate:
- where_expression
- sort_expression
- group_by_expression
- select_expression
4- Invoke sql_method
"""
def isAdvancedSearchText(search_text):
"""
Returns True if given value follows Search Text "advanced" syntax,
False otherwise.
"""
def parseSearchText(search_text, column=None, search_key=None, is_valid=None):
"""
Parses given SearchText expression using given column's parser
(determined by the SearchKey it is configured to use by default), or
given SearchKey name.
search_text (string)
SearchText to parse.
column (string)
Column to use to determine which SearchKey to use for parsing.
Either this parameter or search_key must be provided.
search_key (string)
Name of the SearchKey to use for parsing.
Either this parameter or column must be provided.
if_valid (callback)
Callback method to use to decide wether an encountered column-ish
identifier in SearchText is a valid column.
If not provided, catalog schema will be used.
"""
def isValidColumn(column_id):
"""
Returns wether given string is a known column.
Note: related keys and scriptable keys are considered columns.
"""
##############################################################################
#
# Copyright (c) 2002-2009 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
# Vincent Pelletier <vincent@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 Products.ZSQLCatalog.interfaces.node import INode
class IValueNode(INode):
"""
Value- and comparison-operator-containig node.
They are leaf nodes in the syntax tree.
"""
def getValue():
"""
Returns node's value.
"""
def getComparisonOperator():
"""
Returns node's comparison operator.
"""
# This file is kept for backward compatibility only
from Products.Zelenium.interfaces.zuite import IZuite
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