-
Notifications
You must be signed in to change notification settings - Fork 0
/
mappings.xml
executable file
·563 lines (560 loc) · 47.6 KB
/
mappings.xml
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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:validation="http://www.mulesoft.org/schema/mule/validation" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:mulerequester="http://www.mulesoft.org/schema/mule/mulerequester" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/mulerequester http://www.mulesoft.org/schema/mule/mulerequester/current/mule-mulerequester.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/validation http://www.mulesoft.org/schema/mule/validation/current/mule-validation.xsd">
<http:request-config name="vlaamsparlement_api" host="ws.vlpar.be" port="80" basePath="/" doc:name="HTTP Request Configuration" responseTimeout="20000">
<http:proxy host="proxy.do.viaa.be" port="80"/>
</http:request-config>
<http:request-config name="edtf_validator" host="${edtfLocal.host}" port="80" doc:name="HTTP Request Configuration" responseTimeout="20000">
<http:proxy host="proxy.do.viaa.be" port="80"/>
</http:request-config>
<sub-flow name="PI_METADATA_MAPPING_MHEM">
<set-variable variableName="eventName" value="PI_METADATA_MAPPING" doc:name="Set Name"/>
<set-variable variableName="comment" value="#[flowVars.httpResult]" doc:name="Set Comment"/>
<set-payload value="#[flowVars.incomingXml]" doc:name="Set Payload with incomingXml"/>
<mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
<set-variable variableName="CreationDate" value="#[xpath3("//*[local-name() = 'dcterms_issued']/text()") != "" ? (xpath3("//*[local-name() = 'dcterms_issued']/text()").replaceAll('-', ':').substring(0,10) + " 00:00:00") : null]" doc:name="Set CreationDate from dcterms_issued (from EDTF to EXIF)"/>
<dw:transform-message metadata:id="d696f7ed-e9b9-4f34-8265-1191510a0be4" doc:name="Transform Message">
<dw:input-payload doc:sample="sample_data/empty.xml"/>
<dw:input-variable variableName="comment"/>
<dw:input-variable doc:sample="sample_data/string.dwl" variableName="CreationDate"/>
<dw:input-variable doc:sample="sample_data/string_1.dwl" mimeType="application/java" variableName="filenameEssence"/>
<dw:input-variable doc:sample="sample_data/list_string.dwl" mimeType="application/java" variableName="pid_collateral"/>
<dw:input-variable doc:sample="sample_data/map.dwl" variableName="cp"/>
<dw:input-variable doc:sample="sample_data/map_1.dwl" variableName="pid"/>
<dw:input-variable doc:sample="sample_data/MyPojo.dwl" variableName="cp_id"/>
<dw:input-variable doc:sample="/Users/dieter/VIAA/borndigital/src/test/resources/sample_data/list_String.dwl" mimeType="application/java" variableName="collaterals"/>
<dw:set-payload><![CDATA[%dw 1.0
%input payload application/xml
%output application/xml skipNullOn="everywhere"
%function split(name) name splitBy ","
---
{
MediaHAVEN_external_metadata: {
title: payload.VIAA.dc_title when payload.VIAA.dc_title?
otherwise (payload.VIAA.dc_titles[0] when (payload.VIAA.dc_titles?)
otherwise (payload.VIAA.dc_description_short when payload.VIAA.dc_description_short?
otherwise "")),
description: payload.VIAA.dc_description when payload.VIAA.dc_description?
otherwise (payload.VIAA.dc_description_short when payload.VIAA.dc_description_short?
otherwise ""),
MDProperties: {
(payload.*VIAA map (
$ mapObject {
'$$': $ when ('$$' != 'dc_relations' and '$$' != 'CP_id') otherwise null
}
)),
(sp_name: 'borndigital') when payload.VIAA.sp_name == null,
(CP: flowVars.cp) when payload.VIAA.CP == null,
CP_id: flowVars.cp_id,
PID: flowVars.pid,
dc_relations @(type: "list"): {
(flowVars.collaterals default [] map (bevat: $)),
((payload.VIAA.dc_relations mapObject ('$$': $)) when payload.VIAA.dc_relations? and (sizeOf payload.VIAA.dc_relations) > 0 and not payload.VIAA.dc_relations is :string otherwise {})
},
(CreationDate: flowVars.CreationDate) when flowVars.CreationDate != null,
(dc_source: flowVars.filenameEssence) when payload.VIAA.dc_source == null
// Default VIAA license?
//dc_rights_licenses @(type: "list"): {
// (licentie: flowVars.license) when flowVars.license?
//}
}
}
}]]></dw:set-payload>
</dw:transform-message>
<mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
<set-variable variableName="mappedXml" value="#[payload]" doc:name="Set mappedXml"/>
<set-variable variableName="result" value="OK" doc:name="Set result OK"/>
<set-variable variableName="comment" value="The input XML was mapped succesfully: #[payload]" doc:name="Set comment"/>
<flow-ref name="PI_LOG" doc:name="PI_LOG"/>
</sub-flow>
<flow name="get_sidecar">
<logger message="Start get_sidecar: #[payload]" level="INFO" doc:name="Start get_sidecar"/>
<mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
<logger message="After: #[payload]" level="INFO" doc:name="Logger"/>
</flow>
<sub-flow name="PI_METADATA_MAPPING_VRT">
<set-variable variableName="eventName" value="PI_METADATA_MAPPING" doc:name="Set Name"/>
<set-variable variableName="comment" value="#[flowVars.httpResult]" doc:name="Set Comment"/>
<set-payload value="#[flowVars.incomingXml]" doc:name="Set Payload"/>
<mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
<dw:transform-message doc:name="Transform Message" metadata:id="ef2d489e-12ad-4b91-8add-659011b32d9a">
<dw:input-variable doc:sample="string_1.dwl" variableName="origin"/>
<dw:input-variable doc:sample="string_2.dwl" variableName="mediaId"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/xml
---
{
MediaHAVEN_external_metadata:
{
title: flowVars.pid ++ "-" ++ flowVars.local_id,
MDProperties: {
CP: p('cp'),
CP_id: flowVars.cp_id,
sp_name: 'dailies' when flowVars.origin != 'tape' otherwise 'intake_existing',
PID: flowVars.pid,
dc_identifier_localid: flowVars.local_id,
(md5: flowVars.md5metadata) when flowVars.md5metadata?
}
}
}]]></dw:set-payload>
</dw:transform-message>
<mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
<set-variable variableName="mappedXml" value="#[payload]" doc:name="Set mappedXml"/>
<!--
<message-filter throwOnUnaccepted="true" doc:name="Check output format">
<and-filter>
<expression-filter expression="#[flowVars.comment = "Output format is incorrect."]"/>
</and-filter>
</message-filter>
-->
<set-variable variableName="result" value="OK" doc:name="Set result OK"/>
<set-variable variableName="comment" value="The input XML was mapped succesfully: #[payload]" doc:name="Set comment"/>
<flow-ref name="PI_LOG" doc:name="PI_LOG"/>
</sub-flow>
<sub-flow name="PI_METADATA_MAPPING_VLAAMS_PARLEMENT">
<set-variable variableName="eventName" value="PI_METADATA_MAPPING" doc:name="Set Name"/>
<set-variable variableName="comment" value="#[flowVars.httpResult]" doc:name="Set Comment"/>
<set-payload value="#[flowVars.incomingXml]" doc:name="Set Payload with sidecar"/>
<mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
<set-variable variableName="filenameEssence" value="#[flowVars.filenameEssence != null ? flowVars.filenameEssence : xpath3("//dc_source/text()")]" doc:name="Set filenameEssence"/>
<set-variable variableName="total" value="#[flowVars.filenameEssence.replaceAll('^.*_[1-9]+v([1-9]+)\\..*', '$1') != flowVars.filenameEssence ? flowVars.filenameEssence.replaceAll('^.*_[1-9]+v([1-9]+)\\..*', '$1') : "1"]" doc:name="Set total"/>
<until-successful maxRetries="2" millisBetweenRetries="5000" synchronous="true" doc:name="Until Successful">
<http:request config-ref="vlaamsparlement_api" path="#['/e/opendata/verg/' + flowVars.local_id]" method="GET" doc:name="Get metadata from open data portal">
<http:request-builder>
<http:header headerName="Accept" value="application/json"/>
</http:request-builder>
</http:request>
</until-successful>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<json:json-to-object-transformer doc:name="JSON to Object" returnClass="java.util.HashMap"/>
<set-variable variableName="vergadering_response" value="#[payload]" doc:name="Set vergadering_response"/>
<set-variable variableName="type" value="#[payload.get("vergadering").get("type").toString()]" doc:name="Set type (Plenair | Commissie)"/>
<choice doc:name="Plenaire or commissie?">
<when expression="#[flowVars.type == "Plenair"]">
<set-variable variableName="titelType" value="#["Plenaire vergadering"]" doc:name="Set titelType plenaire"/>
</when>
<otherwise>
<set-variable variableName="titelType" value="#[payload.vergadering.commissie[0].titel]" doc:name="Set titelType"/>
</otherwise>
</choice>
<set-variable variableName="datumBegin" value="#[payload.get("vergadering").get("datumbegin").toString().substring(0,19)]" doc:name="Set datumBegin"/>
<set-variable variableName="dayOfWeek" value="#[new org.mule.el.datetime.DateTime(flowVars.datumBegin).getDayOfWeek()]" doc:name="Set dayOfWeek"/>
<choice doc:name="Choice">
<when expression="#[flowVars.dayOfWeek == "1"]">
<set-variable variableName="dag" value="#["zondag"]" doc:name="Set dag zondag"/>
</when>
<when expression="#[flowVars.dayOfWeek == "7"]">
<set-variable variableName="dag" value="#["zaterdag"]" doc:name="Set dag zaterdag"/>
</when>
<when expression="#[flowVars.dayOfWeek == "6"]">
<set-variable variableName="dag" value="#["vrijdag"]" doc:name="Set dag vrijdag"/>
</when>
<when expression="#[flowVars.dayOfWeek == "5"]">
<set-variable variableName="dag" value="#["donderdag"]" doc:name="Set dag donderdag"/>
</when>
<when expression="#[flowVars.dayOfWeek == "4"]">
<set-variable variableName="dag" value="#["woensdag"]" doc:name="Set dag woensdag"/>
</when>
<when expression="#[flowVars.dayOfWeek == "3"]">
<set-variable variableName="dag" value="#["dinsdag"]" doc:name="Set dag dinsdag"/>
</when>
<otherwise>
<set-variable variableName="dag" value="#["maandag"]" doc:name="Set dag maandag"/>
</otherwise>
</choice>
<set-variable variableName="month" value="#[new org.mule.el.datetime.DateTime(flowVars.datumBegin).getMonth()]" doc:name="Set month"/>
<choice doc:name="Choice">
<when expression="#[flowVars.month == 5]">
<set-variable variableName="maand" value="#["mei"]" doc:name="Set maand mei"/>
</when>
<when expression="#[flowVars.month == 4]">
<set-variable variableName="maand" value="#["april"]" doc:name="Set maand april"/>
</when>
<when expression="#[flowVars.month == 3]">
<set-variable variableName="maand" value="#["maart"]" doc:name="Set maand maart"/>
</when>
<when expression="#[flowVars.month == 2]">
<set-variable variableName="maand" value="#["februari"]" doc:name="Set maand februari"/>
</when>
<when expression="#[flowVars.month == 10]">
<set-variable doc:name="Set maand oktober" value="#["oktober"]" variableName="maand"/>
</when>
<when expression="#[flowVars.month == 9]">
<set-variable doc:name="Set maand september" value="#["september"]" variableName="maand"/>
</when>
<when expression="#[flowVars.month == 8]">
<set-variable doc:name="Set maand augustus" value="#["augustus"]" variableName="maand"/>
</when>
<when expression="#[flowVars.month == 7]">
<set-variable doc:name="Set maand juli" value="#["juli"]" variableName="maand"/>
</when>
<when expression="#[flowVars.month == 6]">
<set-variable doc:name="Set maand juni" value="#["juni"]" variableName="maand"/>
</when>
<when expression="#[flowVars.month == 11]">
<set-variable variableName="maand" value="#["november"]" doc:name="Set maand november"/>
</when>
<when expression="#[flowVars.month == 12]">
<set-variable variableName="maand" value="#["december"]" doc:name="Set maand december"/>
</when>
<otherwise>
<set-variable variableName="maand" value="#["januari"]" doc:name="Set maand januari"/>
</otherwise>
</choice>
<set-variable variableName="datumTitel" value="#[flowVars.dag + " " + flowVars.datumBegin.substring(8,10).replaceFirst("^0+(?!$)", "") + " " + flowVars.maand + " " + flowVars.datumBegin.substring(0,4) + ", " + flowVars.datumBegin.substring(11,13) + "." + flowVars.datumBegin.substring(14,16) + "u"]" doc:name="Set datumTitel (bv. Plenaire vergadering woensdag 16 november 2011, 14.00u)"/>
<set-variable variableName="CreationDate" value="#[payload.get("vergadering").get("datumbegin").toString().substring(0,10).replaceAll('-', ':') + " " + payload.get("vergadering").get("datumbegin").toString().substring(11,19).replaceAll('-',':')]" doc:name="Set CreationDate (MH)"/>
<expression-component doc:name="Set deel from filename"><![CDATA[#[flowVars.deel = flowVars.filenameEssence.replaceAll('^.*_([1-9]+)v[1-9]+\\..*', '$1') != flowVars.filenameEssence ? (" (Deel " + flowVars.filenameEssence.replaceAll('^.*_([1-9]+)v[1-9]+\\..*', '$1') + "/" + flowVars.total + ") ") : "" ]]]></expression-component>
<json:json-to-object-transformer returnClass="java.util.HashMap" doc:name="JSON to Object"/>
<flow-ref name="PI_METADATA_MAPPING_VLAAMSPARLEMENT_DESCRIPTION" doc:name="PI_METADATA_MAPPING_VLAAMSPARLEMENT_DESCRIPTION"/>
<flow-ref name="PI_METADATA_MAPPING_VLAAMSPARLEMENT_TRANSCRIPTIE_AND_DESCRIPTION_LANG" doc:name="PI_METADATA_MAPPING_VLAAMSPARLEMENT_TRANSCRIPTIE_AND_DESCRIPTION_LANG"/>
<set-payload value="#[flowVars.vergadering_response]" doc:name="Set Payload with vergadering_response"/>
<dw:transform-message metadata:id="d696f7ed-e9b9-4f34-8265-1191510a0be4" doc:name="Transform Message">
<dw:input-payload doc:sample="sample_data/json.json"/>
<dw:input-variable variableName="comment"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/xml
---
{
MediaHAVEN_external_metadata: {
title: flowVars.titelType ++ " " ++ flowVars.deel ++ flowVars.datumTitel,
description: flowVars.dc_description,
MDProperties: {
PID: flowVars.pid,
CP: 'Vlaams Parlement',
CP_id: 'OR-7h1dk9t',
sp_name: 'borndigital',
dc_source: flowVars.filenameEssence,
dc_identifier_localid: flowVars.local_id,
dc_identifier_localids @(type: "list"): {
(pdf: payload.vergadering.commissiehandelingen.pdffilewebpath when flowVars.type == "Commissie"
otherwise payload.vergadering.plenairehandelingen.pdffilewebpath) when payload.vergadering != null,
bestandsnaam: flowVars.filenameEssence,
api: 'http://ws.vlpar.be/e/opendata/verg/' ++ flowVars.local_id
},
(dc_titles @(type: "list"): {
reeks: payload.vergadering.commissie[0].titel when flowVars.type == "Commissie"
otherwise "Plenair"
}) when payload.vergadering != null,
CreationDate: flowVars.CreationDate,
dcterms_issued: flowVars.datumBegin,
dcterms_created: flowVars.datumBegin,
(dc_contributors @(type: "list"): {
(voorzitter: payload.vergadering.voorzitter.voornaam ++ " " ++
payload.vergadering.voorzitter.naam ++ " (" ++
payload.vergadering.voorzitter.fractie.naam ++ ")") when payload.vergadering.voorzitter?,
(((payload.vergadering.aanwezigheid) when payload.vergadering.aanwezigheid? otherwise []) map using (aanwezigheid = $) {
(aanwezigheid.persoon map using (persoon = $) {
(lower aanwezigheid.aanwezigheid-status): (persoon.voornaam ++ " " ++ persoon.naam ++ " (" ++ persoon.fractie.naam ++ ")")
})
})
}) when payload.vergadering != null,
(dc_subjects @(type: "list"): {
Trefwoord: "Vergaderzaal: " ++ payload.vergadering.vergaderzaal.naam when payload.vergadering.vergaderzaal.naam?
otherwise ("Koepel" when flowVars.type == "Plenair" otherwise "onbekend")
}) when payload.vergadering != null,
dc_description: flowVars.dc_description,
dc_description_lang: flowVars.dc_description_lang,
dc_description_transcriptie: flowVars.transcriptie replace " " with "",
dc_rights_licenses @(type: "list"): {
multiselect: "VIAA-ONDERWIJS",
multiselect: "VIAA-ONDERZOEK",
multiselect: "VIAA-INTRA_CP-CONTENT",
multiselect: "VIAA-INTRA_CP-METADATA-ALL",
multiselect: "VIAA-PUBLIEK-METADATA-LTD",
multiselect: "VIAA-PUBLIEK-METADATA-ALL",
multiselect: "VIAA-PUBLIEK-CONTENT",
multiselect: "CC-BY-SA-CONTENT"
},
dc_rights_rightsOwners @(type: "list"): {
Auteursrechthouder: "Vlaams Parlement"
},
dc_rights_rightsHolders @(type: "list"): {
Licentiehouder: "Vlaams Parlement"
},
md5: flowVars.md5metadata
}
}
}]]></dw:set-payload>
</dw:transform-message>
<mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
<set-variable variableName="mappedXml" value="#[payload]" doc:name="Set MappedXml"/>
<set-variable variableName="result" value="OK" doc:name="Set result OK"/>
<set-variable variableName="comment" value="The input XML was mapped succesfully" doc:name="Set comment"/>
<flow-ref name="PI_LOG" doc:name="PI_LOG"/>
</sub-flow>
<sub-flow name="PI_METADATA_MAPPING_VLAAMSPARLEMENT_DESCRIPTION">
<set-variable variableName="dc_description" value="#[""]" doc:name="init dc_description"/>
<foreach collection="#[payload.get('vergadering').get('agenda-item')]" doc:name="For Each agenda-item" counterVariableName="counterItem">
<set-variable variableName="agenda_lijnen" value="#[""]" doc:name="Init agenda_lijnen"/>
<foreach collection="#[payload.get('agenda-lijn')]" doc:name="For Each agenda-lijn" counterVariableName="counterLijn">
<set-variable variableName="titel" value="#[payload.titel != null ? payload.titel + "\n" : ""]" doc:name="Set titel"/>
<set-variable variableName="omschrijving" value="#[payload.omschrijving != null ? payload.omschrijving + "\n" : ""]" doc:name="Set omschrijving"/>
<set-variable variableName="agendalijntype" value="#[payload.'agenda-lijn-type' != null && payload.'agenda-lijn-type'.naam != 'Tekst kader vet' ? payload.'agenda-lijn-type'.naam + "\n" : ""]" doc:name="Set agendalijntype"/>
<set-variable variableName="debat" value="#[""]" doc:name="Reset debat"/>
<choice doc:name="debat > 0?">
<when expression="#[payload.'debat'.size() > 0]">
<foreach collection="#[payload.'debat']" doc:name="For Each debat">
<set-variable variableName="zittingsjaar" value="#[payload.zittingsjaar != null && payload.zittingsjaar != "" ? "(" + payload.zittingsjaar + ")" : ""]" doc:name="Set zittingsjaar"/>
<set-variable variableName="nummer" value="#[payload.nummer != null && payload.nummer != "" ? payload.nummer + " " : ""]" doc:name="Set nummer"/>
<set-variable variableName="debat" value="#[flowVars.'debat' != null ? (flowVars.'debat' + payload.titel + "\n" + flowVars.nummer + flowVars.zittingsjaar + "\n") : (payload.titel + "\n" + flowVars.nummer + flowVars.zittingsjaar)]" doc:name="Set debat"/>
</foreach>
</when>
<otherwise>
<set-variable doc:name="Set debat empty" value="#[""]" variableName="debat"/>
</otherwise>
</choice>
<set-variable variableName="gedachtewisseling" value="#[""]" doc:name="Reset gedachtewisseling"/>
<choice tracking:enable-default-events="true" doc:name="Gedachtewisseling > 0?">
<when expression="#[payload.'gedachtewisseling'.size() > 0]">
<foreach collection="#[payload.'gedachtewisseling']" doc:name="For Each gedachtewisseling">
<set-variable variableName="gedachtewisseling" value="#[flowVars.'gedachtewisseling' != null ? (flowVars.'gedachtewisseling' + payload.titel + "\n") : (payload.titel + "\n")]" doc:name="Set gedachtewisseling"/>
</foreach>
</when>
<otherwise>
<set-variable variableName="gedachtewisseling" value="#[""]" doc:name="Set gedachtewisseling empty"/>
</otherwise>
</choice>
<set-variable variableName="parlementair_initiatieven" value="#[null]" doc:name="Reset parlementair_initiatieven"/>
<choice doc:name="Parlementaire initieven > 0?">
<when expression="#[payload.'parlementair-initiatief'.size() > 0]">
<foreach collection="#[payload.'parlementair-initiatief']" doc:name="For Each parlementaire initiatief">
<set-variable variableName="zittingsjaar" value="#[payload.zittingsjaar != null && payload.zittingsjaar != "" ? "(" + payload.zittingsjaar + ")" : ""]" doc:name="Set zittingsjaar"/>
<set-variable variableName="nummer" value="#[payload.nummer != null && payload.nummer != "" ? payload.nummer + " " : ""]" doc:name="Set nummer"/>
<set-variable variableName="materie" value="#[payload.materie != null && payload.materie != "" ? payload.materie + "\n" : ""]" doc:name="Set materie"/>
<set-variable variableName="volgnummer" value="#[payload.volgnr != null && payload.volgnr != "" ? " nr. " + payload.volgnr : ""]" doc:name="Set volgnummer"/>
<set-variable variableName="parlementair_initiatieven" value="#[flowVars.'parlementair_initiatieven' != null ? (flowVars.'parlementair_initiatieven' + payload.titel + "\n" + flowVars.nummer + flowVars.zittingsjaar + flowVars.volgnummer + "\n" + flowVars.materie + "\n") : (payload.titel + "\n" + flowVars.nummer + flowVars.zittingsjaar + flowVars.volgnummer + "\n" + flowVars.materie + "\n")]" doc:name="Set parlementair_initiatieven"/>
</foreach>
</when>
<otherwise>
<set-variable variableName="parlementair_initiatieven" value="#[""]" doc:name="Set parlementair_initiatieven empty"/>
</otherwise>
</choice>
<set-variable variableName="vrageninterpellatie" value="#[null]" doc:name="Reset vrageninterpellatie"/>
<choice doc:name="Vrageninterpellaties > 0?">
<when expression="#[payload.vrageninterpellatie.size() > 0]">
<foreach collection="#[payload.vrageninterpellatie]" doc:name="For Each vrageninterpellatie">
<set-variable variableName="zittingsjaar" value="#[payload.zittingsjaar != null && payload.zittingsjaar != "" ? "(" + payload.zittingsjaar + ")" : ""]" doc:name="Set zittingsjaar"/>
<set-variable variableName="nummer" value="#[payload.nummer != null && payload.nummer != "" ? payload.nummer + " " : ""]" doc:name="Set nummer"/>
<set-variable variableName="materie" value="#[payload.materie != null && payload.materie != "" ? payload.materie + "\n" : ""]" doc:name="Set materie"/>
<set-variable variableName="volgnummer" value="#[payload.volgnr != null && payload.volgnr != "" ? " nr. " + payload.volgnr : ""]" doc:name="Set volgnummer"/>
<set-variable variableName="vrageninterpellatie" value="#[flowVars.vrageninterpellatie != null ? (flowVars.vrageninterpellatie + payload.titel + "\n" + flowVars.nummer + flowVars.zittingsjaar + flowVars.volgnummer + "\n" + flowVars.materie + "\n") : (payload.titel + "\n" + flowVars.nummer + flowVars.zittingsjaar + flowVars.volgnummer + "\n"+ flowVars.materie + "\n")]" doc:name="Set vrageninterpellatie"/>
</foreach>
</when>
<otherwise>
<set-variable variableName="vrageninterpellatie" value="#[""]" doc:name="Set vrageninterpellatie empty"/>
</otherwise>
</choice>
<set-variable variableName="agenda_lijnen" value="#[flowVars.agenda_lijnen += flowVars.agendalijntype + flowVars.debat + flowVars.gedachtewisseling + flowVars.'parlementair_initiatieven' + flowVars.vrageninterpellatie + flowVars.titel + flowVars.omschrijving + "\n"]" doc:name="Set agenda_lijnen"/>
</foreach>
<set-variable variableName="dc_description" value="#[flowVars.dc_description += flowVars.agenda_lijnen]" doc:name="Set dc_description by concat agenda_lijnen"/>
<set-variable variableName="dc_description" value="#[flowVars.dc_description.replaceAll('<br/>', "\n")]" doc:name="Change <br/> to newlines"/>
<set-variable variableName="dc_description" value="#[flowVars.dc_description.replaceAll("\\<[^>]*>","")]" doc:name="Remove html tags from dc_description"/>
</foreach>
</sub-flow>
<sub-flow name="PI_METADATA_MAPPING_VLAAMSPARLEMENT_TRANSCRIPTIE_AND_DESCRIPTION_LANG">
<set-variable variableName="transcriptie" value="#[""]" doc:name="Set transcriptie empty"/>
<set-variable variableName="dc_description_lang" value="#[""]" doc:name="Set dc_description_lang empty"/>
<foreach collection="#[payload.get('vergadering').get('journaallijn')]" doc:name="For Each journaallijn">
<set-variable variableName="journaalllijn_subtitel" value="#[payload.get("titel")]" doc:name="Set journaalllijn_subtitel"/>
<set-variable variableName="journaallijn_voorzitter" value="#["Voorzitter: " + payload.get("vergadering").get("voorzitter").get("aanspreking") + " " + payload.get("vergadering").get("voorzitter").get("voornaam") + " " + payload.get("vergadering").get("voorzitter").get("naam")]" doc:name="Set journaallijn_voorzitter"/>
<set-variable variableName="journaallijn_titel" value="#[payload.get("titel")]" doc:name="Set journaallijn_titel"/>
<set-variable variableName="titel-samenstelling" value="#[payload.get("titel-samenstelling")]" doc:name="Set titel-samenstelling"/>
<set-variable variableName="url" value="#[payload.get('link')[0].get('href')]" doc:name="Set url"/>
<set-variable variableName="path" value="#[flowVars.url.substring(flowVars.url.indexOf('/e/opendata/'))]" doc:name="Set path"/>
<http:request config-ref="vlaamsparlement_api" path="#[flowVars.path]" method="GET" doc:name="Get journaallijn">
<http:request-builder>
<http:header headerName="Accept" value="application/json"/>
</http:request-builder>
</http:request>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<json:json-to-object-transformer returnClass="java.util.HashMap" doc:name="JSON to Object"/>
<set-variable variableName="debat" value="#[""]" doc:name="Reset debat"/>
<set-variable variableName="gesprek" value="#[""]" doc:name="Reset gesprek"/>
<foreach collection="#[payload.get('spreker')]" doc:name="For Each spreker">
<choice doc:name="Sprekertitel null?">
<when expression="#[payload.get('sprekertitel') == null]">
<set-variable variableName="gesprek" value="#[flowVars.gesprek + payload.get('sprekertekst').toString().replaceAll("\\<[^>]*>","") + "\n"]" doc:name="Append sprekertekst to gesprek"/>
</when>
<when expression="#[payload.get('sprekertitel') == null && payload.get('sprekertekst') == null]]">
<expression-component doc:name="Do nothing because sprekertitel en sprekertekst empty"><![CDATA[// do nothing]]></expression-component>
</when>
<otherwise>
<set-variable variableName="gesprek" value="#[flowVars.gesprek + payload.get('sprekertitel').toString().replaceAll("\\<[^>]*>","") + ": " + payload.get('sprekertekst').toString().replaceAll("\\<[^>]*>","") + "\n"]" doc:name="Append sprekertitel + sprekertekst to gesprek (remove first, last characters and html tags)"/>
</otherwise>
</choice>
</foreach>
<choice doc:name="Choice">
<when expression="#[flowVars.gesprek == ""]">
<expression-component doc:name="do nothing"><![CDATA[// do nothing]]></expression-component>
</when>
<otherwise>
<expression-component doc:name="Append gesprek to transcriptie"><![CDATA[#[flowVars.transcriptie += flowVars.journaallijn_titel + "\n" + flowVars.gesprek]]]></expression-component>
</otherwise>
</choice>
</foreach>
<custom-transformer class="utils.UnescapeHtml" doc:name="Remove HTML escaping"/>
<set-variable variableName="transcriptie" value="#[payload]" doc:name="Set transcriptie with unescaped HTML"/>
<foreach collection="#[flowVars.vergadering_response.get('vergadering').get('journaallijn')]" doc:name="For Each journaallijn">
<set-variable variableName="journaallijn_titel" value="#[payload.titel + "\n"]" doc:name="Set journaallijn_titel"/>
<set-variable variableName="debat" value="#[""]" doc:name="Reset debat"/>
<choice tracking:enable-default-events="true" doc:name="debat > 0?">
<when expression="#[payload.'debat'.size() > 0]">
<foreach collection="#[payload.'debat']" doc:name="For Each debat">
<set-variable variableName="debat" value="#[flowVars.'debat' != null ? (flowVars.'debat' + payload.titel + "\n") : (payload.titel + "\n")]" doc:name="Set debat"/>
<set-variable variableName="zittingsjaar" value="#[payload.zittingsjaar != null && payload.zittingsjaar != "" ? "(" + payload.zittingsjaar + ")" : ""]" doc:name="Set zittingsjaar"/>
<set-variable variableName="nummer" value="#[payload.nummer != null && payload.nummer != "" ? payload.nummer + " " : ""]" doc:name="Set nummer"/>
<set-variable variableName="debat" value="#[flowVars.'debat' != null ? (flowVars.'debat' + payload.titel + "\n" + flowVars.nummer + flowVars.zittingsjaar + "\n") : (payload.titel + "\n" + flowVars.nummer + flowVars.zittingsjaar)]" doc:name="Set debat"/>
</foreach>
</when>
<otherwise>
<set-variable variableName="debat" value="#[""]" doc:name="Set debat empty"/>
</otherwise>
</choice>
<set-variable variableName="parlementair_initiatieven" value="#[null]" doc:name="Reset parlementair_initiatieven"/>
<choice doc:name="Parlementaire initieven > 0?">
<when expression="#[payload.'parlementair-initiatief'.size() > 0]">
<foreach collection="#[payload.'parlementair-initiatief']" doc:name="For Each parlementaire initiatief">
<set-variable variableName="zittingsjaar" value="#[payload.zittingsjaar != null && payload.zittingsjaar != "" ? "(" + payload.zittingsjaar + ")" : ""]" doc:name="Set zittingsjaar"/>
<set-variable variableName="nummer" value="#[payload.nummer != null && payload.nummer != "" ? payload.nummer + " " : ""]" doc:name="Set nummer"/>
<set-variable variableName="materie" value="#[payload.materie != null && payload.materie != "" ? payload.materie + "\n" : ""]" doc:name="Set materie"/>
<set-variable variableName="volgnummer" value="#[payload.volgnr != null && payload.volgnr != "" ? " nr. " + payload.volgnr : ""]" doc:name="Set volgnummer"/>
<set-variable variableName="parlementair_initiatieven" value="#[flowVars.'parlementair_initiatieven' != null ? (flowVars.'parlementair_initiatieven' + payload.titel + "\n" + flowVars.nummer + flowVars.zittingsjaar + flowVars.volgnummer + "\n" + flowVars.materie + "\n") : (payload.titel + "\n" + flowVars.nummer + flowVars.zittingsjaar + flowVars.volgnummer + "\n" + flowVars.materie + "\n")]" doc:name="Set parlementair_initiatieven"/>
</foreach>
</when>
<otherwise>
<set-variable variableName="parlementair_initiatieven" value="#[""]" doc:name="Set parlementair_initiatieven empty"/>
</otherwise>
</choice>
<set-variable variableName="gedachtewisseling" value="#[""]" doc:name="Reset gedachtewisseling"/>
<choice tracking:enable-default-events="true" doc:name="Gedachtewisseling > 0?">
<when expression="#[payload.'gedachtewisseling'.size() > 0]">
<foreach collection="#[payload.'gedachtewisseling']" doc:name="For Each gedachtewisseling">
<set-variable variableName="gedachtewisseling" value="#[flowVars.'gedachtewisseling' != null ? (flowVars.'gedachtewisseling' + payload.titel + "\n") : (payload.titel + "\n")]" doc:name="Set gedachtewisseling"/>
</foreach>
</when>
<otherwise>
<set-variable variableName="gedachtewisseling" value="#[""]" doc:name="Set gedachtewisseling empty"/>
</otherwise>
</choice>
<set-variable variableName="verzoekschrift" value="#[""]" doc:name="Reset verzoekschrift"/>
<choice tracking:enable-default-events="true" doc:name="verzoekschrift > 0?">
<when expression="#[payload.'verzoekschrift'.size() > 0]">
<foreach collection="#[payload.'verzoekschrift']" doc:name="For Each verzoekschrift">
<set-variable variableName="verzoekschrift" value="#[flowVars.'verzoekschrift' != null ? (flowVars.'verzoekschrift' + payload.titel + "\n") : (payload.titel + "\n")]" doc:name="Set verzoekschrift"/>
</foreach>
</when>
<otherwise>
<set-variable variableName="verzoekschrift" value="#[""]" doc:name="Set verzoekschrift empty"/>
</otherwise>
</choice>
<set-variable variableName="vrageninterpellatie" value="#[null]" doc:name="Reset vrageninterpellatie"/>
<choice doc:name="Vrageninterpellaties > 0?">
<when expression="#[payload.vrageninterpellatie.size() > 0]">
<foreach collection="#[payload.vrageninterpellatie]" doc:name="For Each vrageninterpellatie">
<set-variable variableName="zittingsjaar" value="#[payload.zittingsjaar != null && payload.zittingsjaar != "" ? "(" + payload.zittingsjaar + ")" : ""]" doc:name="Set zittingsjaar"/>
<set-variable variableName="nummer" value="#[payload.nummer != null && payload.nummer != "" ? payload.nummer + " " : ""]" doc:name="Set nummer"/>
<set-variable variableName="materie" value="#[payload.materie != null && payload.materie != "" ? payload.materie + "\n" : ""]" doc:name="Set materie"/>
<set-variable variableName="volgnummer" value="#[payload.volgnr != null && payload.volgnr != "" ? " nr. " + payload.volgnr : ""]" doc:name="Set volgnummer"/>
<set-variable variableName="vrageninterpellatie" value="#[flowVars.vrageninterpellatie != null ? (flowVars.vrageninterpellatie + payload.titel + "\n" + flowVars.nummer + flowVars.zittingsjaar + flowVars.volgnummer + "\n" + flowVars.materie + "\n") : (payload.titel + "\n" + flowVars.nummer + flowVars.zittingsjaar + flowVars.volgnummer + "\n"+ flowVars.materie + "\n")]" doc:name="Set vrageninterpellatie"/>
</foreach>
</when>
<otherwise>
<set-variable variableName="vrageninterpellatie" value="#[""]" doc:name="Set vrageninterpellatie empty"/>
</otherwise>
</choice>
<choice doc:name="Welke titel-samenstelling?">
<when expression="#[flowVars.'titel-samenstelling' == 'N']">
<choice doc:name="When initiatieven are empty, use vrije tekst titel">
<when expression="#[(flowVars.vrageninterpellatie + flowVars.debat + flowVars.gedachtewisseling + flowVars.parlementair_initiatieven + flowVars.verzoekschrift) == ""]">
<set-variable variableName="dc_description_lang" value="#[dc_description_lang != "" ? (flowVars.dc_description_lang + "\n" + flowVars.journaallijn_titel) : flowVars.journaallijn_titel]" doc:name="Append to dc_description_lang (only vrije tekst titel)"/>
</when>
<otherwise>
<set-variable variableName="dc_description_lang" value="#[dc_description_lang != "" ? (flowVars.dc_description_lang + "\n" + flowVars.vrageninterpellatie + flowVars.debat + flowVars.gedachtewisseling + flowVars.parlementair_initiatieven + flowVars.verzoekschrift) : (flowVars.vrageninterpellatie + flowVars.debat + flowVars.gedachtewisseling + flowVars.parlementair_initiatieven + flowVars.verzoekschrift) ]" doc:name="Append to dc_description_lang (when N = geen vrije tekst titel, enkel initiatieven)"/>
</otherwise>
</choice>
</when>
<when expression="#[flowVars.'titel-samenstelling' == 'V']">
<set-variable variableName="dc_description_lang" value="#[dc_description_lang != "" ? (flowVars.dc_description_lang + "\n" + flowVars.journaallijn_titel) : flowVars.journaallijn_titel]" doc:name="Append to dc_description_lang (when V = enkel vrije tekst titel)"/>
</when>
<otherwise>
<set-variable variableName="dc_description_lang" value="#[dc_description_lang != "" ? (flowVars.dc_description_lang + "\n" + flowVars.journaallijn_titel + "\n" + flowVars.vrageninterpellatie + "\n" + flowVars.debat + flowVars.gedachtewisseling + flowVars.parlementair_initiatieven + flowVars.verzoekschrift) : (flowVars.journaallijn_titel + flowVars.vrageninterpellatie + "\n" + flowVars.debat + flowVars.gedachtewisseling + flowVars.parlementair_initiatieven + flowVars.verzoekschrift) ]" doc:name="Append to dc_description_lang (normal)"/>
</otherwise>
</choice>
</foreach>
</sub-flow>
<sub-flow name="metadata_corrections">
<set-variable variableName="mappedXml" value="#[flowVars.mappedXml.replaceAll('<trefwoord>', '<Trefwoord>').replaceAll('</trefwoord>', '</Trefwoord>')]" doc:name="Fix trefwoord -> Trefwoord"/>
<set-variable variableName="mappedXml" value="#[flowVars.mappedXml.replaceAll('<auteursrechthouder>', '<Auteursrechthouder>').replaceAll('</auteursrechthouder>','</Auteursrechthouder>')]" doc:name="Fix auteursrechthouder -> Auteursrechthouder"/>
<set-variable variableName="mappedXml" value="#[flowVars.mappedXml.replaceAll('<licentiehouder>', '<Licentiehouder>').replaceAll('</licentiehouder>','</Licentiehouder>')]" doc:name="Fix licentiehouder -> Licentiehouder"/>
<choice doc:name="Languages available?">
<when expression="#[flowVars.mappedXml.indexOf('<dc_languages type="list">') == -1]">
<logger message="No language metadata available" level="INFO" doc:name="No language metadata available"/>
</when>
<otherwise>
<set-variable variableName="languages" value="#[flowVars.mappedXml.substring(flowVars.mappedXml.indexOf('<dc_languages type="list">'), flowVars.mappedXml.indexOf('</dc_languages>'))]" doc:name="Set languages"/>
<set-variable variableName="mappedXml" value="#[flowVars.mappedXml.replace(flowVars.languages, flowVars.languages.toLowerCase())]" doc:name="Fix languages to lowercase"/>
</otherwise>
</choice>
</sub-flow>
<flow name="validateMetadataFromVIAAtoMAM" >
<set-variable variableName="eventName" value="PI_VALIDATE_METADATA_VIAA_MAM" doc:name="Set eventName"/>
<set-payload value="#[flowVars.mappedXml]" doc:name="Set Payload with mappedXml"/>
<mulexml:dom-to-xml-transformer doc:name="DOM to XML" />
<message-filter onUnaccepted="error_invalid_data" doc:name="Validate mappedXml" >
<mulexml:schema-validation-filter schemaLocations="viaa_metadatamodel_van_viaa_naar_mam.xsd" returnResult="false" name="VIAA_MAM_Schema_Validation"
doc:name="Schema Validation" />
</message-filter>
<logger message="FILE OK: #[message.payload]" level="DEBUG" doc:name="Logger" />
<set-variable variableName="result" value="OK" doc:name="Set result OK"/>
<set-variable variableName="comment" value="The mapped XML is valid." doc:name="Set comment"/>
<flow-ref name="PI_LOG" doc:name="PI_LOG"/>
</flow>
<flow name="error_invalid_data" >
<logger message="ERROR: MESSAGE PAYLOAD: #[message.payload]" level="DEBUG" doc:name="Logger" />
<set-variable variableName="result" value="NOK" doc:name="Set result NOK"/>
<set-variable variableName="comment" value="The mapped XML is NOT valid." doc:name="Set comment"/>
<flow-ref name="PI_LOG" doc:name="PI_LOG"/>
</flow>
<sub-flow name="validateEDTFdates">
<set-variable variableName="eventName" value="#['PI_VALIDATE_DATE']" doc:name="Set eventName"/>
<set-variable variableName="dcterms_issued" value="#[xpath3("//dcterms_issued/text()", flowVars.mappedXml)]" doc:name="Get dcterms_issued"/>
<set-variable variableName="dcterms_created" value="#[xpath3("//dcterms_created/text()", flowVars.mappedXml)]" doc:name="Get dcterms_created"/>
<choice doc:name="When dcterms_created is empty">
<when expression="#[flowVars.dcterms_created == ""]">
<set-variable variableName="dcterms_created_is_valid" value="#[true]" doc:name="dcterms_created_is_valid is true"/>
</when>
<otherwise>
<set-payload value="#[flowVars.dcterms_created]" doc:name="Set Payload"/>
<flow-ref name="date_validator" doc:name="date_validator Flow Reference"/>
<set-variable variableName="dcterms_created_is_valid" value="#[payload]" doc:name="Set dcterms_created_is_valid"/>
</otherwise>
</choice>
<choice doc:name="When dcterms_issued is empty">
<when expression="#[flowVars.dcterms_issued == ""]">
<set-variable variableName="dcterms_issued_is_valid" value="#[true]" doc:name="Set dcterms_issued_is_valid is true"/>
</when>
<otherwise>
<set-payload value="#[flowVars.dcterms_issued]" doc:name="Set Payload"/>
<flow-ref name="date_validator" doc:name="date_validator Flow Reference"/>
<set-variable variableName="dcterms_issued_is_valid" value="#[payload]" doc:name="Set dcterms_issued_is_valid"/>
</otherwise>
</choice>
<set-variable variableName="result" value="#[flowVars.dcterms_issued_is_valid && flowVars.dcterms_created_is_valid ? "OK" : "NOK"]" doc:name="Set result OK when dcterms_issued and created are valid"/>
<set-variable variableName="comment" value="dcterms_created and issued are #[flowVars.result]" doc:name="Set comment"/>
<flow-ref name="PI_LOG" doc:name="PI_LOG"/>
</sub-flow>
</mule>