diff --git a/product/ERP5/Document/SolverProcess.py b/product/ERP5/Document/SolverProcess.py index 0c9d20c87751bdc66efe680eb440237b1bd10b03..7d65f6ee61da0905163d7194ef4214b77b45ef3b 100644 --- a/product/ERP5/Document/SolverProcess.py +++ b/product/ERP5/Document/SolverProcess.py @@ -85,6 +85,9 @@ class SolverProcess(XMLObject, ActiveProcess): movement_dict = {} 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 # in order to know for each movements which solvers are needed # and which parameters with @@ -99,18 +102,24 @@ class SolverProcess(XMLObject, ActiveProcess): for movement in decision.getDeliveryValueList(): # Detect incompatibilities 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 # Second, make sure solvers do not conflict and configuration is valid 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] - for other_solver_type in movement_solver_dict.keys(): - if other_solver_type == solver_type: + for other_solver_info in movement_solver_dict.keys(): + if other_solver_info == solver_info: continue - if solver.conflictsWithSolver(types_tool[other_solver_type]): - raise ValueError, "Solver %s conflicts with solver %s on movement %s" % (solver_type, other_solver_type, movement_url) + # Try do detect conflict. + # 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 try: # Solver key contains only those properties which differentiate @@ -118,15 +127,17 @@ class SolverProcess(XMLObject, ActiveProcess): solver_key = tuple(solver.reduceConfigurationList(movement_solver_configuration_dict.keys())) except: 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[movement_url] = movement_solver_configuration_dict.keys() # 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(): solver_instance = self.newContent(portal_type=solver_type) solver_instance._setDeliveryList(solver_movement_dict.keys()) + solver_instance.setCausalityValue(decision) for movement_url, configuration_list in solver_movement_dict.iteritems(): for configuration_kw in configuration_list: if len(configuration_kw): diff --git a/product/ERP5/PropertySheet/TargetSolver.py b/product/ERP5/PropertySheet/TargetSolver.py index 046e2f12e9bad62013b83e9120148a793206ef13..60ae17c8796855b14f40475424e18b1088e34b9a 100644 --- a/product/ERP5/PropertySheet/TargetSolver.py +++ b/product/ERP5/PropertySheet/TargetSolver.py @@ -30,4 +30,4 @@ from Products.CMFCore.Expression import Expression class TargetSolver: - _categories = ('delivery',) + _categories = ('delivery', 'causality')