Alexandra guides us during a complex DataWeave transformation use-case and how to solve it using Tail Recursive functions and other core functions like map, reduce, etc.
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
Toronto Virtual Meetup #11 - Reviewing Complex DataWeave Transformation Use-case
1. June 03, 2021
Toronto MuleSoft Meetup - #11
Reviewing Complex DataWeave Transformation
Use-Case
2. 3
● Introductions
● Q&A Tab
● How does the quiz work?
● If you are one of the quiz winners
● Reviewing Complex DataWeave Transformation Use-Case – Alexandra Martinez
● What’s next?
Agenda
#MuleSoftMeetups
3. 4
Organizers
#MuleSoftMeetups
Alexandra Martinez
Senior MuleSoft Developer
at Bits In Glass
MuleSoft Ambassadress
ProstDev Founder and
Content Creator
3+ years using MuleSoft
5x MuleSoft certified
alexandramartinez.world
Mahesh Pujari
MuleSoft Developer
at Mackenzie Investments
Around 7 years of
integration expertise
3+ Years using Mulesoft
3x Mulesoft Certified
Pravallika Nagaraja
Senior MuleSoft Developer
at Roche / MuleSoft Mentor
Overall 10 years of
experience developing
integration solutions using
MuleSoft and other
integration technologies
3+ years using MuleSoft
4x MuleSoft certified
Content Creator at
ProstDev
Kishore Reddy Paluri
Solutions Architect
at MuleSoft
15 years of experience
building Integration, ESB,
SOA, API, Security and
Middleware solutions on
Cloud, On-Prem, and
Hybrid environments
5. 6
● Anypoint Platform With Datagraph
○ Webinar : https://www.mulesoft.com/platform/anypoint-design-center/datagraph
○ https://tinyurl.com/4wmr8vnv
● New Connectors
○ RPA, data lakes and event streaming : https://blogs.mulesoft.com/dev-guides/api-connectors-
templates/11-new-anypoint-connectors-rpa/
○ Microsoft Azure, Plaid and Dropbox : https://blogs.mulesoft.com/dev-guides/api-connectors-templates/11-
new-connectors-for-anypoint-platform/
○ New anypoint connectors for IT and business collaboration : https://tinyurl.com/vvv9hfp3
Latest Releases/News
#MuleSoftMeetups
6. 7
● Anypoint Studio 7.9.0
○ Dark theme
○ Supports Java 11
○ Improvements for Dataweave code experience
Latest Releases/News
#MuleSoftMeetups
7. 8
NEW! Introducing the MuleSoft Mentors
Who are MuleSoft Mentors?
● Active contributors across platforms
● Hold 1+ Mule certs
● Dedicated mentors to their peers
Why should you become a Mentor?
● Build professional/personal brand
● Earn recognition as a Mule expert by
MuleSoft and broader ecosystem
● Help our Community learn and become
experts themselves
Apply now - June. 18, 2021
mulesoft.com/mentors
A new community program
8. Q&A Tab
● Questions can be lost in the Chat.
● Under the Chat window, there are 3 tabs: General, Q&A, and DMs.
● Click on the Q&A tab to ask your questions.
9
9. How does the quiz work?
1. Questions will be asked during the presentation.
2. If you already answered a question correctly, do not keep answering and give an
opportunity to the other attendees.
3. The first answer in the chat is the winner, unless it’s from someone that already answered
another question.
IMPORTANT
● You can only win one voucher per month, regardless of the meetup city.
● You can’t participate if you’re already a meetup leader (even from another city) or a MuleSoft
ambassador.
● If you already won a voucher in another event in the same month, you will not receive a
voucher.
If any of this applies to you, please don’t participate in the quiz and give other people the
opportunity to win.
10
#MuleSoftMeetups
10. If you are one of the quiz winners
1. Send your name and email to the organizers in the chat window.
2. MuleSoft will get in touch with you to request your voucher.
3. You can only select training vouchers. Certification vouchers are no longer offered.
However, some trainings will give you a free voucher for a certification attempt at the end.
4. Once processed, you can expect to receive your voucher within 10 business days.
5. If you experience any trouble redeeming a voucher, please raise a ticket at
training.mulesoft.com/question
11
#MuleSoftMeetups
15. 16
● Logic:
1. For each object from the
FlightOptions array, create one
output object inside the output array.
Requirement
16
16. 17
● Logic:
1. For each object from the
FlightOptions array, create one
output object inside the output array.
2. The AppliedTaxCode will contain the
value from the last Connection
object.
Requirement
17
17. 18
● Logic:
1. For each object from the
FlightOptions array, create one
output object inside the output array.
2. The AppliedTaxCode will contain the
value from the last Connection
object.
3. If the EndOfConnection field is true,
create a separate output object.
Requirement
18
18. 19
● Logic:
1. For each object from the
FlightOptions array, create one
output object inside the output array.
2. The AppliedTaxCode will contain the
value from the last Connection
object.
3. If the EndOfConnection field is true,
create a separate output object.
4. If there are EndOfConnection fields
that are true and this is not the last
object inside the Connections array,
create a new output object
containing all the false Connection
objects before this, and using this
last object’s TaxCode.
Requirement
19
19. 20
● Logic:
1. For each object from the
FlightOptions array, create one
output object inside the output array.
2. The AppliedTaxCode will contain the
value from the last Connection
object.
3. If the EndOfConnection field is true,
create a separate output object.
4. If there are EndOfConnection fields
that are true and this is not the last
object inside the Connections array,
create a new output object
containing all the false Connection
objects before this, and using this
last object’s TaxCode.
5. Each AppliedConnections object in
the output must have:
1. A hardcoded Type value
“Connection”.
Requirement
20
23. 24
2) Change all the EndOfConnection to true for the last Connection object from the Connections
array.
Building the Solution
24. 1) How can you import the update
function from the dw::util::Values
module in the script?
(There are 3 different ways,
mention just one)
25. Question 1
How can you import the update function from the dw::util::Values module in the script?
(There are 3 different ways, mention just one)
● Import update from dw::util::Values
● Import * from dw::util::Values
● Import dw::util::Values Values::update(…)
26. 27
3) flatten the array of arrays to be just one array.
Building the Solution
27. 2) What are the 2 ways for
flattening the previous array of
arrays?
28. Question 2
What are the 2 ways for flattening the previous array of arrays?
● Using flatten(…)
● Adding ++ to the reduce instead of +
○ Reduce(… accumulator ++ updatedConnections…)
29. 30
4) Parameters:
1. connectionsArray - Current connections array (this will have less values each time, until array is
empty).
2. indexAccumulatorArray - Array with the indexes that are being accumulated for the ”IndexValue”
field.
3. index - Actual index number for each connection being evaluated.
4. connectionsAccumulatorArray - Array that will keep the transformed objects (final output) – This is
what makes our function a tail function.
Building the Solution – Tail Recursive function
30. 31
Iteration 1:
Building the Solution – Tail Recursive function
connectionsArray (original array) indexAccumulatorArray
index
connectionsAccumulatorArray
thisConnection
EndOfConnection = false
Nothing is added to
connectionsAccumulatorArray
Next connection
indexAccumulatorArray should
contain this index
because
thisConnectionEndOfConnection
is false.
31. 32
Iteration 2:
Building the Solution – Tail Recursive function
connectionsArray (original array) indexAccumulatorArray
index
connectionsAccumulatorArray
thisConnection
EndOfConnection = true
Object is added to
connectionsAccumulatorArray
Next connection
indexAccumulatorArray should go
back to [ ] because
thisConnectionEndOfConnection
is true.
32. 33
Iteration 3:
Building the Solution – Tail Recursive function
connectionsArray (original array) indexAccumulatorArray
index
connectionsAccumulatorArray
thisConnection
EndOfConnection = true
Object is added to
connectionsAccumulatorArray
Next connection
indexAccumulatorArray should go
back to [ ] because
thisConnectionEndOfConnection
is true.
33. 34
Iteration 4:
Building the Solution – Tail Recursive function
connectionsArray (original array) indexAccumulatorArray
index
connectionsAccumulatorArray
thisConnection
EndOfConnection = true
Object is added to
connectionsAccumulatorArray
Next connection
indexAccumulatorArray should go
back to [ ] because
thisConnectionEndOfConnection
is true.
34. 35
Iteration 5:
Building the Solution – Tail Recursive function
connectionsArray (original array) indexAccumulatorArray
index
connectionsAccumulatorArray
thisConnection
EndOfConnection = false
Nothing is added to
connectionsAccumulatorArray
Next connection
indexAccumulatorArray should
contain this index
because
thisConnectionEndOfConnection
is false.
35. 36
Iteration 6:
Building the Solution – Tail Recursive function
connectionsArray (original array) indexAccumulatorArray
index
connectionsAccumulatorArray
thisConnection
EndOfConnection = false
Nothing is added to
connectionsAccumulatorArray
Next connection
indexAccumulatorArray should
contain this index
because
thisConnectionEndOfConnection
is false.
36. 37
Iteration 7:
Building the Solution – Tail Recursive function
connectionsArray (original array) indexAccumulatorArray
index
connectionsAccumulatorArray
thisConnection
EndOfConnection = true
Object is added to
connectionsAccumulatorArray
Next connection
indexAccumulatorArray should go
back to [ ] because
thisConnectionEndOfConnection
is true.
37. 38
Iteration 8:
Building the Solution – Tail Recursive function
connectionsArray (original array) indexAccumulatorArray
index
connectionsAccumulatorArray
thisConnection
EndOfConnection = true
Object is added to
connectionsAccumulatorArray
Next connection
indexAccumulatorArray should go
back to [ ] because
thisConnectionEndOfConnection
is true.
To be continued…
45. 46
● Share:
○ Tweet using the hashtag #MuleSoftMeetups
○ Invite your network to join: https://meetups.mulesoft.com/toronto/
● Feedback:
○ Fill out the survey feedback and suggest topics for upcoming events
○ Contact MuleSoft at meetups@mulesoft.com for ways to improve the program
What’s next?
#MuleSoftMeetups