Commit fb5449fa authored by Łukasz Nowak's avatar Łukasz Nowak

Support Simulation Movements w/o causality.

Use predicate test method of Business Links in order to find matching one.

Fail in case if none found or in case if predicate matches too many.

Note: As updated design assume that Simulation Movements w/o Business Link are
not buildable at all it will render all "legacy simulation movemements", those
pre-Business Process, to be non buildable.
parent 680287ae
...@@ -617,17 +617,20 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin): ...@@ -617,17 +617,20 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'isBuildable') 'isBuildable')
def isBuildable(self): def isBuildable(self, business_link):
"""Simulation Movement buildable logic""" """Simulation Movement buildable logic"""
if self.getDelivery(): if self.getDelivery():
# already delivered # already delivered
return False return False
# might be buildable - business path dependent # might be buildable - business path dependent
business_link = self.getCausalityValue(portal_type='Business Link')
explanation_value = self.getExplanationValue() explanation_value = self.getExplanationValue()
if business_link is None or explanation_value is None: if business_link is None or explanation_value is None:
return True # without Business Link and explanation it is impossible to check
# precisely if movement is buildable
# Note: It breaks compatilibity with old simulation code which did not
# use Business Process at all, here assumption is inverted
return False
## XXX Code below following line has been moved to BusinessPath (cf r37116) ## XXX Code below following line has been moved to BusinessPath (cf r37116)
#return len(business_path.filterBuildableMovementList([self])) == 1 #return len(business_path.filterBuildableMovementList([self])) == 1
...@@ -642,10 +645,10 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin): ...@@ -642,10 +645,10 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
composed_document = self.asComposedDocument() composed_document = self.asComposedDocument()
predecessor_link_list = composed_document.getBusinessLinkValueList( predecessor_link_list = composed_document.getBusinessLinkValueList(
successor=predecessor_state) successor=predecessor_state)
business_link_list = composed_document.getBusinessLinkValueList()
def isBuiltAndCompleted(simulation, path): def isBuiltAndCompleted(simulation, path):
return simulation.getCausalityValue() is not None and \ return simulation.getSimulationState() in path.getCompletedStateList()
simulation.getSimulationState() in path.getCompletedStateList()
### Step 1: ### Step 1:
## Explore ancestors in ZODB (cheap) ## Explore ancestors in ZODB (cheap)
...@@ -655,8 +658,20 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin): ...@@ -655,8 +658,20 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
causality_dict = {} causality_dict = {}
current = self.getParentValue().getParentValue() current = self.getParentValue().getParentValue()
while current.getPortalType() == "Simulation Movement": while current.getPortalType() == "Simulation Movement":
causality_dict[current.getCausality(portal_type='Business Link')] = \ business_link = current.getCausality(portal_type='Business Link')
current if business_link is None:
# no direct business link set on movement, use predicate to find one
for candidate_business_link in business_link_list:
if candidate_business_link.test(current):
if business_link is not None:
raise ValueError('Business Link predicate matches too many '
'movements.')
business_link = candidate_business_link.getRelativeUrl()
if not business_link:
raise ValueError('Simulation Movement has no Business Link related '
'and no Business Link from current Business Process matches')
causality_dict[business_link] = current
current = current.getParentValue().getParentValue() current = current.getParentValue().getParentValue()
remaining_path_set = set() remaining_path_set = set()
......
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