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