[Erp5-report] r28040 - /erp5/trunk/products/ERP5/Document/BusinessPath.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Jul 9 13:31:14 CEST 2009
Author: luke
Date: Thu Jul 9 13:31:13 2009
New Revision: 28040
URL: http://svn.erp5.org?rev=28040&view=rev
Log:
Builder related implementation and small fixes:
- updated copyrights
- implement isBuildable, based on real system
- add helper method to fetch explanation list
- during build use proper method to find delivery builders, and let do builder its job to find movements (this is to be future proof)
- fix method name from _getRelatedSimulationMovementList to _getRelatedSimulationMovementValueList, as it in reality return documents not urls and fix this method implementation
Modified:
erp5/trunk/products/ERP5/Document/BusinessPath.py
Modified: erp5/trunk/products/ERP5/Document/BusinessPath.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessPath.py?rev=28040&r1=28039&r2=28040&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessPath.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessPath.py [utf8] Thu Jul 9 13:31:13 2009
@@ -4,6 +4,7 @@
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp at nexedi.com>
# Yusuke Muraoka <yusuke at nexedi.com>
+# Łukasz Nowak <luke at nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@@ -182,15 +183,20 @@
def isBuildable(self, explanation):
"""
"""
- if self.isCompleted(explanation):
- return False # No need to build what was already built
- if self.isFrozen(explanation):
- return False # No need to build what is frozen
+ # check if there is at least one simulation movement which is not
+ # delivered
+ result = False
+ if self.isCompleted(explanation) or self.isFrozen(explanation):
+ return False # No need to build what was already built or frozen
+ for simulation_movement in self._getRelatedSimulationMovementValueList(
+ explanation):
+ if simulation_movement.getDeliveryValue() is None:
+ result = True
predecessor = self.getPredecessorValue()
if predecessor is None:
- return True # No predecessor, let's build
+ return result
if predecessor.isCompleted(explanation):
- return True
+ return result
return False
def isPartiallyBuildable(self, explanation):
@@ -198,22 +204,42 @@
Not sure if this will exist some day XXX
"""
+ def _getExplanationUidList(self, explanation):
+ """Helper method to fetch really explanation related movements
+
+ As Business Path is related to movement by causality, thanks to
+ trade_phase during expand, it is correct to pass too much explanations
+ than not enough"""
+ explanation_uid_list = [explanation.getUid()]
+ for ex in explanation.getCausalityRelatedValueList(
+ portal_type=self.getPortalDeliveryTypeList()):
+ explanation_uid_list.extend(self._getExplanationUidList(ex))
+ return explanation_uid_list
+
def build(self, explanation):
"""
Build
"""
- builder_list = self.getBuilderList() # Missing method
+ builder_list = self.getDeliveryBuilderValueList() # Missing method
for builder in builder_list:
- builder.build(causality_uid=self.getUid()) # This is one way of doing
- builder.build(movement_relative_url_list=
- self._getRelatedSimulationMovementList(explanation)) # Another way
-
- def _getRelatedSimulationMovementList(self, explanation): # XXX - What API ?
- """
-
- """
- return self.getCausalityRelatedValueList(portal_type='Simulation Movement',
- explanation_uid=explanation.getUid())
+ # chosen a way that builder is good enough to decide to select movements
+ # which shall be really build (movement selection for build is builder
+ # job, not business path job)
+ builder.build(select_method_dict={
+ 'causality_uid': self.getUid(),
+ 'explanation_uid': self._getExplanationUidList(explanation)
+ })
+
+ def _getRelatedSimulationMovementValueList(self, explanation): # XXX - What API ?
+ """
+ Returns all Simulation Movements related to explanation
+ """
+ # XXX What about explanations for causality related documents to explanation?
+ explanation_uid_list = self._getExplanationUidList(explanation)
+ # getCausalityRelated do not support filtering, so post filtering needed
+ return [x for x in self.getCausalityRelatedValueList(
+ portal_type='Simulation Movement')
+ if x.getExplanationUid() in explanation_uid_list]
# IBusinessCompletable implementation
def isCompleted(self, explanation):
@@ -222,7 +248,7 @@
and checks the simulation_state of the delivery
"""
acceptable_state_list = self.getCompletedStateList()
- for movement in self._getRelatedSimulationMovementList(explanation):
+ for movement in self._getRelatedSimulationMovementValueList(explanation):
if movement.getSimulationState() not in acceptable_state_list:
return False
return True
@@ -233,7 +259,7 @@
and checks the simulation_state of the delivery
"""
acceptable_state_list = self.getCompletedStateList()
- for movement in self._getRelatedSimulationMovementList(explanation):
+ for movement in self._getRelatedSimulationMovementValueList(explanation):
if movement.getSimulationState() in acceptable_state_list:
return True
return False
@@ -243,7 +269,7 @@
Looks at all simulation related movements
and checks if frozen
"""
- movement_list = self._getRelatedSimulationMovementList(explanation)
+ movement_list = self._getRelatedSimulationMovementValueList(explanation)
if len(movement_list) == 0:
return False # Nothing to be considered as Frozen
for movement in movement_list:
More information about the Erp5-report
mailing list