MovementGroup.py 19.5 KB
Newer Older
Sebastien Robin's avatar
Sebastien Robin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
#                    Sebastien Robin <seb@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.
#
##############################################################################

"""
Define in this class all classes intended to group every kind of movement
"""

from Products.ERP5Type.Base import Base
Sebastien Robin's avatar
Sebastien Robin committed
34
from Products.ERP5Type.Document.Folder import Folder
Sebastien Robin's avatar
Sebastien Robin committed
35 36
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from AccessControl import ClassSecurityInfo
Sebastien Robin's avatar
Sebastien Robin committed
37 38 39
from Globals import InitializeClass, DTMLFile
from Products.CMFCategory.Category import Category
from zLOG import LOG
Sebastien Robin's avatar
Sebastien Robin committed
40

Sebastien Robin's avatar
Sebastien Robin committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
manage_addRootMovementGroupForm=DTMLFile('dtml/SimulationTool_addRootMovementGroup', globals())

def addRootMovementGroup( self, id, title='', REQUEST=None ):
    """
        Add a new Order Movement
    """
    sf = RootMovementGroup( id )
    sf._setTitle(title)
    self._setObject( id, sf )
    sf = self._getOb( id )
    sf.reindexObject()
    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)

class RootMovementGroup(Folder):
Sebastien Robin's avatar
Sebastien Robin committed
56 57 58 59 60 61

  meta_type = 'ERP5 Root Movement Group'
  portal_type = 'Root Movement Group'
  add_permission = Permissions.AddPortalContent
  isPortalContent = 1
  isRADContent = 1
Sebastien Robin's avatar
Sebastien Robin committed
62
  icon = 'portal.gif'
Sebastien Robin's avatar
Sebastien Robin committed
63 64 65 66 67

  # Declarative security
  security = ClassSecurityInfo()
  security.declareObjectProtected(Permissions.View)

Sebastien Robin's avatar
Sebastien Robin committed
68 69 70 71 72 73 74 75 76 77
  # Declarative constructors
  constructors =   (manage_addRootMovementGroupForm, addRootMovementGroup,)

  property_sheets = ( PropertySheet.Base,
                      PropertySheet.DublinCore,
                    )

  def getNestedClass(self, check_list):
    if len(check_list)>0:
      return check_list[0]
Sebastien Robin's avatar
Sebastien Robin committed
78 79
    return None

Sebastien Robin's avatar
Sebastien Robin committed
80
  def setNestedClass(self,check_list=None):
Sebastien Robin's avatar
Sebastien Robin committed
81 82 83 84
    """
      This sets an appropriate nested class.
    """
    
Sebastien Robin's avatar
Sebastien Robin committed
85 86 87 88 89 90
    LOG('RootGroup.setNestedClass, check_list:',0,check_list)
    for i in range(len(check_list)):
      LOG('RootGroup.setNestedClass, check_list[i]:',0,check_list[i])
      LOG('RootGroup.setNestedClass, check_list[i].getId():',0,check_list[i].getId())
      LOG('RootGroup.setNestedClass, self.getId():',0,self.getId())
      if check_list[i].getId() == self.getId():
Sebastien Robin's avatar
Sebastien Robin committed
91 92 93 94
        break
    else:
      raise RuntimeError, "no appropriate nested class is found for %s" % str(self)

Sebastien Robin's avatar
Sebastien Robin committed
95
    self.nested_class = self.getNestedClass(check_list[i+1:])
Sebastien Robin's avatar
Sebastien Robin committed
96

Sebastien Robin's avatar
Sebastien Robin committed
97
  def initialize(self, movement=None,check_list=None):
Sebastien Robin's avatar
Sebastien Robin committed
98
    self.nested_class = None
Sebastien Robin's avatar
Sebastien Robin committed
99
    self.setNestedClass(check_list=check_list)
Sebastien Robin's avatar
Sebastien Robin committed
100 101 102
    self.movement_list = []
    self.group_list = []
    if movement is not None :
Sebastien Robin's avatar
Sebastien Robin committed
103
      self.append(movement,check_list=check_list)
Sebastien Robin's avatar
Sebastien Robin committed
104

