Skip to content

Commit a169b39

Browse files
committed
add correlation keys to process variable correlations
1 parent fb484fc commit a169b39

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

SpiffWorkflow/bpmn/specs/event_definitions/message.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ def calculate_correlations(self, script_engine, cp, ctx):
7171
except WorkflowException:
7272
# Just ignore missing keys. The dictionaries have to match exactly
7373
pass
74-
if len(prop.correlation_keys) == 0:
75-
if self.name not in correlations:
76-
correlations[self.name] = {}
77-
correlations[self.name][prop.name] = value
7874
return correlations
7975

8076
def details(self, my_task):

SpiffWorkflow/spiff/parser/event_parsers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ def parse_process_correlations(self, node):
5555
for prop in node.xpath('.//spiffworkflow:processVariableCorrelation', namespaces=SPIFFWORKFLOW_NSMAP):
5656
key = one(prop.xpath('./spiffworkflow:propertyId', namespaces=SPIFFWORKFLOW_NSMAP))
5757
expression = one(prop.xpath('./spiffworkflow:expression', namespaces=SPIFFWORKFLOW_NSMAP))
58-
correlations.append(CorrelationProperty(key.text, expression.text, []))
58+
used_by = []
59+
for ck in self.xpath(f"//bpmn:collaboration//bpmn:correlationPropertyRef[text()='{key.text}']"):
60+
used_by.append(ck.getparent().attrib['name'])
61+
correlations.append(CorrelationProperty(key.text, expression.text, used_by))
5962
return correlations
6063

6164
def parse_message_event(self, message_event):

tests/SpiffWorkflow/spiff/CorrelationTest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def actual_test(self, save_restore=False):
7474
task.data.update(value_1='a', value_2='b')
7575
task.run()
7676
self.workflow.do_engine_steps()
77-
self.assertEqual(self.workflow.correlations, {'message': {'prop_1': 'a', 'prop_2': 'b'}})
77+
self.assertEqual(self.workflow.correlations, {'test': {'prop_1': 'a', 'prop_2': 'b'}})
7878
waiting_task = self.workflow.get_next_task(state=TaskState.WAITING)
7979
event_def = waiting_task.task_spec.event_definition
8080
payload = {'msg_value_1': 'a', 'msg_value_2': 'b'}

tests/SpiffWorkflow/spiff/data/receive_correlations.bpmn

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
</bpmn:messageEventDefinition>
3333
</bpmn:intermediateCatchEvent>
3434
</bpmn:process>
35+
<bpmn:collaboration id="receive_correlation_test">
36+
<bpmn:participant id="collaboration" processRef="correlation-test" />
37+
<bpmn:correlationKey name="test">
38+
<bpmn:correlationPropertyRef>prop_1</bpmn:correlationPropertyRef>
39+
<bpmn:correlationPropertyRef>prop_2</bpmn:correlationPropertyRef>
40+
</bpmn:correlationKey>
41+
</bpmn:collaboration>
3542
<bpmn:message id="Message_16t6tet" name="message" />
3643
<bpmn:correlationProperty id="prop_1" name="prop_1">
3744
<bpmn:correlationPropertyRetrievalExpression messageRef="Message_16t6tet">

0 commit comments

Comments
 (0)