Commit 148e8b26 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

get properties to be solved from divergence tester (target solver's causality's causality).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32268 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 58aa0461
...@@ -64,9 +64,9 @@ class AcceptSolver(SolverMixin, ConfigurableMixin, XMLObject): ...@@ -64,9 +64,9 @@ class AcceptSolver(SolverMixin, ConfigurableMixin, XMLObject):
Adopt new property to simulation movements, with keeping the Adopt new property to simulation movements, with keeping the
original one recorded. original one recorded.
""" """
solved_property = self._getPortalTypeValue().getTestedProperty() solved_property_list = self.getCausalityValue().getCausalityValue(). \
getTestedPropertyList()
for movement in self.getDeliveryValueList(): for movement in self.getDeliveryValueList():
new_value = movement.getProperty(solved_property)
simulation_movement_list = movement.getDeliveryRelatedValueList() simulation_movement_list = movement.getDeliveryRelatedValueList()
# if movement here is a delivery, we need to find simulation # if movement here is a delivery, we need to find simulation
# movements by its movements. # movements by its movements.
...@@ -75,12 +75,15 @@ class AcceptSolver(SolverMixin, ConfigurableMixin, XMLObject): ...@@ -75,12 +75,15 @@ class AcceptSolver(SolverMixin, ConfigurableMixin, XMLObject):
[x.getDeliveryRelatedValueList() \ [x.getDeliveryRelatedValueList() \
for x in self.getDeliveryValue().getMovementList()], []) for x in self.getDeliveryValue().getMovementList()], [])
for simulation_movement in simulation_movement_list: for simulation_movement in simulation_movement_list:
# XXX hard coded value_dict = {}
if solved_property == 'quantity': for solved_property in solved_property_list:
new_quantity = new_value * simulation_movement.getDeliveryRatio() new_value = movement.getProperty(solved_property)
value_dict = {'quantity':new_quantity} # XXX hard coded
else: if solved_property == 'quantity':
value_dict = {solved_property:new_value} new_quantity = new_value * simulation_movement.getDeliveryRatio()
value_dict.update({'quantity':new_quantity})
else:
value_dict.update({solved_property:new_value})
self._solveRecursively(simulation_movement, value_dict) self._solveRecursively(simulation_movement, value_dict)
simulation_movement.expand() simulation_movement.expand()
# Finish solving # Finish solving
......
...@@ -65,30 +65,32 @@ class AdoptSolver(SolverMixin, ConfigurableMixin, XMLObject): ...@@ -65,30 +65,32 @@ class AdoptSolver(SolverMixin, ConfigurableMixin, XMLObject):
""" """
Adopt new property to movements or deliveries. Adopt new property to movements or deliveries.
""" """
solved_property = self._getPortalTypeValue().getTestedProperty() solved_property_list = self.getCausalityValue().getCausalityValue(). \
getTestedPropertyList()
for movement in self.getDeliveryValueList(): for movement in self.getDeliveryValueList():
# XXX hardcoded for solved_property in solved_property_list:
if solved_property == 'quantity': # XXX hardcoded
total_quantity = sum( if solved_property == 'quantity':
[x.getQuantity() for x in movement.getDeliveryRelatedValueList()]) total_quantity = sum(
movement.setQuantity(total_quantity) [x.getQuantity() for x in movement.getDeliveryRelatedValueList()])
for simulation_movement in movement.getDeliveryRelatedValueList(): movement.setQuantity(total_quantity)
quantity = simulation_movement.getQuantity() for simulation_movement in movement.getDeliveryRelatedValueList():
delivery_ratio = quantity / total_quantity quantity = simulation_movement.getQuantity()
delivery_error = total_quantity * delivery_ratio - quantity delivery_ratio = quantity / total_quantity
simulation_movement.edit(delivery_ratio=delivery_ratio, delivery_error = total_quantity * delivery_ratio - quantity
delivery_error=delivery_error) simulation_movement.edit(delivery_ratio=delivery_ratio,
self._clearRecordedPropertyRecursively(simulation_movement, delivery_error=delivery_error)
solved_property) self._clearRecordedPropertyRecursively(simulation_movement,
else: solved_property)
# XXX TODO we need to support multiple values for categories or else:
# list type property. # XXX TODO we need to support multiple values for categories or
simulation_movement = movement.getDeliveryRelatedValue() # list type property.
movement.setProperty(solved_property, simulation_movement = movement.getDeliveryRelatedValue()
simulation_movement.getProperty(solved_property)) movement.setProperty(solved_property,
for simulation_movement in movement.getDeliveryRelatedValueList(): simulation_movement.getProperty(solved_property))
self._clearRecordedPropertyRecursively(simulation_movement, for simulation_movement in movement.getDeliveryRelatedValueList():
solved_property) self._clearRecordedPropertyRecursively(simulation_movement,
solved_property)
# Finish solving # Finish solving
self.succeed() self.succeed()
......
...@@ -62,7 +62,9 @@ class UnifySolver(AcceptSolver, AdoptSolver): ...@@ -62,7 +62,9 @@ class UnifySolver(AcceptSolver, AdoptSolver):
Adopt new property to simulation movements, with keeping the Adopt new property to simulation movements, with keeping the
original one recorded. original one recorded.
""" """
solved_property = self._getPortalTypeValue().getTestedProperty() # XXX it does not support multiple tested properties.
solved_property = self.getCausalityValue().getCausalityValue(). \
getTestedProperty()
for movement in self.getDeliveryValueList(): for movement in self.getDeliveryValueList():
configuration_dict = self.getConfigurationPropertyDict() configuration_dict = self.getConfigurationPropertyDict()
new_value = configuration_dict.get('value') new_value = configuration_dict.get('value')
......
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