Sebastien Robin's avatar
Sebastien Robin committed
105
  def appendGroup(self, movement,check_list=None):
Sebastien Robin's avatar
Sebastien Robin committed
106
    if self.nested_class is not None:
Sebastien Robin's avatar
Sebastien Robin committed
107 108 109
      LOG('RootGroup.appendGroup, check_list',0,check_list)
      nested_instance = self.nested_class.getInstance(movement=movement,check_list=check_list)
      self.group_list.append(nested_instance)
Sebastien Robin's avatar
Sebastien Robin committed
110

Sebastien Robin's avatar
Sebastien Robin committed
111
  def append(self,movement,check_list=None):
Sebastien Robin's avatar
Sebastien Robin committed
112 113 114 115 116 117 118 119
    self.movement_list.append(movement)
    movement_in_group = 0
    for group in self.group_list :
      if group.test(movement) :
        group.append(movement)
        movement_in_group = 1
        break
    if movement_in_group == 0 :
Sebastien Robin's avatar
Sebastien Robin committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
      LOG('RootGroup.append, check_list',0,check_list)
      self.appendGroup(movement,check_list=check_list)

  def getInstance(self,movement=None,check_list=None):
    group = RootMovementGroup('root_movement_group')
    # We should append self to the check_list
    check_list = [self] + check_list
    group.initialize(movement=movement,check_list=check_list)
    return group

manage_addOrderMovementGroupForm=DTMLFile('dtml/SimulationTool_addOrderMovementGroup', globals())

def addOrderMovementGroup( self, id, title='', REQUEST=None ):
    """
        Add a new Order Movement
    """
    sf = OrderMovementGroup( id )
    sf._setTitle(title)
    self._setObject( id, sf )
    sf = self._getOb( id )
    sf.reindexObject()
    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)
Sebastien Robin's avatar
Sebastien Robin committed
143

Sebastien Robin's avatar
Sebastien Robin committed
144
class OrderMovementGroup(RootMovementGroup,Folder):
Sebastien Robin's avatar
Sebastien Robin committed
145 146 147

  meta_type = 'ERP5 Order Movement Group'
  portal_type = 'Order Movement Group'
Sebastien Robin's avatar
Sebastien Robin committed
148 149 150 151 152 153 154
  add_permission = Permissions.AddPortalContent
  isPortalContent = 1
  isRADContent = 1
  icon = 'portal.gif'

  # Declarative constructors
  constructors =   (manage_addOrderMovementGroupForm, addOrderMovementGroup,)
Sebastien Robin's avatar
Sebastien Robin committed
155

Sebastien Robin's avatar
Sebastien Robin committed
156 157 158 159 160 161 162
  property_sheets = ( PropertySheet.Base,
                      PropertySheet.DublinCore,
                    )

  def initialize(self,movement,**kw):
    LOG('OrderMovementGroup.initialize, kw:',0,kw)
    RootMovementGroup.initialize(self,movement,**kw)
Sebastien Robin's avatar
Sebastien Robin committed
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
    if hasattr(movement, 'getRootAppliedRule'):
      # This is a simulation movement
      order_value = movement.getRootAppliedRule().getCausalityValue(
                                                portal_type=order_type_list)
      if order_value is None:
        # In some cases (ex. DeliveryRule), there is no order
        # we may consider a PackingList as the order in the OrderGroup
        order_value = movement.getRootAppliedRule().getCausalityValue(
                        portal_type=delivery_type_list)
    else:
      # This is a temp movement
      order_value = None
    if order_value is None:
      order_relative_url = None
    else:
      # get the id of the enclosing delivery
      # for this cell or line
      order_relative_url = order_value.getRelativeUrl()
    self.order = order_relative_url

  def test(self,movement):
    if hasattr(movement, 'getRootAppliedRule'):
      order_value = movement.getRootAppliedRule().getCausalityValue(
                                                  portal_type=order_type_list)

      if order_value is None:
        # In some cases (ex. DeliveryRule), there is no order
        # we may consider a PackingList as the order in the OrderGroup
        order_value = movement.getRootAppliedRule().getCausalityValue(
                        portal_type=delivery_type_list)
    else:
      # This is a temp movement
      order_value = None
    if order_value is None:
      order_relative_url = None
    else:
      # get the id of the enclosing delivery
      # for this cell or line
      order_relative_url = order_value.getRelativeUrl()
    if order_relative_url == self.order:
      return 1
    else :
      return 0

