Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
langcode: en
status: true
dependencies:
config:
- eca.eca.eca_lib_0016
id: eca_lib_0016
label: 'Asynchronous views export'
tags:
- simple
- views
- export
- endpoint
- queue
documentation: |-
This model provides an endpoint `/eca/export/users` which can be published as a menu item or a link. When requested, it does this:
- Check access and only allow users with the administror role to cal that endpoint
- Enqueue a task called `export-users` and forward the email address of the current user
- Display a message to the user and redirect them back to the page where they came from
After that, the task is being queued and will be executed by the next cron of the Drupal site. This will then execute the view and export the result into a csv file. Finally, an email will be sent to the user who originally requested the export together with the link from where they can download the export.
Building this model has been recorded: [watch video](https://tube.tchncs.de/w/qpc4qAu2jPMPqcnzV8125h)
filename: ''
modeldata: |
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:qa="http://some-company/schema/bpmn/qa" id="sample-diagram" targetNamespace="http://bpmn.io/schema/bpmn" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:process id="eca_lib_0016" name="Asynchronous views export" isExecutable="true" camunda:versionTag="v1">
<bpmn2:documentation>This model provides an endpoint `/eca/export/users` which can be published as a menu item or a link. When requested, it does this:
- Check access and only allow users with the administror role to cal that endpoint
- Enqueue a task called `export-users` and forward the email address of the current user
- Display a message to the user and redirect them back to the page where they came from
After that, the task is being queued and will be executed by the next cron of the Drupal site. This will then execute the view and export the result into a csv file. Finally, an email will be sent to the user who originally requested the export together with the link from where they can download the export.
Building this model has been recorded: [watch video](https://tube.tchncs.de/w/qpc4qAu2jPMPqcnzV8125h)</bpmn2:documentation>
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="Tags" value="simple,views,export,endpoint,queue" />
<camunda:property name="Changelog v1" value="Initial version" />
</camunda:properties>
</bpmn2:extensionElements>
<bpmn2:startEvent id="Event_0upnk7p" name="Endpoint response event" camunda:modelerTemplate="org.drupal.event.eca_endpoint:response">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_endpoint:response" />
</camunda:properties>
<camunda:field name="first_path_argument">
<camunda:string>export</camunda:string>
</camunda:field>
<camunda:field name="second_path_argument">
<camunda:string>users</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:outgoing>Flow_1830882</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:task id="Activity_077y9bb" name="Get user's email address" camunda:modelerTemplate="org.drupal.action.eca_token_set_value">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_token_set_value" />
</camunda:properties>
<camunda:field name="token_name">
<camunda:string>email</camunda:string>
</camunda:field>
<camunda:field name="token_value">
<camunda:string>[current_user:mail:value]</camunda:string>
</camunda:field>
<camunda:field name="use_yaml">
<camunda:string>no</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:incoming>Flow_1830882</bpmn2:incoming>
<bpmn2:outgoing>Flow_1czmpnn</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:sequenceFlow id="Flow_1830882" sourceRef="Event_0upnk7p" targetRef="Activity_077y9bb" />
<bpmn2:task id="Activity_0udkfuk" name="Enqueue the export task" camunda:modelerTemplate="org.drupal.action.eca_enqueue_task">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_enqueue_task" />
</camunda:properties>
<camunda:field name="task_name">
<camunda:string>export-users</camunda:string>
</camunda:field>
<camunda:field name="task_value">
<camunda:string></camunda:string>
</camunda:field>
<camunda:field name="tokens">
<camunda:string>email</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:incoming>Flow_1czmpnn</bpmn2:incoming>
<bpmn2:outgoing>Flow_1uewb92</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:sequenceFlow id="Flow_1czmpnn" sourceRef="Activity_077y9bb" targetRef="Activity_0udkfuk" />
<bpmn2:task id="Activity_00rb6ol" name="Print message" camunda:modelerTemplate="org.drupal.action.action_message_action">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="action_message_action" />
</camunda:properties>
<camunda:field name="message">
<camunda:string>Your request for the user export has been received. We will notify you by email ([email]) once it's ready for download.</camunda:string>
</camunda:field>
<camunda:field name="replace_tokens">
<camunda:string>yes</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:incoming>Flow_1uewb92</bpmn2:incoming>
<bpmn2:outgoing>Flow_0w66wzy</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:sequenceFlow id="Flow_1uewb92" sourceRef="Activity_0udkfuk" targetRef="Activity_00rb6ol" />
<bpmn2:task id="Activity_0ebf5c5" name="Get the referrer URL" camunda:modelerTemplate="org.drupal.action.eca_endpoint_get_request_header">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_endpoint_get_request_header" />
</camunda:properties>
<camunda:field name="token_name">
<camunda:string>referer</camunda:string>
</camunda:field>
<camunda:field name="name">
<camunda:string>referer</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:incoming>Flow_0w66wzy</bpmn2:incoming>
<bpmn2:outgoing>Flow_18grueb</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:sequenceFlow id="Flow_0w66wzy" sourceRef="Activity_00rb6ol" targetRef="Activity_0ebf5c5" />
<bpmn2:task id="Activity_1mwsdsv" name="Redirect the user" camunda:modelerTemplate="org.drupal.action.action_goto_action">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="action_goto_action" />
</camunda:properties>
<camunda:field name="url">
<camunda:string>[referer]</camunda:string>
</camunda:field>
<camunda:field name="replace_tokens">
<camunda:string>yes</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:incoming>Flow_18grueb</bpmn2:incoming>
</bpmn2:task>
<bpmn2:sequenceFlow id="Flow_18grueb" sourceRef="Activity_0ebf5c5" targetRef="Activity_1mwsdsv" />
<bpmn2:startEvent id="Event_079c3t3" name="Verify access to the endpoint" camunda:modelerTemplate="org.drupal.event.eca_endpoint:access">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_endpoint:access" />
</camunda:properties>
<camunda:field name="first_path_argument">
<camunda:string>export</camunda:string>
</camunda:field>
<camunda:field name="second_path_argument">
<camunda:string>users</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:outgoing>Flow_1qwm7o2</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:task id="Activity_03czabg" name="Allow access" camunda:modelerTemplate="org.drupal.action.eca_access_set_result">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_access_set_result" />
</camunda:properties>
<camunda:field name="access_result">
<camunda:string>allowed</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:incoming>Flow_1qwm7o2</bpmn2:incoming>
</bpmn2:task>
<bpmn2:sequenceFlow id="Flow_1qwm7o2" name="is admin?" camunda:modelerTemplate="org.drupal.condition.eca_current_user_role" sourceRef="Event_079c3t3" targetRef="Activity_03czabg">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_current_user_role" />
</camunda:properties>
<camunda:field name="role">
<camunda:string>administrator</camunda:string>
</camunda:field>
<camunda:field name="negate">
<camunda:string>no</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
</bpmn2:sequenceFlow>
<bpmn2:startEvent id="Event_0k7tmxh" name="Process task export-users" camunda:modelerTemplate="org.drupal.event.eca_queue:processing_task">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_queue:processing_task" />
</camunda:properties>
<camunda:field name="task_name">
<camunda:string>export-users</camunda:string>
</camunda:field>
<camunda:field name="task_value">
<camunda:string></camunda:string>
</camunda:field>
<camunda:field name="distribute">
<camunda:string>no</camunda:string>
</camunda:field>
<camunda:field name="cron">
<camunda:string></camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:outgoing>Flow_1vhshhg</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:task id="Activity_0lbjb7k" name="Run export" camunda:modelerTemplate="org.drupal.action.eca_views_export">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_views_export" />
</camunda:properties>
<camunda:field name="load_results_into_token">
<camunda:string>no</camunda:string>
</camunda:field>
<camunda:field name="token_name">
<camunda:string></camunda:string>
</camunda:field>
<camunda:field name="view_id">
<camunda:string>user_admin_people</camunda:string>
</camunda:field>
<camunda:field name="display_id">
<camunda:string>data_export_1</camunda:string>
</camunda:field>
<camunda:field name="arguments">
<camunda:string></camunda:string>
</camunda:field>
<camunda:field name="token_for_filename">
<camunda:string></camunda:string>
</camunda:field>
<camunda:field name="filename">
<camunda:string>private://user-export.csv</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:incoming>Flow_0nkpjhl</bpmn2:incoming>
<bpmn2:outgoing>Flow_1p088d5</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:sequenceFlow id="Flow_1vhshhg" sourceRef="Event_0k7tmxh" targetRef="Activity_13dr0m3" />
<bpmn2:task id="Activity_0kl7hjm" name="Send email" camunda:modelerTemplate="org.drupal.action.action_send_email_action">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="action_send_email_action" />
</camunda:properties>
<camunda:field name="recipient">
<camunda:string>[email]</camunda:string>
</camunda:field>
<camunda:field name="subject">
<camunda:string>Your export is available for download</camunda:string>
</camunda:field>
<camunda:field name="message">
<camunda:string>You can find it here: [site:url]sites/default/private/user-export.csv</camunda:string>
</camunda:field>
<camunda:field name="replace_tokens">
<camunda:string>yes</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:incoming>Flow_1p088d5</bpmn2:incoming>
</bpmn2:task>
<bpmn2:sequenceFlow id="Flow_1p088d5" sourceRef="Activity_0lbjb7k" targetRef="Activity_0kl7hjm" />
<bpmn2:task id="Activity_13dr0m3" name="Switch user" camunda:modelerTemplate="org.drupal.action.eca_switch_account">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_switch_account" />
</camunda:properties>
<camunda:field name="user_id">
<camunda:string>1</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:incoming>Flow_1vhshhg</bpmn2:incoming>
<bpmn2:outgoing>Flow_0nkpjhl</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:sequenceFlow id="Flow_0nkpjhl" sourceRef="Activity_13dr0m3" targetRef="Activity_0lbjb7k" />
</bpmn2:process>
<bpmndi:BPMNDiagram id="sid-fa53906d-c46e-4756-b923-ce3a6554cd0d">
<bpmndi:BPMNPlane id="sid-c61c351f-1564-4cce-8b6c-5dce9ce1c3d8" bpmnElement="eca_lib_0016">
<bpmndi:BPMNShape id="Event_0upnk7p_di" bpmnElement="Event_0upnk7p">
<dc:Bounds x="252" y="82" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="233" y="125" width="76" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_077y9bb_di" bpmnElement="Activity_077y9bb">
<dc:Bounds x="340" y="60" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0udkfuk_di" bpmnElement="Activity_0udkfuk">
<dc:Bounds x="500" y="60" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_00rb6ol_di" bpmnElement="Activity_00rb6ol">
<dc:Bounds x="660" y="60" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0ebf5c5_di" bpmnElement="Activity_0ebf5c5">
<dc:Bounds x="820" y="60" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1mwsdsv_di" bpmnElement="Activity_1mwsdsv">
<dc:Bounds x="980" y="60" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_079c3t3_di" bpmnElement="Event_079c3t3">
<dc:Bounds x="252" y="202" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="232" y="245" width="78" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_03czabg_di" bpmnElement="Activity_03czabg">
<dc:Bounds x="340" y="180" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0k7tmxh_di" bpmnElement="Event_0k7tmxh">
<dc:Bounds x="252" y="342" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="239" y="385" width="63" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0lbjb7k_di" bpmnElement="Activity_0lbjb7k">
<dc:Bounds x="500" y="320" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0kl7hjm_di" bpmnElement="Activity_0kl7hjm">
<dc:Bounds x="660" y="320" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_13dr0m3_di" bpmnElement="Activity_13dr0m3">
<dc:Bounds x="340" y="320" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1830882_di" bpmnElement="Flow_1830882">
<di:waypoint x="288" y="100" />
<di:waypoint x="340" y="100" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1czmpnn_di" bpmnElement="Flow_1czmpnn">
<di:waypoint x="440" y="100" />
<di:waypoint x="500" y="100" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1uewb92_di" bpmnElement="Flow_1uewb92">
<di:waypoint x="600" y="100" />
<di:waypoint x="660" y="100" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0w66wzy_di" bpmnElement="Flow_0w66wzy">
<di:waypoint x="760" y="100" />
<di:waypoint x="820" y="100" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_18grueb_di" bpmnElement="Flow_18grueb">
<di:waypoint x="920" y="100" />
<di:waypoint x="980" y="100" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1qwm7o2_di" bpmnElement="Flow_1qwm7o2">
<di:waypoint x="288" y="220" />
<di:waypoint x="340" y="220" />
<bpmndi:BPMNLabel>
<dc:Bounds x="291" y="202" width="48" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1vhshhg_di" bpmnElement="Flow_1vhshhg">
<di:waypoint x="288" y="360" />
<di:waypoint x="340" y="360" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1p088d5_di" bpmnElement="Flow_1p088d5">
<di:waypoint x="600" y="360" />
<di:waypoint x="660" y="360" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0nkpjhl_di" bpmnElement="Flow_0nkpjhl">
<di:waypoint x="440" y="360" />
<di:waypoint x="500" y="360" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>