Commit ed4e2eb5 authored by Yusuke Muraoka's avatar Yusuke Muraoka

- changed some method sigunatures.

- changed calling parameters to get a node from a business path.
- fixed get_remaining_trade_phase should be filtered by trade_phase(s)
  of a transformation.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27641 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9210b7d1
...@@ -95,12 +95,10 @@ class ProductionOrderModelRule(TransformationModelRuleMixin, OrderRule): ...@@ -95,12 +95,10 @@ class ProductionOrderModelRule(TransformationModelRuleMixin, OrderRule):
for prop in default_property_list: for prop in default_property_list:
property_dict[prop] = movement.getProperty(prop) property_dict[prop] = movement.getProperty(prop)
explanation = self.getExplanation(applied_rule=applied_rule) path = self.getBusinessProcessValue(applied_rule=applied_rule).getRootExplanationPathValue()
path = self.getSpecialise(applied_rule=applied_rule).getRootExplanationValue() property_dict['source_section'] = path.getDestinationSection(context=movement)
property_dict['source_section'] = path.getDestinationSection(explanation) property_dict['source'] = path.getDestination(context=movement)
property_dict['source'] = path.getDestination(explanation)
import pdb; pdb.set_trace()
successor = path.getSuccessorValue() successor = path.getSuccessorValue()
if successor is not None: if successor is not None:
property_dict['causality_list'] = successor.getPredecessorRelatedList() property_dict['causality_list'] = successor.getPredecessorRelatedList()
......
...@@ -136,8 +136,8 @@ class TransformationModelMovementFactory(MovementFactory): ...@@ -136,8 +136,8 @@ class TransformationModelMovementFactory(MovementFactory):
class TransformationModelRuleMixin(Base): class TransformationModelRuleMixin(Base):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareProtected(Permissions.View, 'getTransformation') security.declareProtected(Permissions.View, 'getTransformationValue')
def getTransformation(self, movement=None, applied_rule=None): def getTransformationValue(self, movement=None, applied_rule=None):
""" """
Return transformation related to used by the applied rule. Return transformation related to used by the applied rule.
""" """
...@@ -145,8 +145,8 @@ class TransformationModelRuleMixin(Base): ...@@ -145,8 +145,8 @@ class TransformationModelRuleMixin(Base):
movement = applied_rule.getParentValue() movement = applied_rule.getParentValue()
order_movement = movement.getRootSimulationMovement().getOrderValue() order_movement = movement.getRootSimulationMovement().getOrderValue()
explanation = self.getExplanation(movement=movement, explanation = self.getExplanationValue(movement=movement,
applied_rule=applied_rule) applied_rule=applied_rule)
# find the line of order recursively # find the line of order recursively
order_line = order_movement order_line = order_movement
while order_line.getParentValue() != explanation: while order_line.getParentValue() != explanation:
...@@ -167,16 +167,16 @@ class TransformationModelRuleMixin(Base): ...@@ -167,16 +167,16 @@ class TransformationModelRuleMixin(Base):
if transformation.getResource() == movement.getResource(): if transformation.getResource() == movement.getResource():
return transformation return transformation
security.declareProtected(Permissions.View, 'getSpecialise') security.declareProtected(Permissions.View, 'getBusinessProcessValue')
def getSpecialise(self, movement=None, applied_rule=None, portal_type_list=None): def getBusinessProcessValue(self, movement=None, applied_rule=None, portal_type_list=None):
""" """
Return a business process related to the root causality. Return a business process related to the root causality.
""" """
if portal_type_list is None: if portal_type_list is None:
portal_type_list = self.getPortalBusinessProcessTypeList() portal_type_list = self.getPortalBusinessProcessTypeList()
explanation = self.getExplanation(movement=movement, explanation = self.getExplanationValue(movement=movement,
applied_rule=applied_rule) applied_rule=applied_rule)
if explanation is not None: if explanation is not None:
specialise = explanation.getSpecialiseValue() specialise = explanation.getSpecialiseValue()
business_process_type_list = self.getPortalBusinessProcessTypeList() business_process_type_list = self.getPortalBusinessProcessTypeList()
...@@ -187,8 +187,11 @@ class TransformationModelRuleMixin(Base): ...@@ -187,8 +187,11 @@ class TransformationModelRuleMixin(Base):
specialise = specialise.getSpecialiseValue() specialise = specialise.getSpecialiseValue()
return specialise return specialise
security.declareProtected(Permissions.View, 'getExplanation') security.declareProtected(Permissions.View, 'getExplanationValue')
def getExplanation(self, movement=None, applied_rule=None): def getExplanationValue(self, movement=None, applied_rule=None):
"""
Return the explanation with the movement or the applied_rule.
"""
if applied_rule is not None: if applied_rule is not None:
return applied_rule.getRootAppliedRule().getCausalityValue() return applied_rule.getRootAppliedRule().getCausalityValue()
else: else:
...@@ -234,9 +237,9 @@ class TransformationModelRule(TransformationModelRuleMixin, Rule): ...@@ -234,9 +237,9 @@ class TransformationModelRule(TransformationModelRuleMixin, Rule):
""" """
parent_movement = applied_rule.getParentValue() parent_movement = applied_rule.getParentValue()
transformation = self.getTransformation(movement=parent_movement) transformation = self.getTransformationValue(movement=parent_movement)
business_process = self.getSpecialise(movement=parent_movement) business_process = self.getBusinessProcessValue(movement=parent_movement)
explanation = self.getExplanation(movement=parent_movement) explanation = self.getExplanationValue(movement=parent_movement)
# get all trade_phase of the Business Process # get all trade_phase of the Business Process
trade_phase_list = business_process.getTradePhaseList() trade_phase_list = business_process.getTradePhaseList()
...@@ -263,6 +266,8 @@ class TransformationModelRule(TransformationModelRuleMixin, Rule): ...@@ -263,6 +266,8 @@ class TransformationModelRule(TransformationModelRuleMixin, Rule):
amount_dict.setdefault(phase, []) amount_dict.setdefault(phase, [])
amount_dict[phase].append(amount) amount_dict[phase].append(amount)
transformation_phase_list = amount_dict.keys()
last_phase_path_list = list() # to keep phase_path_list last_phase_path_list = list() # to keep phase_path_list
last_prop_dict = dict() last_prop_dict = dict()
for (phase, amount_list) in amount_dict.items(): for (phase, amount_list) in amount_dict.items():
...@@ -285,18 +290,18 @@ class TransformationModelRule(TransformationModelRuleMixin, Rule): ...@@ -285,18 +290,18 @@ class TransformationModelRule(TransformationModelRuleMixin, Rule):
quantity = factory.product['quantity'] * path.getQuantity() quantity = factory.product['quantity'] * path.getQuantity()
# nodes at the path # nodes at the path
source_section = path.getSourceSection(explanation) source_section = path.getSourceSection(context=parent_movement)
destination_section = path.getDestinationSection(explanation) destination_section = path.getDestinationSection(context=parent_movement)
source = path.getSource(explanation) source = path.getSource(context=parent_movement)
destination = path.getDestination(explanation) destination = path.getDestination(context=parent_movement)
# the remaining at the start and the end on the path # the remaining at the start and the end on the path
predecessor_remaining_phase_list = path.getPredecessorValue()\ predecessor_remaining_phase_list = path.getPredecessorValue()\
.getRemainingTradePhaseList(explanation, .getRemainingTradePhaseList(explanation,
trade_phase_list=trade_phase_list) trade_phase_list=transformation_phase_list)
successor_remaining_phase_list = path.getSuccessorValue()\ successor_remaining_phase_list = path.getSuccessorValue()\
.getRemainingTradePhaseList(explanation, .getRemainingTradePhaseList(explanation,
trade_phase_list=trade_phase_list) trade_phase_list=transformation_phase_list)
consumed_common_dict = dict(source_section=source_section, consumed_common_dict = dict(source_section=source_section,
destination_section=destination_section, destination_section=destination_section,
......
...@@ -82,7 +82,8 @@ class TransformationSourcingModelRule(TransformationModelRuleMixin, Rule): ...@@ -82,7 +82,8 @@ class TransformationSourcingModelRule(TransformationModelRuleMixin, Rule):
is expanded. is expanded.
""" """
parent_movement = applied_rule.getParentValue() parent_movement = applied_rule.getParentValue()
explanation = self.getExplanation(movement=parent_movement)
explanation = self.getExplanationValue(applied_rule=applied_rule)
state = parent_movement.getCausalityValue().getPredecessorValue() state = parent_movement.getCausalityValue().getPredecessorValue()
path_list = state.getSuccessorRelatedValueList() path_list = state.getSuccessorRelatedValueList()
...@@ -95,10 +96,10 @@ class TransformationSourcingModelRule(TransformationModelRuleMixin, Rule): ...@@ -95,10 +96,10 @@ class TransformationSourcingModelRule(TransformationModelRuleMixin, Rule):
path = path_list[0] path = path_list[0]
source_section = self.getSourceSection(path, applied_rule=applied_rule) source_section = path.getSourceSection(context=parent_movement)
destination_section = self.getDestinationSection(path, applied_rule=applied_rule) destination_section = path.getDestinationSection(context=parent_movement)
source = self.getSource(path, applied_rule=applied_rule) source = path.getSource(context=parent_movement)
destination = self.getDestination(path, applied_rule=applied_rule) destination = path.getDestination(context=parent_movement)
start_date = path.getExpectedStartDate(explanation) start_date = path.getExpectedStartDate(explanation)
stop_date = path.getExpectedStopDate(explanation) stop_date = path.getExpectedStopDate(explanation)
......
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