Sebastien Robin's avatar
Sebastien Robin committed
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
  def getInstance(self,movement=None,check_list=None):
    group = OrderMovementGroup('order_movement_group')
    LOG('OrderGroup.getInstance, check_list:',0,check_list)
    group.initialize(movement=movement,check_list=check_list)
    return group

manage_addPathMovementGroupForm=DTMLFile('dtml/SimulationTool_addPathMovementGroup', globals())

def addPathMovementGroup( self, id, title='', REQUEST=None ):
    """
        Add a new Order Movement
    """
    sf = PathMovementGroup( id )
    sf._setTitle(title)
    self._setObject( id, sf )
    sf = self._getOb( id )
    sf.reindexObject()
    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)

class PathMovementGroup(RootMovementGroup,Folder):
Sebastien Robin's avatar
Sebastien Robin committed
228 229 230

  meta_type = 'ERP5 Path Movement Group'
  portal_type = 'Path Movement Group'
Sebastien Robin's avatar
Sebastien Robin committed
231 232 233 234 235 236 237
  add_permission = Permissions.AddPortalContent
  isPortalContent = 1
  isRADContent = 1
  icon = 'portal.gif'

  # Declarative constructors
  constructors =   (manage_addPathMovementGroupForm, addPathMovementGroup,)
Sebastien Robin's avatar
Sebastien Robin committed
238

Sebastien Robin's avatar
Sebastien Robin committed
239 240 241 242 243 244
  property_sheets = ( PropertySheet.Base,
                      PropertySheet.DublinCore,
                    )

  def initialize(self,movement,**kw):
    RootMovementGroup.initialize(self,movement,**kw)
Sebastien Robin's avatar
Sebastien Robin committed
245
    self.source = movement.getSource()
Sebastien Robin's avatar
Sebastien Robin committed
246
    LOG('PathGroup.initialize source',0,self.source)
Sebastien Robin's avatar
Sebastien Robin committed
247
    self.destination = movement.getDestination()
Sebastien Robin's avatar
Sebastien Robin committed
248
    LOG('PathGroup.initialize destination',0,self.destination)
Sebastien Robin's avatar
Sebastien Robin committed
249
    self.source_section = movement.getSourceSection()
Sebastien Robin's avatar
Sebastien Robin committed
250
    LOG('PathGroup.initialize source_section',0,self.source_section)
Sebastien Robin's avatar
Sebastien Robin committed
251
    self.destination_section = movement.getDestinationSection()
Sebastien Robin's avatar
Sebastien Robin committed
252
    LOG('PathGroup.initialize destination_section',0,self.destination_section)
Sebastien Robin's avatar
Sebastien Robin committed
253
    self.target_source = movement.getTargetSource()
Sebastien Robin's avatar
Sebastien Robin committed
254
    LOG('PathGroup.initialize target_source',0,self.target_source)
Sebastien Robin's avatar
Sebastien Robin committed
255
    self.target_destination = movement.getTargetDestination()
Sebastien Robin's avatar
Sebastien Robin committed
256
    LOG('PathGroup.initialize target_destination',0,self.target_destination)
Sebastien Robin's avatar
Sebastien Robin committed
257
    self.target_source_section = movement.getTargetSourceSection()
Sebastien Robin's avatar
Sebastien Robin committed
258
    LOG('PathGroup.initialize target_source_section',0,self.target_source_section)
Sebastien Robin's avatar
Sebastien Robin committed
259
    self.target_destination_section = movement.getTargetDestinationSection()
Sebastien Robin's avatar
Sebastien Robin committed
260
    LOG('PathGroup.initialize target_destination_section',0,self.target_destination_section)
