Skip to content

Commit 9608cc9

Browse files
authored
Merge pull request #238 from ProcessMaker/FOUR-28320
FOUR-28320 Fix data mapping in message start event
2 parents 9f0deac + 9377763 commit 9608cc9

File tree

4 files changed

+265
-1
lines changed

4 files changed

+265
-1
lines changed

src/ProcessMaker/Nayra/Bpmn/StartEventTrait.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
namespace ProcessMaker\Nayra\Bpmn;
44

5+
use ProcessMaker\Nayra\Contracts\Bpmn\CatchEventInterface;
56
use ProcessMaker\Nayra\Contracts\Bpmn\CollectionInterface;
7+
use ProcessMaker\Nayra\Contracts\Bpmn\EndEventInterface;
68
use ProcessMaker\Nayra\Contracts\Bpmn\EventDefinitionInterface;
79
use ProcessMaker\Nayra\Contracts\Bpmn\EventInterface;
810
use ProcessMaker\Nayra\Contracts\Bpmn\FlowInterface;
11+
use ProcessMaker\Nayra\Contracts\Bpmn\MessageEventDefinitionInterface;
12+
use ProcessMaker\Nayra\Contracts\Bpmn\ThrowEventInterface;
913
use ProcessMaker\Nayra\Contracts\Bpmn\TokenInterface;
1014
use ProcessMaker\Nayra\Contracts\Bpmn\TransitionInterface;
1115
use ProcessMaker\Nayra\Contracts\Engine\EngineInterface;
@@ -116,7 +120,11 @@ public function execute(EventDefinitionInterface $eventDef, ExecutionInstanceInt
116120
$process = $this->getOwnerProcess();
117121
$data = $eventDefinition->getPayloadData($token, $this);
118122
$dataStorage = $process->getRepository()->createDataStore();
119-
$dataStorage->setData($data);
123+
$sourceHasDataMapping = $token?->getOwnerElement()?->getDataInputs()?->count();
124+
$targetHasDataMapping = $this->getDataOutputAssociations()?->count();
125+
if (!$sourceHasDataMapping && !$targetHasDataMapping) {
126+
$dataStorage->setData($data);
127+
}
120128
$instance = $process->getEngine()->createExecutionInstance($process, $dataStorage);
121129
}
122130
$this->triggerPlace[$index]->addNewToken($instance);

tests/Feature/Patterns/PatternsTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,20 @@ private function runProcess($filename, $data, $startEvent, $result, $events, $ou
212212
if ($errors) {
213213
$this->assertData($errors, $runtimeErrors);
214214
}
215+
// Check data from all instances
216+
$expectedDataByInstances = $json['expectedDataByInstances'] ?? false;
217+
if ($expectedDataByInstances ?? false) {
218+
$i = 0;
219+
foreach ($processes as $process) {
220+
foreach ($process->getBpmnElementInstance()->getInstances() as $ins) {
221+
if (!isset($expectedDataByInstances[$i])) {
222+
$this->fail('Data instance ' . $i . ' not found for test' . $testName);
223+
}
224+
$this->assertData($expectedDataByInstances[$i], $ins->getDataStore()->getData());
225+
$i++;
226+
}
227+
}
228+
}
215229
}
216230

