Commit 9e5cb6bb authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

try to match by 'order' value first, and then try to match by using divergence testers.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31296 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3f7e9d60
...@@ -157,6 +157,25 @@ class RuleMixin: ...@@ -157,6 +157,25 @@ class RuleMixin:
self._getMovementGeneratorContext(context), self._getMovementGeneratorContext(context),
movement_list=self._getMovementGeneratorMovementList(), rounding=rounding) movement_list=self._getMovementGeneratorMovementList(), rounding=rounding)
# Prepare a mapping between prevision and decision
# The prevision_to_decision_map is a list of tuples
# of the form (prevision_movement_dict, list of decision_movement)
prevision_to_decision_map = []
# XXX First we try to match by 'order' value if possible.
matched_prevision_list = []
matched_decision_list = []
prevision_order_dict = dict(
(x.getOrder(), x) for x in prevision_movement_list)
for decision_movement in decision_movement_list:
prevision_movement = prevision_order_dict.get(
decision_movement.getOrder(), None)
if prevision_movement is not None:
prevision_to_decision_map.append(
(prevision_movement, [decision_movement]))
matched_prevision_list.append(prevision_movement)
matched_decision_list.append(decision_movement)
# Get divergence testers # Get divergence testers
tester_list = self._getMatchingTesterList() tester_list = self._getMatchingTesterList()
if len(tester_list) == 0: if len(tester_list) == 0:
...@@ -165,6 +184,8 @@ class RuleMixin: ...@@ -165,6 +184,8 @@ class RuleMixin:
# Create small groups of movements per hash keys # Create small groups of movements per hash keys
decision_movement_dict = {} decision_movement_dict = {}
for movement in decision_movement_list: for movement in decision_movement_list:
if movement in matched_decision_list:
continue
tester_key = [] tester_key = []
for tester in tester_list: for tester in tester_list:
if tester.test(movement): if tester.test(movement):
...@@ -175,6 +196,8 @@ class RuleMixin: ...@@ -175,6 +196,8 @@ class RuleMixin:
decision_movement_dict.setdefault(tester_key, []).append(movement) decision_movement_dict.setdefault(tester_key, []).append(movement)
prevision_movement_dict = {} prevision_movement_dict = {}
for movement in prevision_movement_list: for movement in prevision_movement_list:
if movement in matched_prevision_list:
continue
tester_key = [] tester_key = []
for tester in tester_list: for tester in tester_list:
if tester.test(movement): if tester.test(movement):
...@@ -184,11 +207,6 @@ class RuleMixin: ...@@ -184,11 +207,6 @@ class RuleMixin:
tester_key = tuple(tester_key) tester_key = tuple(tester_key)
prevision_movement_dict.setdefault(tester_key, []).append(movement) prevision_movement_dict.setdefault(tester_key, []).append(movement)
# Prepare a mapping between prevision and decision
# The prevision_to_decision_map is a list of tuples
# of the form (prevision_movement_dict, list of decision_movement)
prevision_to_decision_map = []
# First find out all existing (decision) movements which belong to no group # First find out all existing (decision) movements which belong to no group
no_group_list = [] no_group_list = []
for tester_key in decision_movement_dict.keys(): for tester_key in decision_movement_dict.keys():
...@@ -217,6 +235,7 @@ class RuleMixin: ...@@ -217,6 +235,7 @@ class RuleMixin:
map_list = [] map_list = []
for decision_movement in decision_movement_dict.get(tester_key, ()): for decision_movement in decision_movement_dict.get(tester_key, ()):
if _compare(tester_list, prevision_movement, decision_movement): if _compare(tester_list, prevision_movement, decision_movement):
# XXX is it OK to have more than 2 decision_movements?
map_list.append(decision_movement) map_list.append(decision_movement)
prevision_to_decision_map.append((prevision_movement, map_list)) prevision_to_decision_map.append((prevision_movement, map_list))
......
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