Sebastien Robin's avatar
Sebastien Robin committed
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276


  def test(self,movement):
    if movement.getSource() == self.source and \
      movement.getDestination() == self.destination and \
      movement.getSourceSection() == self.source_section and \
      movement.getDestinationSection() == self.destination_section and \
      movement.getTargetSource() == self.target_source and \
      movement.getTargetDestination() == self.target_destination and \
      movement.getTargetSourceSection() == self.target_source_section and \
      movement.getTargetDestinationSection() == self.target_destination_section :

      return 1
    else :
      return 0

Sebastien Robin's avatar
Sebastien Robin committed
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
  def getInstance(self,movement=None,check_list=None):
    group =  PathMovementGroup('path_movement_group')
    LOG('PathGroup.getInstance, check_list:',0,check_list)
    group.initialize(movement=movement,check_list=check_list)
    return group

manage_addDateMovementGroupForm=DTMLFile('dtml/SimulationTool_addDateMovementGroup', globals())

def addDateMovementGroup( self, id, title='', REQUEST=None ):
    """
        Add a new Order Movement
    """
    sf = DateMovementGroup( id )
    sf._setTitle(title)
    self._setObject( id, sf )
    sf = self._getOb( id )
    sf.reindexObject()
    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)

class DateMovementGroup(RootMovementGroup,Folder):
Sebastien Robin's avatar
Sebastien Robin committed
298 299 300

  meta_type = 'ERP5 Date Movement Group'
  portal_type = 'Date Movement Group'
Sebastien Robin's avatar
Sebastien Robin committed
301 302 303 304 305 306 307
  add_permission = Permissions.AddPortalContent
  isPortalContent = 1
  isRADContent = 1
  icon = 'portal.gif'

  # Declarative constructors
  constructors =   (manage_addDateMovementGroupForm, addDateMovementGroup,)
Sebastien Robin's avatar
Sebastien Robin committed
308

Sebastien Robin's avatar
Sebastien Robin committed
309 310 311 312 313 314
  property_sheets = ( PropertySheet.Base,
                      PropertySheet.DublinCore,
                    )

  def initialize(self,movement,**kw):
    RootMovementGroup.initialize(self,movement,**kw)
Sebastien Robin's avatar
Sebastien Robin committed
315 316 317 318 319 320 321 322 323 324 325 326
    self.target_start_date = movement.getTargetStartDate()
    self.target_stop_date = movement.getTargetStopDate()
    self.start_date = movement.getStartDate()
    self.stop_date = movement.getStopDate()

  def test(self,movement):
    if movement.getStartDate() == self.start_date and \
      movement.getStopDate() == self.stop_date :
      return 1
    else :
      return 0

Sebastien Robin's avatar
Sebastien Robin committed
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
  def getInstance(self,movement=None,check_list=None):
    group = DateMovementGroup('date_movement_group')
    group.initialize(movement=movement,check_list=check_list)
    return group

manage_addCriterionMovementGroupForm=DTMLFile('dtml/SimulationTool_addCriterionMovementGroup', globals())

def addCriterionMovementGroup( self, id, title='', REQUEST=None ):
    """
        Add a new Order Movement
    """
    sf = CriterionMovementGroup( id )
    sf._setTitle(title)
    self._setObject( id, sf )
    sf = self._getOb( id )
    sf.reindexObject()
    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)

class CriterionMovementGroup(RootMovementGroup,Folder):
Sebastien Robin's avatar
Sebastien Robin committed
347 348 349

  meta_type = 'ERP5 Criterion Movement Group'
  portal_type = 'Criterion Movement Group'
Sebastien Robin's avatar
Sebastien Robin committed
350 351 352 353
  add_permission = Permissions.AddPortalContent
  isPortalContent = 1
  isRADContent = 1
  icon = 'portal.gif'
Sebastien Robin's avatar
Sebastien Robin committed
354

Sebastien Robin's avatar
Sebastien Robin committed
355 356 357 358 359 360 361 362 363
  # Declarative constructors
  constructors =   (manage_addCriterionMovementGroupForm, addCriterionMovementGroup,)

  property_sheets = ( PropertySheet.Base,
                      PropertySheet.DublinCore,
                    )

  def initialize(self,movement,**kw):
    RootMovementGroup.initialize(self,movement,**kw)