217231
/**
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:pm="http://processmaker.com/BPMN/2.0/Schema.xsd" xmlns:tns="http://sourceforge.net/bpmn/definitions/_1530553328908" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://bpmn.io/schema/bpmn" exporter="ProcessMaker Modeler" exporterVersion="1.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL http://bpmn.sourceforge.net/schemas/BPMN20.xsd">
3+
<bpmn:process id="ProcessId" name="ProcessName" isExecutable="true">
4+
<bpmn:startEvent id="node_3" name="Start Event" pm:allowInterstitial="true" pm:interstitialScreenRef="14" pm:config="{&quot;web_entry&quot;:null}">
5+
<bpmn:outgoing>node_20</bpmn:outgoing>
6+
</bpmn:startEvent>
7+
<bpmn:task id="node_4" name="Form Task 1" pm:screenRef="15" pm:allowInterstitial="false" pm:assignment="requester" pm:assignmentLock="false" pm:allowReassignment="false" pm:config="{&quot;email_notifications&quot;:{&quot;notifications&quot;:[{&quot;sendAt&quot;:&quot;task-start&quot;,&quot;expression&quot;:&quot;&quot;,&quot;subject&quot;:&quot;RE: {{_user.firstname}} assigned you in \&quot;{{_task_name}}\&quot;&quot;,&quot;type&quot;:&quot;screen&quot;,&quot;textBody&quot;:&quot;&quot;,&quot;screenRef&quot;:12,&quot;usersAndGroupsOptionSelected&quot;:null,&quot;toRecipients&quot;:[{&quot;type&quot;:&quot;assignedUser&quot;,&quot;value&quot;:null}],&quot;ccRecipients&quot;:[],&quot;bccRecipients&quot;:[],&quot;i&quot;:21}]},&quot;web_entry&quot;:null}" pm:elementDestination="{&quot;type&quot;:&quot;processLaunchpad&quot;,&quot;value&quot;:&quot;process-browser/123?categorySelected=-1&quot;}">
8+
<bpmn:incoming>node_20</bpmn:incoming>
9+
<bpmn:outgoing>node_153</bpmn:outgoing>
10+
</bpmn:task>
11+
<bpmn:intermediateThrowEvent id="node_18" name="Intermediate Message Throw Event">
12+
<bpmn:incoming>node_177</bpmn:incoming>
13+
<bpmn:outgoing>node_37</bpmn:outgoing>
14+
<bpmn:dataInput id="din_1764370229232" name="form_input_1"/>
15+
<bpmn:dataInput id="din_1764965138442" name="glossary"/>
16+
<bpmn:dataInputAssociation>
17+
<bpmn:targetRef>din_1764370229232</bpmn:targetRef>
18+
<bpmn:assignment>
19+
<bpmn:from>form_input_1</bpmn:from>
20+
<bpmn:to>form_input_3</bpmn:to>
21+
</bpmn:assignment>
22+
</bpmn:dataInputAssociation>
23+
<bpmn:dataInputAssociation>
24+
<bpmn:targetRef>din_1764965138442</bpmn:targetRef>
25+
<bpmn:assignment>
26+
<bpmn:from>glossary.title</bpmn:from>
27+
<bpmn:to>form_input_1a</bpmn:to>
28+
</bpmn:assignment>
29+
</bpmn:dataInputAssociation>
30+
<bpmn:inputSet>
31+
<bpmn:dataInputRefs>din_1764370229232</bpmn:dataInputRefs>
32+
<bpmn:dataInputRefs>din_1764965138442</bpmn:dataInputRefs>
33+
</bpmn:inputSet>
34+
<bpmn:messageEventDefinition messageRef="node_18_message"/>
35+
</bpmn:intermediateThrowEvent>
36+
<bpmn:sequenceFlow id="node_20" name="" sourceRef="node_3" targetRef="node_4"/>
37+
<bpmn:sequenceFlow id="node_53" name="" sourceRef="node_17" targetRef="node_43"/>
38+
<bpmn:sequenceFlow id="node_74" name="" sourceRef="node_43" targetRef="node_66"/>
39+
<bpmn:sequenceFlow id="node_97" name="" sourceRef="node_77" targetRef="node_87"/>
40+
<bpmn:sequenceFlow id="node_88" name="" sourceRef="node_103" targetRef="node_77"/>
41+
<bpmn:endEvent id="node_104" name="Message End Event">
42+
<bpmn:incoming>node_37</bpmn:incoming>
43+
<bpmn:dataInput id="din_1764908076462" name="form_select_list_1"/>
44+
<bpmn:dataInputAssociation>
45+
<bpmn:targetRef>din_1764908076462</bpmn:targetRef>
46+
<bpmn:assignment>
47+
<bpmn:from>form_select_list_1</bpmn:from>
48+
<bpmn:to>form_select_list_3</bpmn:to>
49+
</bpmn:assignment>
50+
</bpmn:dataInputAssociation>
51+
<bpmn:inputSet>
52+
<bpmn:dataInputRefs>din_1764908076462</bpmn:dataInputRefs>
53+
</bpmn:inputSet>
54+
<bpmn:messageEventDefinition messageRef="node_104_message"/>
55+
</bpmn:endEvent>
56+
<bpmn:sequenceFlow id="node_37" name="" sourceRef="node_18" targetRef="node_104"/>
57+
<bpmn:scriptTask id="node_129" name="Script Task" pm:scriptRef="4">
58+
<bpmn:incoming>node_153</bpmn:incoming>
59+
<bpmn:outgoing>node_177</bpmn:outgoing>
60+
</bpmn:scriptTask>
61+
<bpmn:sequenceFlow id="node_153" sourceRef="node_4" targetRef="node_129"/>
62+
<bpmn:sequenceFlow id="node_177" sourceRef="node_129" targetRef="node_18"/>
63+
</bpmn:process>
64+
<bpmn:collaboration id="collaboration_0">
65+
<bpmn:participant id="node_1" name="Pool" processRef="ProcessId"/>
66+
<bpmn:participant id="node_2" name="Pool" processRef="Process_1"/>
67+
<bpmn:participant id="node_75" name="Pool" processRef="Process_2"/>
68+
<bpmn:messageFlow id="node_19" name="" sourceRef="node_18" targetRef="node_17"/>
69+
<bpmn:messageFlow id="node_105" name="" sourceRef="node_104" targetRef="node_103"/>
70+
</bpmn:collaboration>
71+
<bpmn:process id="Process_1">
72+
<bpmn:startEvent id="node_17" name="Message Start Event">
73+
<bpmn:outgoing>node_53</bpmn:outgoing>
74+
<bpmn:messageEventDefinition messageRef="node_18_message"/>
75+
</bpmn:startEvent>
76+
<bpmn:task id="node_43" name="Form Task 2" pm:screenRef="16" pm:allowInterstitial="false" pm:assignment="requester" pm:assignmentLock="false" pm:allowReassignment="false" pm:config="{&quot;email_notifications&quot;:{&quot;notifications&quot;:[{&quot;sendAt&quot;:&quot;task-start&quot;,&quot;expression&quot;:&quot;&quot;,&quot;subject&quot;:&quot;RE: {{_user.firstname}} assigned you in \&quot;{{_task_name}}\&quot;&quot;,&quot;type&quot;:&quot;screen&quot;,&quot;textBody&quot;:&quot;&quot;,&quot;screenRef&quot;:12,&quot;usersAndGroupsOptionSelected&quot;:null,&quot;toRecipients&quot;:[{&quot;type&quot;:&quot;assignedUser&quot;,&quot;value&quot;:null}],&quot;ccRecipients&quot;:[],&quot;bccRecipients&quot;:[],&quot;i&quot;:15}]},&quot;web_entry&quot;:null}" pm:elementDestination="{&quot;type&quot;:&quot;taskSource&quot;,&quot;value&quot;:null}">
77+
<bpmn:incoming>node_53</bpmn:incoming>
78+
<bpmn:outgoing>node_74</bpmn:outgoing>
79+
</bpmn:task>
80+
<bpmn:endEvent id="node_66" name="End Event" pm:elementDestination="{&quot;type&quot;:&quot;summaryScreen&quot;,&quot;value&quot;:null}">
81+
<bpmn:incoming>node_74</bpmn:incoming>
82+
</bpmn:endEvent>
83+
</bpmn:process>
84+
<bpmn:message id="node_18_message" name="node_18_message"/>
85+
<bpmn:process id="Process_2">
86+
<bpmn:task id="node_77" name="Form Task 3" pm:screenRef="17" pm:allowInterstitial="false" pm:assignment="requester" pm:assignmentLock="false" pm:allowReassignment="false" pm:config="{&quot;email_notifications&quot;:{&quot;notifications&quot;:[{&quot;sendAt&quot;:&quot;task-start&quot;,&quot;expression&quot;:&quot;&quot;,&quot;subject&quot;:&quot;RE: {{_user.firstname}} assigned you in \&quot;{{_task_name}}\&quot;&quot;,&quot;type&quot;:&quot;screen&quot;,&quot;textBody&quot;:&quot;&quot;,&quot;screenRef&quot;:13,&quot;usersAndGroupsOptionSelected&quot;:null,&quot;toRecipients&quot;:[{&quot;type&quot;:&quot;assignedUser&quot;,&quot;value&quot;:null}],&quot;ccRecipients&quot;:[],&quot;bccRecipients&quot;:[],&quot;i&quot;:13}]},&quot;web_entry&quot;:null}" pm:elementDestination="{&quot;type&quot;:&quot;taskSource&quot;,&quot;value&quot;:null}">
87+
<bpmn:incoming>node_88</bpmn:incoming>
88+
<bpmn:outgoing>node_97</bpmn:outgoing>
89+
</bpmn:task>
90+
<bpmn:endEvent id="node_87" name="End Event" pm:elementDestination="{&quot;type&quot;:&quot;summaryScreen&quot;,&quot;value&quot;:null}">
91+
<bpmn:incoming>node_97</bpmn:incoming>
92+
</bpmn:endEvent>
93+
<bpmn:startEvent id="node_103" name="Message Start Event">
94+
<bpmn:outgoing>node_88</bpmn:outgoing>
95+
<bpmn:messageEventDefinition messageRef="node_104_message"/>
96+
</bpmn:startEvent>
97+
</bpmn:process>
98+
<bpmn:message id="node_104_message" name="node_104_message"/>
99+
<bpmndi:BPMNDiagram id="BPMNDiagramId">
100+
<bpmndi:BPMNPlane id="BPMNPlaneId" bpmnElement="collaboration_0">
101+
<bpmndi:BPMNShape id="node_1_di" bpmnElement="node_1">
102+
<dc:Bounds x="196" y="-5" width="608" height="300"/>
103+
</bpmndi:BPMNShape>
104+
<bpmndi:BPMNShape id="node_2_di" bpmnElement="node_2">
105+
<dc:Bounds x="282" y="341" width="600" height="300"/>
106+
</bpmndi:BPMNShape>
107+
<bpmndi:BPMNShape id="node_3_di" bpmnElement="node_3">
108+
<dc:Bounds x="703" y="50" width="36" height="36"/>
109+
</bpmndi:BPMNShape>
110+
<bpmndi:BPMNShape id="node_4_di" bpmnElement="node_4">
111+
<dc:Bounds x="489" y="30" width="116" height="76"/>
112+
</bpmndi:BPMNShape>
113+
<bpmndi:BPMNShape id="node_17_di" bpmnElement="node_17">
114+
<dc:Bounds x="350" y="450" width="36" height="36"/>
115+
</bpmndi:BPMNShape>
116+
<bpmndi:BPMNShape id="node_18_di" bpmnElement="node_18">
117+
<dc:Bounds x="350" y="209" width="36" height="36"/>
118+
</bpmndi:BPMNShape>
119+
<bpmndi:BPMNEdge id="node_19_di" bpmnElement="node_19">
120+
<di:waypoint x="368" y="227"/>
121+
<di:waypoint x="368" y="468"/>
122+
</bpmndi:BPMNEdge>
123+
<bpmndi:BPMNEdge id="node_20_di" bpmnElement="node_20">
124+
<di:waypoint x="721" y="68"/>
125+
<di:waypoint x="547" y="68"/>
126+
</bpmndi:BPMNEdge>
127+
<bpmndi:BPMNShape id="node_43_di" bpmnElement="node_43">
128+
<dc:Bounds x="478" y="430" width="116" height="76"/>
129+
</bpmndi:BPMNShape>
130+
<bpmndi:BPMNEdge id="node_53_di" bpmnElement="node_53">
131+
<di:waypoint x="368" y="468"/>
132+
<di:waypoint x="536" y="468"/>
133+
</bpmndi:BPMNEdge>
134+
<bpmndi:BPMNShape id="node_66_di" bpmnElement="node_66">
135+
<dc:Bounds x="650" y="450" width="36" height="36"/>
136+
</bpmndi:BPMNShape>
137+
<bpmndi:BPMNEdge id="node_74_di" bpmnElement="node_74">
138+
<di:waypoint x="536" y="468"/>
139+
<di:waypoint x="668" y="468"/>
140+
</bpmndi:BPMNEdge>
141+
<bpmndi:BPMNShape id="node_75_di" bpmnElement="node_75">
142+
<dc:Bounds x="880" y="13" width="600" height="300"/>
143+
</bpmndi:BPMNShape>
144+
<bpmndi:BPMNShape id="node_77_di" bpmnElement="node_77">
145+
<dc:Bounds x="1131" y="188" width="116" height="76"/>
146+
</bpmndi:BPMNShape>
147+
<bpmndi:BPMNShape id="node_87_di" bpmnElement="node_87">
148+
<dc:Bounds x="1308" y="208" width="36" height="36"/>
149+
</bpmndi:BPMNShape>
150+
<bpmndi:BPMNEdge id="node_97_di" bpmnElement="node_97">
151+
<di:waypoint x="1189" y="226"/>
152+
<di:waypoint x="1326" y="226"/>
153+
</bpmndi:BPMNEdge>
154+
<bpmndi:BPMNShape id="node_103_di" bpmnElement="node_103">
155+
<dc:Bounds x="1000" y="208" width="36" height="36"/>
156+
</bpmndi:BPMNShape>
157+
<bpmndi:BPMNEdge id="node_88_di" bpmnElement="node_88">
158+
<di:waypoint x="1018" y="226"/>
159+
<di:waypoint x="1189" y="226"/>
160+
</bpmndi:BPMNEdge>
161+
<bpmndi:BPMNShape id="node_104_di" bpmnElement="node_104">
162+
<dc:Bounds x="577" y="209" width="36" height="36"/>
163+
</bpmndi:BPMNShape>
164+
<bpmndi:BPMNEdge id="node_37_di" bpmnElement="node_37">
165+
<di:waypoint x="368" y="227"/>
166+
<di:waypoint x="595" y="227"/>
167+
</bpmndi:BPMNEdge>
168+
<bpmndi:BPMNEdge id="node_105_di" bpmnElement="node_105">
169+
<di:waypoint x="595" y="227"/>
170+
<di:waypoint x="1018" y="226"/>
171+
</bpmndi:BPMNEdge>
172+
<bpmndi:BPMNShape id="node_129_di" bpmnElement="node_129">
173+
<dc:Bounds x="310" y="30" width="116" height="76"/>
174+
</bpmndi:BPMNShape>
175+
<bpmndi:BPMNEdge id="node_153_di" bpmnElement="node_153">
176+
<di:waypoint x="547" y="68"/>
177+
<di:waypoint x="368" y="68"/>
178+
</bpmndi:BPMNEdge>
179+
<bpmndi:BPMNEdge id="node_177_di" bpmnElement="node_177">
180+
<di:waypoint x="368" y="68"/>
181+
<di:waypoint x="368" y="227"/>
182+
</bpmndi:BPMNEdge>
183+
</bpmndi:BPMNPlane>
184+
</bpmndi:BPMNDiagram>
185+
</bpmn:definitions>

0 commit comments

Comments
 (0)