Commit 8b3e92fd authored by Łukasz Nowak's avatar Łukasz Nowak

Support lazy causality links on Simulation Movements.

Accept business_link_list on searchMovementList in order to test each found
movement precisely against Business Process.

If any Simulation Movement will become not buildable anymore reset causality
link.

When calling searchMovementList pass Business Links in order to allow select
only interesting movements.
parent fb5449fa
......@@ -98,7 +98,7 @@ class SimulatedDeliveryBuilder(BuilderMixin):
pass
@UnrestrictedMethod
def searchMovementList(self, applied_rule_uid=None, **kw):
def searchMovementList(self, applied_rule_uid=None, business_link_list=None, **kw):
"""
defines how to query all Simulation Movements which meet certain criteria
(including the above path path definition).
......@@ -112,18 +112,27 @@ class SimulatedDeliveryBuilder(BuilderMixin):
# Search only child movement from this applied rule
if applied_rule_uid is not None:
kw['parent_uid'] = applied_rule_uid
if business_link_list is None:
business_link_list = []
# XXX Add profile query
# Add resource query
if self.getResourcePortalType() not in ('', None):
kw['resourceType'] = self.getResourcePortalType()
if self.getSimulationSelectMethodId() in ['', None]:
movement_list = [x.getObject() for x in self.portal_catalog(**kw)]
prefilter_movement_list = [x.getObject() for x in self.portal_catalog(**kw)]
else:
select_method = getattr(self.getPortalObject(), self.getSimulationSelectMethodId())
movement_list = select_method(**kw)
prefilter_movement_list = select_method(**kw)
# XXX Use buildSQLQuery will be better
movement_list = [x for x in movement_list if \
x.getDeliveryValueList()==[] and x.isBuildable()]
movement_list = []
for movement in prefilter_movement_list:
for business_link in business_link_list:
if movement.isBuildable(business_link):
if movement.getDeliveryValueList()==[]:
movement_list.append(movement)
else:
# drop causality links
movement.setCausalityList([])
# XXX Add predicate test
# XXX FIXME Check that there is no double in the list
# Because we can't trust simulation_select_method
......
......@@ -126,6 +126,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
kw['path'] = explanation_cache.getSimulationPathPatternList()
if business_link is not None:
kw['causality_uid'] = business_link.getUid()
business_link_value_list = [business_link]
elif kw.get('causality_uid') is None:
business_link_value_list = self.getRelatedBusinessLinkValueList()
if len(business_link_value_list) > 0:
......@@ -134,6 +135,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
movement_list = self.searchMovementList(
delivery_relative_url_list=delivery_relative_url_list,
applied_rule_uid=applied_rule_uid,
business_link_list=business_link_value_list,
**kw)
if not movement_list:
return []
......
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