Sebastien Robin's avatar
Sebastien Robin committed
364 365 366 367 368 369 370 371 372 373 374 375 376
    if hasattr(movement, 'getGroupCriterion'):
      self.criterion = movement.getGroupCriterion()
    else:
      self.criterion = None

  def test(self,movement):
    # we must have the same criterion
    if hasattr(movement, 'getGroupCriterion'):
      criterion = movement.getGroupCriterion()
    else:
      criterion = None
    return self.criterion == criterion

Sebastien Robin's avatar
Sebastien Robin committed
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
  def getInstance(self,movement=None,check_list=None):
    group = CriterionMovementGroup('criterion_movement_group')
    group.initialize(movement=movement,check_list=check_list)
    return group

manage_addResourceMovementGroupForm=DTMLFile('dtml/SimulationTool_addResourceMovementGroup', globals())

def addResourceMovementGroup( self, id, title='', REQUEST=None ):
    """
        Add a new Order Movement
    """
    sf = ResourceMovementGroup( id )
    sf._setTitle(title)
    self._setObject( id, sf )
    sf = self._getOb( id )
    sf.reindexObject()
    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)

class ResourceMovementGroup(RootMovementGroup,Base):
Sebastien Robin's avatar
Sebastien Robin committed
397 398 399

  meta_type = 'ERP5 Resource Movement Group'
  portal_type = 'Resource Movement Group'
Sebastien Robin's avatar
Sebastien Robin committed
400 401 402 403
  add_permission = Permissions.AddPortalContent
  isPortalContent = 1
  isRADContent = 1
  icon = 'portal.gif'
Sebastien Robin's avatar
Sebastien Robin committed
404

Sebastien Robin's avatar
Sebastien Robin committed
405 406 407 408 409 410 411 412 413
  # Declarative constructors
  constructors =   (manage_addResourceMovementGroupForm, addResourceMovementGroup,)

  property_sheets = ( PropertySheet.Base,
                      PropertySheet.DublinCore,
                    )

  def initialize(self,movement,**kw):
    RootMovementGroup.initialize(self,movement,**kw)
Sebastien Robin's avatar
Sebastien Robin committed
414 415 416 417 418 419 420 421
    self.resource = movement.getResource()

  def test(self,movement):
    if movement.getResource() == self.resource :
      return 1
    else :
      return 0

Sebastien Robin's avatar
Sebastien Robin committed
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
  def getInstance(self,movement=None,check_list=None):
    group = ResourceMovementGroup('resource_movement_group')
    group.initialize(movement=movement,check_list=check_list)
    return group

manage_addBaseVariantMovementGroupForm=DTMLFile('dtml/SimulationTool_addBaseVariantMovementGroup', globals())

def addBaseVariantMovementGroup( self, id, title='', REQUEST=None ):
    """
        Add a new Order Movement
    """
    sf = BaseVariantMovementGroup( id )
    sf._setTitle(title)
    self._setObject( id, sf )
    sf = self._getOb( id )
    sf.reindexObject()
    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)

class BaseVariantMovementGroup(RootMovementGroup,Folder):
Sebastien Robin's avatar
Sebastien Robin committed
442 443 444

  meta_type = 'ERP5 Base Variant Movement Group'
  portal_type = 'Base Variant Movement Group'
Sebastien Robin's avatar
Sebastien Robin committed
445 446 447 448 449 450 451 452 453 454 455
  add_permission = Permissions.AddPortalContent
  isPortalContent = 1
  isRADContent = 1
  icon = 'portal.gif'

  # Declarative constructors
  constructors =   (manage_addBaseVariantMovementGroupForm, addBaseVariantMovementGroup,)

  property_sheets = ( PropertySheet.Base,
                      PropertySheet.DublinCore,
                    )
Sebastien Robin's avatar
Sebastien Robin committed
456

Sebastien Robin's avatar
Sebastien Robin committed
457 458
  def initialize(self,movement,**kw):
    RootMovementGroup.initialize(self,movement,**kw)
Sebastien Robin's avatar
Sebastien Robin committed
459 460
    self.base_category_list = movement.getVariationBaseCategoryList()
    if self.base_category_list is None:
Sebastien Robin's avatar
Sebastien Robin committed
461
      LOG('BaseVariantGroup initialize', 0, 'movement = %s, movement.showDict() = %s' % (repr(movement), repr(movement.showDict())))
