Commit 58aa0461 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

set causality to Solver Decision in Target Solver documents under Solver Process.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32266 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 80bee45c
...@@ -85,6 +85,9 @@ class SolverProcess(XMLObject, ActiveProcess): ...@@ -85,6 +85,9 @@ class SolverProcess(XMLObject, ActiveProcess):
movement_dict = {} movement_dict = {}
types_tool = self.portal_types types_tool = self.portal_types
# XXX The following logic does not work if several testers handle
# the divergence for the same property.
# First create a mapping between delivery movements and solvers # First create a mapping between delivery movements and solvers
# in order to know for each movements which solvers are needed # in order to know for each movements which solvers are needed
# and which parameters with # and which parameters with
...@@ -99,18 +102,24 @@ class SolverProcess(XMLObject, ActiveProcess): ...@@ -99,18 +102,24 @@ class SolverProcess(XMLObject, ActiveProcess):
for movement in decision.getDeliveryValueList(): for movement in decision.getDeliveryValueList():
# Detect incompatibilities # Detect incompatibilities
movement_solver_dict = movement_dict.setdefault(movement.getRelativeUrl(), {}) movement_solver_dict = movement_dict.setdefault(movement.getRelativeUrl(), {})
movement_solver_configuration_dict = movement_solver_dict.setdefault(solver_type, {}) movement_solver_configuration_dict = movement_solver_dict.setdefault((solver_type, decision), {})
movement_solver_configuration_dict[solver_conviguration_key] = None movement_solver_configuration_dict[solver_conviguration_key] = None
# Second, make sure solvers do not conflict and configuration is valid # Second, make sure solvers do not conflict and configuration is valid
for movement_url, movement_solver_dict in movement_dict.items(): for movement_url, movement_solver_dict in movement_dict.items():
for solver_type, movement_solver_configuration_dict in movement_solver_dict.items(): for solver_info, movement_solver_configuration_dict in movement_solver_dict.items():
solver_type, decision = solver_info
solver = types_tool[solver_type] solver = types_tool[solver_type]
for other_solver_type in movement_solver_dict.keys(): for other_solver_info in movement_solver_dict.keys():
if other_solver_type == solver_type: if other_solver_info == solver_info:
continue continue
if solver.conflictsWithSolver(types_tool[other_solver_type]): # Try do detect conflict.
raise ValueError, "Solver %s conflicts with solver %s on movement %s" % (solver_type, other_solver_type, movement_url) # XXX it cannot be determined by solver portal type itself, but we
# need the information of testers.
# if solver.conflictsWithSolver(types_tool[other_solver_type]):
if set(decision.getCausalityValue().getTestedPropertyList).intersection(
set(other_solver_info[1].getCausalityValue().getTestedPropertyList)):
raise ValueError, "Solver %s for %s conflicts with solver %s for %s on movement %s" % (solver_type, decision.getTitle(), other_solver_info[0], other_solver_info[0].getCausalityTitle(), movement_url)
# Make sure multiple configuration are possible # Make sure multiple configuration are possible
try: try:
# Solver key contains only those properties which differentiate # Solver key contains only those properties which differentiate
...@@ -118,15 +127,17 @@ class SolverProcess(XMLObject, ActiveProcess): ...@@ -118,15 +127,17 @@ class SolverProcess(XMLObject, ActiveProcess):
solver_key = tuple(solver.reduceConfigurationList(movement_solver_configuration_dict.keys())) solver_key = tuple(solver.reduceConfigurationList(movement_solver_configuration_dict.keys()))
except: except:
raise raise
solver_key_dict = solver_dict.setdefault(solver_type, {}) solver_key_dict = solver_dict.setdefault(solver_info, {})
solver_movement_dict = solver_key_dict.setdefault(solver_key, {}) solver_movement_dict = solver_key_dict.setdefault(solver_key, {})
solver_movement_dict[movement_url] = movement_solver_configuration_dict.keys() solver_movement_dict[movement_url] = movement_solver_configuration_dict.keys()
# Third, build target solvers # Third, build target solvers
for solver_type, solver_key_dict in solver_dict.items(): for solver_info, solver_key_dict in solver_dict.items():
solver_type, decision = solver_info
for solver_key, solver_movement_dict in solver_key_dict.items(): for solver_key, solver_movement_dict in solver_key_dict.items():
solver_instance = self.newContent(portal_type=solver_type) solver_instance = self.newContent(portal_type=solver_type)
solver_instance._setDeliveryList(solver_movement_dict.keys()) solver_instance._setDeliveryList(solver_movement_dict.keys())
solver_instance.setCausalityValue(decision)
for movement_url, configuration_list in solver_movement_dict.iteritems(): for movement_url, configuration_list in solver_movement_dict.iteritems():
for configuration_kw in configuration_list: for configuration_kw in configuration_list:
if len(configuration_kw): if len(configuration_kw):
......
...@@ -30,4 +30,4 @@ ...@@ -30,4 +30,4 @@
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
class TargetSolver: class TargetSolver:
_categories = ('delivery',) _categories = ('delivery', 'causality')
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