variated.py 8.03 KB
Newer Older
Jean-Paul Smets's avatar
Jean-Paul Smets committed
1
# -*- coding: utf-8 -*-
2 3
##############################################################################
#
4
# Copyright (c) 2002-2010 Nexedi SA and Contributors. All Rights Reserved.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#                    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.
#
##############################################################################
29 30 31
"""
Products.ERP5.interfaces.variated
"""
32

Jean-Paul Smets's avatar
Jean-Paul Smets committed
33
from zope.interface import Interface
34

35
class IVariated(Interface):
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
  """IVariated interface specification

  IVariated defines methods to access and modify
  discrete variations (categories) and variation
  properties. It also provides variation range methods
  which are often invoked from variated objects.

  IVariated is normally used to specify discrete variations
  of a movement.

  IVariated is also used on all objects which define
  a variation range, such as Resources, Delivery Lines
  which contain Delivery Cells. In this case, categories
  specify a subset of the total variation range, rather
  than a specific discrete variation.
51 52 53 54 55 56 57
  """

  # The following methods are intended to access to the
  # variation value of a variated object. Discrete variations
  # are based on categories. General variations are encapsulated
  # into VariationValue instances.

Jean-Paul Smets's avatar
Jean-Paul Smets committed
58 59 60 61 62 63 64 65 66
  # Property Variation Accessors
  def getVariationPropertyList():
    """
    return the list of variation property IDs which are provided
    by the variated instance.

    Used in: Resource, Delivery Line, Delivery Cell
    """

67 68 69 70 71 72 73 74 75 76 77 78
  # Discrete Variation Accessors
  def getVariationBaseCategoryList(omit_optional_variation=0,
                                   omit_individual_variation=0):
    """
    returns a list of base category ids which are used
    to define discrete variation dimensions for this instance

    Used in: Resource, Delivery Line, Delivery Cell

    omit_optional_variation -- 

    omit_individual_variation --
79
    """
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98

  def getVariationBaseCategoryItemList(self, display_id='title_or_id',
        omit_optional_variation=0, omit_individual_variation=0):
    """
    returns a list of (base_category.id, base_category.display_id())
    which can be displayed in an ERP5 Form and define 
    to define discrete variation dimensions for this instance

    Used in: Resource, Delivery Line, Delivery Cell

    display_id -- 

    omit_optional_variation -- 

    omit_individual_variation --
    """

  def getVariationCategoryList(self, base_category_list=(),
        omit_optional_variation=0, omit_individual_variation=0):
99
    """
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
    returns a list or relative URLs which defines
    a discrete variation (ie. a list of category
    memberships)

    Used in: Resource, Delivery Line, Delivery Cell

    base_category_list --

    omit_optional_variation -- 

    omit_individual_variation --
    """

  def setVariationCategoryList(node_list, base_category_list=()):
    """
    modifies the discrete variation of a variated instance by
    providing a list of relative URLs

    Used in: Resource, Delivery Line, Delivery Cell

    base_category_list --
    """

  def getVariationCategoryItemList(base_category_list=(), base=1,
        display_id='logical_path', display_base_category=1,
        current_category=None, omit_optional_variation=0,
        omit_individual_variation=0, **kw):
    """
    returns a list of (category.getRelativeUrl(), category.display_id())
    which define the discrete variations  of a variated instance
    in a way which be displayed in an ERP5 Form.

    Used in: Resource, Delivery Line, Delivery Cell

    base_category_list --

    base --
137

138 139 140 141 142 143 144 145 146 147 148 149 150
    display_id --

    display_base_category --

    base_category_list --

    current_category --

    omit_optional_variation --

    omit_individual_variation --

    **kw -- 
151
    """
152 153 154

  # Discrete Variation Range Accessors
  def getVariationRangeBaseCategoryList():
155
    """
156 157
    returns a list of base categories which are acceptable
    as discrete variation dimensions
158

159
    Used in: Resource, Delivery Line, Delivery Cell
160
    """
161 162 163

  def getVariationRangeBaseCategoryItemList(base=1, 
                                            display_id='getTitle'):
164
    """
165 166 167 168 169
    returns a list of (base_category.id, base_category.display_id())
    which are acceptable as discrete variation dimensions of
    the variated instance and are easy to display in an ERP5Form
    
    Used in: Resource, Delivery Line, Delivery Cell
170

171
    display_id --
172
    """
173 174 175

  def getVariationRangeCategoryList(base_category_list=(), base=1,
        root=1, current_category=None, omit_individual_variation=0):
176
    """
177 178 179 180 181 182 183 184
    returns a list of categories which are acceptable
    as discrete variation values of the current variated instance

    Used in: Resource, Delivery Line, Delivery Cell

    base_category_list -- 

    base -- 
185

186 187 188 189 190
    root -- 

    current_category -- 

    omit_individual_variation -- 
191
    """
192 193 194 195

  def getVariationRangeCategoryItemList(base_category_list=(), base=1, 
        root=1, display_method_id='getCategoryChildLogicalPathItemList',
        display_base_category=1, current_category=None, **kw):
196
    """
197 198 199 200 201
    returns a list of (category.id, category.display_id()) which are acceptable
    as discrete variation values. This is mostly useful in ERP5Form 
    instances to generate selection menus.

    Used in: Resource, Delivery Line, Delivery Cell
202

203 204 205 206 207 208 209 210 211 212 213 214 215
    base_category_list -- 

    base -- 

    root -- 

    display_method_id -- 

    display_base_category -- 

    current_category -- 

    **kw --
216
    """
217 218 219

  # Variated Value API
  def setVariated(variated):
220
    """
221 222 223
    Sets all variation categories and properties of the current
    variated instance to the categories and properties of
    variated instance provided as parameter.
224

225
    Used in: Resource, Delivery Line, Delivery Cell
226

227 228
    variated -- 
    """
229

230 231 232 233 234 235
  def compareVariated(variated):
    """
    Compares current variated instance with another
    variated instance provided as parameter.

    Used in: Resource, Delivery Line, Delivery Cell
236

237
    variated --     
238
    """
239 240 241

  # Serialization API
  def getVariationText(self):
242
    """
243 244 245
    returns a human readable, computer parsable,
    non ambiguous string representation of the variation
    categories and properties of the current instance.
246

247
    Used in: Delivery Line (terminal), Delivery Cell
248
    """
249 250

  def setVariationText(variation_text):
251
    """
252 253
    parses variation_text to set variation properties
    and categories of the current instance
254

255 256
    Used in: Delivery Line (terminal), Delivery Cell
    Could be used in: Resource, Delivery Line (non terminal)
257
    """
258

Jean-Paul Smets's avatar
Jean-Paul Smets committed
259
  def getVariationUid():
260
    """
261 262 263
    returns a unique UID integer representation of the variation
    categories and properties of the current instance based
    on a UID mapping of variation_text
264

265 266
    Used in: Delivery Line (terminal), Delivery Cell
    Could be used in: Resource, Delivery Line (non terminal)
267
    """
268 269

  def setVariationUid(variation_uid):
270
    """
271 272 273 274 275
    sets variation properties and categories of the current instance
    by looking up variation to UID mapping

    Used in: Delivery Line (terminal), Delivery Cell
    Could be used in: Resource, Delivery Line (non terminal)
Jean-Paul Smets's avatar
Jean-Paul Smets committed
276
    """