Commit 53af2b82 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

rename from testToUpdate() to test().

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23669 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 971e9a13
......@@ -44,13 +44,6 @@ class BaseVariantMovementGroup(MovementGroup):
property_dict['_base_category_list'] = category_list
return property_dict
def test(self, object, property_dict):
category_list = object.getVariationBaseCategoryList()
if category_list is None:
category_list = []
category_list.sort()
return property_dict['_base_category_list'] == category_list
def testToUpdate(self, object, property_dict, **kw):
def test(self, object, property_dict, **kw):
# This movement group does not affect updating.
return True, {}
......@@ -41,7 +41,8 @@ class CategoryMovementGroup(PropertyMovementGroup):
def _getPropertyDict(self, movement, **kw):
property_dict = {}
for prop in self.getTestedPropertyList():
property_dict['%s_list' % prop] = movement.getPropertyList(prop, None)
property_dict['%s_list' % prop] = sorted(
movement.getPropertyList(prop, None))
return property_dict
def test(self, object, property_dict, property_list=None, **kw):
......@@ -51,7 +52,7 @@ class CategoryMovementGroup(PropertyMovementGroup):
else:
target_property_list = self.getTestedPropertyList()
for prop in target_property_list:
if sorted(property_dict['%s_list' % prop]) != \
if property_dict['%s_list' % prop] != \
sorted(object.getPropertyList(prop, None)):
return False
return True
return False, property_dict
return True, property_dict
......@@ -47,7 +47,7 @@ class CausalityAssignmentMovementGroup(MovementGroup):
self._addCausalityToEdit(movement, property_dict)
return [[movement_list, property_dict]]
def testToUpdate(self, movement, property_dict, **kw):
def test(self, movement, property_dict, **kw):
# We can always update.
return True, property_dict
......
......@@ -42,7 +42,7 @@ class CausalityMovementGroup(MovementGroup):
property_dict['_explanation'] = explanation_relative_url
return property_dict
def testToUpdate(self, movement, property_dict, **kw):
def test(self, movement, property_dict, **kw):
# we don't care the difference of explanation url when updating
#return True, property_dict
return True, {}
......
......@@ -54,6 +54,10 @@ class MovementGroup(XMLObject):
# This method should be defined in sub classes.
raise NotImplementedError
def test(self, object, property_dict, **kw):
# This method should be defined in sub classes.
raise NotImplementedError
def _separate(self, movement_list):
# By default, we separate movements by _getPropertyDict() values.
# You can override this method in each MovementGroup class.
......@@ -75,12 +79,3 @@ class MovementGroup(XMLObject):
return sorted([[sorted(x[0], lambda a,b:cmp(a.getId(), b.getId())), x[1]] \
for x in self._separate(movement_list)],
lambda a,b: cmp(a[0][0].getId(), b[0][0].getId()))
def test(self, object, property_dict, **kw):
raise NotImplementedError
def testToUpdate(self, object, property_dict, **kw):
if self.test(object, property_dict, **kw):
return True, property_dict
else:
return False, property_dict
......@@ -235,12 +235,12 @@ class OrderBuilder(XMLObject, Amount, Predicate):
my_root_group.append(movement_list)
return my_root_group
def _testToUpdate(self, instance, movement_group_list,
def _test(self, instance, movement_group_list,
divergence_list):
result = True
new_property_dict = {}
for movement_group in movement_group_list:
tmp_result, tmp_property_dict = movement_group.testToUpdate(
tmp_result, tmp_property_dict = movement_group.test(
instance, divergence_list)
if tmp_result == False:
result = tmp_result
......@@ -266,7 +266,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
instance_list.sort(lambda a,b:cmp(b.getId()==original_id,
a.getId()==original_id))
for instance_to_update in instance_list:
result, property_dict = self._testToUpdate(
result, property_dict = self._test(
instance_to_update, movement_group_list, divergence_list)
if result == True:
instance = instance_to_update
......
......@@ -44,7 +44,7 @@ class OrderMovementGroup(MovementGroup):
property_dict['causality'] = order_relative_url
return property_dict
def testToUpdate(self, movement, property_dict, **kw):
def test(self, movement, property_dict, **kw):
if movement.getCausality() == property_dict['causality']:
return True, property_dict
else:
......
......@@ -45,6 +45,9 @@ class ParentExplanationMovementGroup(MovementGroup):
property_dict['parent_explanation_value'] = parent_explanation_value
return property_dict
def test(self, object, property_dict, property_list=None, **kw):
return object.getParentExplanationValue() == \
property_dict['parent_explanation_value']
def test(self, object, property_dict, **kw):
if object.getParentExplanationValue() == \
property_dict['parent_explanation_value']:
return True, property_dict
else:
return False, property_dict
......@@ -52,5 +52,5 @@ class PropertyMovementGroup(MovementGroup):
target_property_list = self.getTestedPropertyList()
for prop in target_property_list:
if property_dict[prop] != object.getProperty(prop, None):
return False
return True
return False, property_dict
return True, property_dict
......@@ -65,17 +65,6 @@ class QuantitySignMovementGroup(MovementGroup):
]
def test(self, object, property_dict, **kw):
quantity = object.getQuantity()
sign1 = property_dict['quantity_sign']
sign2 = cmp(quantity, 0)
if sign2 == 0:
return 1
if sign1 == 0:
property_dict['quantity_sign'] = sign2
return 1
return sign1 == sign2
def testToUpdate(self, object, property_dict, **kw):
if object.getQuantitySign() == property_dict['quantity_sign']:
return True, property_dict
else:
......
......@@ -38,7 +38,7 @@ class RequirementMovementGroup(MovementGroup):
def _getPropertyDict(self, movement, **kw):
return {'requirement':self._getRequirementList(movement)}
def testToUpdate(self, movement, property_dict, **kw):
def test(self, movement, property_dict, **kw):
# We can always update
return True, property_dict
......
......@@ -44,7 +44,7 @@ class RootAppliedRuleCausalityMovementGroup(MovementGroup):
property_dict['root_causality_value_list'] = [root_causality_value]
return property_dict
def testToUpdate(self, movement, property_dict, **kw):
def test(self, movement, property_dict, **kw):
# We can always update
return True, property_dict
......
......@@ -38,7 +38,7 @@ class SplitMovementGroup(MovementGroup):
def _getPropertyDict(self, movement, **kw):
return {}
def testToUpdate(self, object, property_dict, **kw):
def test(self, object, property_dict, **kw):
return True, property_dict
def _separate(self, movement_list):
......
......@@ -41,9 +41,6 @@ class TitleMovementGroup(MovementGroup):
return property_dict
def test(self, object, property_dict, **kw):
return self._getTitle(object) == property_dict['title']
def testToUpdate(self, object, property_dict, **kw):
# If title is different, we want to update existing object instead
# of creating a new one.
return True, property_dict
......
......@@ -49,4 +49,7 @@ class VariantMovementGroup(MovementGroup):
if category_list is None:
category_list = []
category_list.sort()
return property_dict['variation_category_list'] == category_list
if property_dict['variation_category_list'] == category_list:
return True, property_dict
else:
return False, property_dict
......@@ -132,7 +132,7 @@ class MovementGroupNode:
else:
return movement
def testToUpdate(self, movement, divergence_list):
def test(self, movement, divergence_list):
# Try to check if movement is updatable or not.
#
# 1. if Divergence has no scope: update anyway.
......@@ -155,7 +155,7 @@ class MovementGroupNode:
if not len(related_divergence_list):
return True, {}
property_list = [x.tested_property for x in related_divergence_list]
return self._movement_group.testToUpdate(movement, self._property_dict,
return self._movement_group.test(movement, self._property_dict,
property_list=property_list)
else:
return True, {}
......
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