Sebastien Robin's avatar
Sebastien Robin committed
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
      self.base_category_list = []

  def test(self,movement):
    # we must have the same number of categories
    categories_identity = 0
    #LOG('BaseVariantGroup', 0, 'self.base_category_list = %s, movement = %s, movement.getVariationBaseCategoryList() = %s' % (repr(self.base_category_list), repr(movement), repr(movement.getVariationBaseCategoryList())))
    movement_base_category_list = movement.getVariationBaseCategoryList()
    if movement_base_category_list is None:
      LOG('BaseVariantGroup test', 0, 'movement = %s, movement.showDict() = %s' % (repr(movement), repr(movement.showDict())))
      movement_base_category_list = []
    if len(self.base_category_list) == len(movement_base_category_list):
      for category in movement_base_category_list:
        if not category in self.base_category_list :
          break
      else :
        categories_identity = 1
    return categories_identity

Sebastien Robin's avatar
Sebastien Robin committed
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
  def getInstance(self,movement=None,check_list=None):
    group = BaseVariantMovementGroup('base_variant_movement_group')
    group.initialize(movement=movement,check_list=check_list)
    return group

manage_addVariantMovementGroupForm=DTMLFile('dtml/SimulationTool_addVariantMovementGroup', globals())

def addVariantMovementGroup( self, id, title='', REQUEST=None ):
    """
        Add a new Order Movement
    """
    sf = VariantMovementGroup( id )
    sf._setTitle(title)
    self._setObject( id, sf )
    sf = self._getOb( id )
    sf.reindexObject()
    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)

class VariantMovementGroup(RootMovementGroup,Folder):
Sebastien Robin's avatar
Sebastien Robin committed
500 501 502

  meta_type = 'ERP5 Variant Movement Group'
  portal_type = 'Variant Movement Group'
Sebastien Robin's avatar
Sebastien Robin committed
503 504 505 506 507 508 509
  add_permission = Permissions.AddPortalContent
  isPortalContent = 1
  isRADContent = 1
  icon = 'portal.gif'

  # Declarative constructors
  constructors =   (manage_addVariantMovementGroupForm, addVariantMovementGroup,)
Sebastien Robin's avatar
Sebastien Robin committed
510

Sebastien Robin's avatar
Sebastien Robin committed
511 512 513 514 515 516
  property_sheets = ( PropertySheet.Base,
                      PropertySheet.DublinCore,
                    )

  def initialize(self,movement,**kw):
    RootMovementGroup.initialize(self,movement,**kw)
Sebastien Robin's avatar
Sebastien Robin committed
517 518
    self.category_list = movement.getVariationCategoryList()
    if self.category_list is None:
Sebastien Robin's avatar
Sebastien Robin committed
519
      LOG('VariantGroup initialize', 0, 'movement = %s, movement.showDict() = %s' % (repr(movement), repr(movement.showDict())))
Sebastien Robin's avatar
Sebastien Robin committed
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535
      self.category_list = []

  def test(self,movement):
    # we must have the same number of categories
    categories_identity = 0
    movement_category_list = movement.getVariationCategoryList()
    if movement_category_list is None:
      LOG('VariantGroup test', 0, 'movement = %s, movement.showDict() = %s' % (repr(movement), repr(movement.showDict())))
      movement_category_list = []
    if len(self.category_list) == len(movement_category_list):
      for category in movement_category_list:
        if not category in self.category_list :
          break
      else :
        categories_identity = 1
    return categories_identity
Sebastien Robin's avatar
Sebastien Robin committed
536 537 538 539 540 541 542 543 544 545 546 547 548

  def getInstance(self,movement=None,check_list=None):
    group = VariantMovementGroup('variant_movement_group')
    group.initialize(movement=movement,check_list=check_list)
    return group

InitializeClass( RootMovementGroup )
InitializeClass( OrderMovementGroup )
InitializeClass( PathMovementGroup )
InitializeClass( DateMovementGroup )
InitializeClass( CriterionMovementGroup )
InitializeClass( VariantMovementGroup )
InitializeClass( BaseVariantMovementGroup )