SlideShare a Scribd company logo
1 of 30
Reviewing a Complex
DataWeave Transformation
Use-case
Alexandra Martinez
All contents © MuleSoft Inc. 2
• Functions (fun)
– Parameters using types
– Calling functions with 2 parameters
• Variables (var)
• do statement to create scopes (local variables)
• Object manipulation using object destructor {( )}
• If/else
• Selectors:
– Index (array[0])
– Range (1 to 10)
• Setting default values
• Core functions/operators
– isEmpty
– reduce
– map
– groupBy
– flatten
– Remove (-)
– Sum (+)
– Concatenation (++)
– Prepend (>>)
Solution will make use of the following:
All contents © MuleSoft Inc. 3
• Input JSON structure:
– FlightOptions (array of objects)
• Connections (array of objects)
– ReferenceID (number)
– TaxCode (string)
– EndOfConnection (Boolean)
Requirement
All contents © MuleSoft Inc. 4
• Input JSON structure:
– FlightOptions (array of objects)
• Connections (array of objects)
– ReferenceID (number)
– TaxCode (string)
– EndOfConnection (Boolean)
• Output JSON structure:
– Array of objects
• AppliedTaxCode (string – from TaxCode)
• AppliedConnections (array of objects)
– Type (string – hardcoded value “Connection”)
– IndexValue (number - dynamic)
Requirement
All contents © MuleSoft Inc. 5
• Logic:
1. For each object from the FlightOptions
array, create one output object inside
the output array.
Requirement
All contents © MuleSoft Inc. 6
• 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
All contents © MuleSoft Inc. 7
• 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, even
though the Connection might be inside
a FlightOption object.
Requirement
All contents © MuleSoft Inc. 8
• 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, even
though the Connection might be inside
a FlightOption 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 object’s TaxCode.
Requirement
All contents © MuleSoft Inc. 9
• 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, even though the
Connection might be inside a FlightOption 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 object’s TaxCode.
5. For each object from the Connections array
(taking into account the EndOfConnection
true/false logic), create one AppliedConnections
object with:
1. a hardcoded Type value ”Connection”
2. an incrementing IndexValue throughout the
complete output.
Requirement
All contents © MuleSoft Inc.
• Examples per FlightOptions object:
– 1) EndOfConnection: false
– 2) EndOfConnection: true
Requirement
• Output:
– 1 object containing
– 2 AppliedConnections objects
All contents © MuleSoft Inc.
• Examples per FlightOptions object:
– 1) EndOfConnection: true
– 2) EndOfConnection: true
Requirement
• Output:
– 2 objects containing
– 1 AppliedConnections object each
All contents © MuleSoft Inc.
• Examples per FlightOptions object:
– 1) EndOfConnection: false
– 2) EndOfConnection: false
– 3) EndOfConnection: false
Requirement
• Output:
– 1 object containing
– 3 AppliedConnections objects
All contents © MuleSoft Inc.
• Examples per FlightOptions object:
– 1) EndOfConnection: false
• Note: if this was true, it would
behave the same
Requirement
• Output:
– 1 object containing
– 1 AppliedConnections object
All contents © MuleSoft Inc.
• Examples per FlightOptions object:
– 1) EndOfConnection: false
– 2) EndOfConnection: true
– 3) EndOfConnection: false
Requirement
• Output:
– 2 objects.
• First: 2 AppliedConnections objects
• Second: 1 AppliedConnections object
All contents © MuleSoft Inc. 15
• DW Playground: https://dwl.mule.club/
• Input payload:
{"FlightOptions":[{"Connections":[{"ReferenceID":111,"TaxCode":"ABC","EndOfConnection":false},{"ReferenceID":222,"TaxCode":"DEF","EndOfConnection":true}]},{"C
onnections":[{"ReferenceID":333,"TaxCode":"GHI","EndOfConnection":true},{"ReferenceID":444,"TaxCode":"JKL","EndOfConnection":true}]},{"Connections":[{"Refere
nceID":555,"TaxCode":"MNO","EndOfConnection":false},{"ReferenceID":666,"TaxCode":"PQR","EndOfConnection":false},{"ReferenceID":777,"TaxCode":"STU","EndOfC
onnection":false}]},{"Connections":[{"ReferenceID":888,"TaxCode":"VWX","EndOfConnection":false}]},{"Connections":[{"ReferenceID":999,"TaxCode":"MNO","EndOfC
onnection":false},{"ReferenceID":101,"TaxCode":"PQR","EndOfConnection":true},{"ReferenceID":102,"TaxCode":"STU","EndOfConnection":false}]}]}
• Expected output:
[{"AppliedTaxCode":"DEF","AppliedConnections":[{"Type":"Connection","IndexValue":1},{"Type":"Connection","IndexValue":2}]},{"AppliedTaxCode":"GHI","AppliedCon
nections":[{"Type":"Connection","IndexValue":3}]},{"AppliedTaxCode":"JKL","AppliedConnections":[{"Type":"Connection","IndexValue":4}]},{"AppliedTaxCode":"STU",
"AppliedConnections":[{"Type":"Connection","IndexValue":5},{"Type":"Connection","IndexValue":6},{"Type":"Connection","IndexValue":7}]},{"AppliedTaxCode":"VWX"
,"AppliedConnections":[{"Type":"Connection","IndexValue":8}]},{"AppliedTaxCode":"PQR","AppliedConnections":[{"Type":"Connection","IndexValue":9},{"Type":"Conn
ection","IndexValue":10}]},{"AppliedTaxCode":"STU","AppliedConnections":[{"Type":"Connection","IndexValue":11}]}]
• Format JSONs for better view:
https://jsonformatter.curiousconcept.com/
Building the Solution
All contents © MuleSoft Inc. 16
• 1) Extract the Connections arrays.
Building the Solution
All contents © MuleSoft Inc. 17
• 2) Change all the EndOfConnection to true for the last Connection
object from the Connections array.
Building the Solution
All contents © MuleSoft Inc. 18
• 3) flatten the array of arrays to be just one array.
Building the Solution
All contents © MuleSoft Inc. 19
• 4) Add a new field to keep track of the object’s index, basing on the
EndOfConnection field.
– (i.e. for each EndOfConnection=true, stop incrementing the index)
Building the Solution
Index 1
Index 2
Index 1
Index 1
Index 1
Index 3
Index 2
All contents © MuleSoft Inc. 20
• 5) Add a new field to keep track of the final AppliedConnections
object’s (first) index where the object in question will be added.
– This is calculated using the object’s index + 1 (to start at 1) and then minus the
previously added indexBasedOnEOC field.
Building the Solution
Index 0
Index 2
Index 3
Index 4
All contents © MuleSoft Inc. 21
• 6) Separate the objects based on the EndOfConnection value (true or
false).
Building the Solution
All contents © MuleSoft Inc. 22
• 7) Take only the objects that are inside the “true” list.
Building the Solution
All contents © MuleSoft Inc. 23
• 8) Create the final output
Building the Solution
All contents © MuleSoft Inc. 24
• Playing with the indexes
Index based on
EndOfConnection
1
2
1
1
1
2
3
1
1
1
2
All contents © MuleSoft Inc. 25
• Playing with the indexes
index + 1
1
3
4
5
2 6
7
8
9
10
11
Index based on
EndOfConnection
1
2
1
1
1
2
3
1
1
1
2
All contents © MuleSoft Inc. 26
• Playing with the indexes
AppliedConnections
Index
(index+1) - indexBasedOnEOC
1-1=0
3-1=2
4-1=3
5-1=4
2-2=0 6-2=4
7-3=4
8-1=7
9-1=8
10-2=8
11-1=10
Index based on
EndOfConnection
1
2
1
1
1
2
3
1
1
1
2
All contents © MuleSoft Inc. 27
• Playing with the indexes
AppliedConnections
Index
(index+1) - indexBasedOnEOC
IndexValue
indexBasedOnEOC (or
actualIndex or actualNum) +
indexAppliedConnections
0
2
3
4
0 4
4
7
8
8
10
Index based on
EndOfConnection
1
2
1
1
1
2
3
1
1
1
2
1+0=1
2+0=2
1+2=3
1+3=4
1+4=5
2+4=6
3+4=7
1+7=8
1+8=9
2+8=10
1+10=11
All contents © MuleSoft Inc. 28
• Github repository: https://github.com/alexandramartinez/reviewing-
a-complex-dw-transformation-use-case/
Code
All contents © MuleSoft Inc. 29
• https://docs.mulesoft.com/mule-runtime/4.3/dataweave-functions
• https://docs.mulesoft.com/mule-runtime/4.3/dataweave-variables
• https://docs.mulesoft.com/mule-runtime/4.3/dataweave-flow-control
• https://docs.mulesoft.com/mule-runtime/4.3/dataweave-selectors
• https://docs.mulesoft.com/mule-runtime/4.3/dataweave-cookbook-defaults
• https://docs.mulesoft.com/mule-runtime/3.9/dataweave-operators
• https://docs.mulesoft.com/mule-runtime/4.3/dw-operators
• https://docs.mulesoft.com/mule-runtime/4.3/dw-core-functions-isempty
• https://docs.mulesoft.com/mule-runtime/4.3/dw-core-functions-reduce
• https://docs.mulesoft.com/mule-runtime/4.3/dw-core-functions-map
• https://docs.mulesoft.com/mule-runtime/4.3/dw-core-functions-groupby
• https://docs.mulesoft.com/mule-runtime/4.3/dw-core-functions-flatten
References
Questions?

More Related Content

What's hot

VueJS Introduction
VueJS IntroductionVueJS Introduction
VueJS IntroductionDavid Ličen
 
Mule 4 migration + Common Integration Challenges : MuleSoft Virtual Muleys Me...
Mule 4 migration + Common Integration Challenges : MuleSoft Virtual Muleys Me...Mule 4 migration + Common Integration Challenges : MuleSoft Virtual Muleys Me...
Mule 4 migration + Common Integration Challenges : MuleSoft Virtual Muleys Me...Angel Alberici
 
London-MuleSoft-Meetup-April-19-2023
London-MuleSoft-Meetup-April-19-2023London-MuleSoft-Meetup-April-19-2023
London-MuleSoft-Meetup-April-19-2023AnuragSharma900
 
MuleSoft Runtime Fabric (RTF): Foundations : MuleSoft Virtual Muleys Meetups
MuleSoft Runtime Fabric (RTF): Foundations  : MuleSoft Virtual Muleys MeetupsMuleSoft Runtime Fabric (RTF): Foundations  : MuleSoft Virtual Muleys Meetups
MuleSoft Runtime Fabric (RTF): Foundations : MuleSoft Virtual Muleys MeetupsAngel Alberici
 
Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...
Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...
Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...Eva Mave Ng
 
Functional Programming in Swift
Functional Programming in SwiftFunctional Programming in Swift
Functional Programming in SwiftSaugat Gautam
 
Data weave 2.0 language fundamentals
Data weave 2.0 language fundamentalsData weave 2.0 language fundamentals
Data weave 2.0 language fundamentalsManjuKumara GH
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.jsTechMagic
 
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63Angel Alberici
 
Angular 4 The new Http Client Module
Angular 4 The new Http Client ModuleAngular 4 The new Http Client Module
Angular 4 The new Http Client Modulearjun singh
 
Solace PubSub+ MuleSoft Connector for Mule 4
Solace PubSub+ MuleSoft Connector for Mule 4Solace PubSub+ MuleSoft Connector for Mule 4
Solace PubSub+ MuleSoft Connector for Mule 4Manish Kumar Yadav
 
Denver MuleSoft Meetup: Deep Dive into Anypoint Runtime Fabric Security
Denver MuleSoft Meetup: Deep Dive into Anypoint Runtime Fabric Security Denver MuleSoft Meetup: Deep Dive into Anypoint Runtime Fabric Security
Denver MuleSoft Meetup: Deep Dive into Anypoint Runtime Fabric Security Stephanie Lawrence
 
Building High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol BuffersBuilding High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol BuffersShiju Varghese
 
MuleSoft's Approach to Driving Customer Outcomes
MuleSoft's Approach to Driving Customer Outcomes MuleSoft's Approach to Driving Customer Outcomes
MuleSoft's Approach to Driving Customer Outcomes MuleSoft
 

What's hot (20)

VueJS Introduction
VueJS IntroductionVueJS Introduction
VueJS Introduction
 
Introduction to MuleSoft
Introduction to MuleSoftIntroduction to MuleSoft
Introduction to MuleSoft
 
Mule 4 migration + Common Integration Challenges : MuleSoft Virtual Muleys Me...
Mule 4 migration + Common Integration Challenges : MuleSoft Virtual Muleys Me...Mule 4 migration + Common Integration Challenges : MuleSoft Virtual Muleys Me...
Mule 4 migration + Common Integration Challenges : MuleSoft Virtual Muleys Me...
 
London-MuleSoft-Meetup-April-19-2023
London-MuleSoft-Meetup-April-19-2023London-MuleSoft-Meetup-April-19-2023
London-MuleSoft-Meetup-April-19-2023
 
Managing APIs with MuleSoft
Managing APIs with MuleSoftManaging APIs with MuleSoft
Managing APIs with MuleSoft
 
MuleSoft Runtime Fabric (RTF): Foundations : MuleSoft Virtual Muleys Meetups
MuleSoft Runtime Fabric (RTF): Foundations  : MuleSoft Virtual Muleys MeetupsMuleSoft Runtime Fabric (RTF): Foundations  : MuleSoft Virtual Muleys Meetups
MuleSoft Runtime Fabric (RTF): Foundations : MuleSoft Virtual Muleys Meetups
 
Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...
Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...
Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...
 
Angular
AngularAngular
Angular
 
Functional Programming in Swift
Functional Programming in SwiftFunctional Programming in Swift
Functional Programming in Swift
 
Data weave 2.0 language fundamentals
Data weave 2.0 language fundamentalsData weave 2.0 language fundamentals
Data weave 2.0 language fundamentals
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.js
 
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63
 
Angular 4 The new Http Client Module
Angular 4 The new Http Client ModuleAngular 4 The new Http Client Module
Angular 4 The new Http Client Module
 
Solace PubSub+ MuleSoft Connector for Mule 4
Solace PubSub+ MuleSoft Connector for Mule 4Solace PubSub+ MuleSoft Connector for Mule 4
Solace PubSub+ MuleSoft Connector for Mule 4
 
Optimizing MySQL queries
Optimizing MySQL queriesOptimizing MySQL queries
Optimizing MySQL queries
 
Denver MuleSoft Meetup: Deep Dive into Anypoint Runtime Fabric Security
Denver MuleSoft Meetup: Deep Dive into Anypoint Runtime Fabric Security Denver MuleSoft Meetup: Deep Dive into Anypoint Runtime Fabric Security
Denver MuleSoft Meetup: Deep Dive into Anypoint Runtime Fabric Security
 
Building High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol BuffersBuilding High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol Buffers
 
Nodejs
NodejsNodejs
Nodejs
 
What Is Spring?
What Is Spring?What Is Spring?
What Is Spring?
 
MuleSoft's Approach to Driving Customer Outcomes
MuleSoft's Approach to Driving Customer Outcomes MuleSoft's Approach to Driving Customer Outcomes
MuleSoft's Approach to Driving Customer Outcomes
 

Similar to Reviewing a Complex DataWeave Transformation Use-case

Vancouver Canada MuleSoft Meetup Nov 2020
Vancouver Canada MuleSoft Meetup Nov 2020Vancouver Canada MuleSoft Meetup Nov 2020
Vancouver Canada MuleSoft Meetup Nov 2020Yashwant Palkar
 
Indianapolis mule soft_meetup_14_apr_2021-Review a complex Dataweave Transfor...
Indianapolis mule soft_meetup_14_apr_2021-Review a complex Dataweave Transfor...Indianapolis mule soft_meetup_14_apr_2021-Review a complex Dataweave Transfor...
Indianapolis mule soft_meetup_14_apr_2021-Review a complex Dataweave Transfor...ikram_ahamed
 
Reviewing a complex dataweave transformation use case v3
Reviewing a complex dataweave transformation use case v3Reviewing a complex dataweave transformation use case v3
Reviewing a complex dataweave transformation use case v3Alexandra N. Martinez
 
Reviewing a Complex DataWeave Transformation Use-case v2
Reviewing a Complex DataWeave Transformation Use-case v2Reviewing a Complex DataWeave Transformation Use-case v2
Reviewing a Complex DataWeave Transformation Use-case v2Alexandra N. Martinez
 
Toronto Virtual Meetup #11 - Reviewing Complex DataWeave Transformation Use-case
Toronto Virtual Meetup #11 - Reviewing Complex DataWeave Transformation Use-caseToronto Virtual Meetup #11 - Reviewing Complex DataWeave Transformation Use-case
Toronto Virtual Meetup #11 - Reviewing Complex DataWeave Transformation Use-caseAlexandra N. Martinez
 
Kotlin 1.2: Sharing code between platforms
Kotlin 1.2: Sharing code between platformsKotlin 1.2: Sharing code between platforms
Kotlin 1.2: Sharing code between platformsKirill Rozov
 
Use the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docxUse the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docxdickonsondorris
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for KotlinTechMagic
 
iOS Automation: XCUITest + Gherkin
iOS Automation: XCUITest + GherkiniOS Automation: XCUITest + Gherkin
iOS Automation: XCUITest + GherkinKenneth Poon
 
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...InfluxData
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfoliomwillmer
 
Unit 5 Java Programming with Linux-converted.pdf
Unit 5 Java Programming with Linux-converted.pdfUnit 5 Java Programming with Linux-converted.pdf
Unit 5 Java Programming with Linux-converted.pdfranjithunni35
 
Building Mobile Apps with Android
Building Mobile Apps with AndroidBuilding Mobile Apps with Android
Building Mobile Apps with AndroidKurt Renzo Acosta
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN StackTroy Miles
 
Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Scott Wlaschin
 
Coherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherenceCoherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherencearagozin
 
Entity Component System - for App developers
Entity Component System - for App developersEntity Component System - for App developers
Entity Component System - for App developersMaxim Zaks
 

Similar to Reviewing a Complex DataWeave Transformation Use-case (20)

Vancouver Canada MuleSoft Meetup Nov 2020
Vancouver Canada MuleSoft Meetup Nov 2020Vancouver Canada MuleSoft Meetup Nov 2020
Vancouver Canada MuleSoft Meetup Nov 2020
 
Indianapolis mule soft_meetup_14_apr_2021-Review a complex Dataweave Transfor...
Indianapolis mule soft_meetup_14_apr_2021-Review a complex Dataweave Transfor...Indianapolis mule soft_meetup_14_apr_2021-Review a complex Dataweave Transfor...
Indianapolis mule soft_meetup_14_apr_2021-Review a complex Dataweave Transfor...
 
Reviewing a complex dataweave transformation use case v3
Reviewing a complex dataweave transformation use case v3Reviewing a complex dataweave transformation use case v3
Reviewing a complex dataweave transformation use case v3
 
Reviewing a Complex DataWeave Transformation Use-case v2
Reviewing a Complex DataWeave Transformation Use-case v2Reviewing a Complex DataWeave Transformation Use-case v2
Reviewing a Complex DataWeave Transformation Use-case v2
 
Toronto Virtual Meetup #11 - Reviewing Complex DataWeave Transformation Use-case
Toronto Virtual Meetup #11 - Reviewing Complex DataWeave Transformation Use-caseToronto Virtual Meetup #11 - Reviewing Complex DataWeave Transformation Use-case
Toronto Virtual Meetup #11 - Reviewing Complex DataWeave Transformation Use-case
 
Kotlin 1.2: Sharing code between platforms
Kotlin 1.2: Sharing code between platformsKotlin 1.2: Sharing code between platforms
Kotlin 1.2: Sharing code between platforms
 
Use the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docxUse the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docx
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
 
iOS Automation: XCUITest + Gherkin
iOS Automation: XCUITest + GherkiniOS Automation: XCUITest + Gherkin
iOS Automation: XCUITest + Gherkin
 
MTPLs
MTPLsMTPLs
MTPLs
 
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
 
Unit 5 Java Programming with Linux-converted.pdf
Unit 5 Java Programming with Linux-converted.pdfUnit 5 Java Programming with Linux-converted.pdf
Unit 5 Java Programming with Linux-converted.pdf
 
Building Mobile Apps with Android
Building Mobile Apps with AndroidBuilding Mobile Apps with Android
Building Mobile Apps with Android
 
Geminate Airtable Connector
Geminate Airtable ConnectorGeminate Airtable Connector
Geminate Airtable Connector
 
Javascript
JavascriptJavascript
Javascript
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN Stack
 
Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)
 
Coherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherenceCoherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherence
 
Entity Component System - for App developers
Entity Component System - for App developersEntity Component System - for App developers
Entity Component System - for App developers
 

More from Alexandra N. Martinez

Mejora tu productividad creando aplicaciones de Slack
Mejora tu productividad creando aplicaciones de SlackMejora tu productividad creando aplicaciones de Slack
Mejora tu productividad creando aplicaciones de SlackAlexandra N. Martinez
 
Women Who Mule - Workshop series #2: Ghost
Women Who Mule - Workshop series #2: GhostWomen Who Mule - Workshop series #2: Ghost
Women Who Mule - Workshop series #2: GhostAlexandra N. Martinez
 
Women Who Mule - Workshop series: Create your own blog from scratch without a...
Women Who Mule - Workshop series: Create your own blog from scratch without a...Women Who Mule - Workshop series: Create your own blog from scratch without a...
Women Who Mule - Workshop series: Create your own blog from scratch without a...Alexandra N. Martinez
 
Toronto Virtual Meetup #12 - Testing Strategies and MUnit Test Recorder
Toronto Virtual Meetup #12 - Testing Strategies and MUnit Test RecorderToronto Virtual Meetup #12 - Testing Strategies and MUnit Test Recorder
Toronto Virtual Meetup #12 - Testing Strategies and MUnit Test RecorderAlexandra N. Martinez
 
Cómo generar e implementar monitoreo para aplicaciones de Mule
Cómo generar e implementar monitoreo para aplicaciones de MuleCómo generar e implementar monitoreo para aplicaciones de Mule
Cómo generar e implementar monitoreo para aplicaciones de MuleAlexandra N. Martinez
 
reCONNECT 2021 May Meetup - Women Who Mule #4
reCONNECT 2021 May Meetup - Women Who Mule #4reCONNECT 2021 May Meetup - Women Who Mule #4
reCONNECT 2021 May Meetup - Women Who Mule #4Alexandra N. Martinez
 
Women Who Mule - April Meetup (Diane Kesler's Journey)
Women Who Mule - April Meetup (Diane Kesler's Journey)Women Who Mule - April Meetup (Diane Kesler's Journey)
Women Who Mule - April Meetup (Diane Kesler's Journey)Alexandra N. Martinez
 
Toronto Virtual Meetup #9 - KPIs and metrics accelerator
Toronto Virtual Meetup #9 - KPIs and metrics acceleratorToronto Virtual Meetup #9 - KPIs and metrics accelerator
Toronto Virtual Meetup #9 - KPIs and metrics acceleratorAlexandra N. Martinez
 
What is munit and how to create your first unit test
What is munit and how to create your first unit testWhat is munit and how to create your first unit test
What is munit and how to create your first unit testAlexandra N. Martinez
 
Toronto Virtual Meetup #8 - Tips for Reusability
Toronto Virtual Meetup #8 - Tips for ReusabilityToronto Virtual Meetup #8 - Tips for Reusability
Toronto Virtual Meetup #8 - Tips for ReusabilityAlexandra N. Martinez
 
Meetup en español #6 - MuleSoft para profesionales de Java (segunda edición)
Meetup en español #6 - MuleSoft para profesionales de Java (segunda edición)Meetup en español #6 - MuleSoft para profesionales de Java (segunda edición)
Meetup en español #6 - MuleSoft para profesionales de Java (segunda edición)Alexandra N. Martinez
 
Meetup en español #5 - Continuous Integration and Continuous Delivery (CI/CD)...
Meetup en español #5 - Continuous Integration and Continuous Delivery (CI/CD)...Meetup en español #5 - Continuous Integration and Continuous Delivery (CI/CD)...
Meetup en español #5 - Continuous Integration and Continuous Delivery (CI/CD)...Alexandra N. Martinez
 
Toronto Virtual Meetup #7 - Anypoint VPC, VPN and DLB Architecture
Toronto Virtual Meetup #7 - Anypoint VPC, VPN and DLB ArchitectureToronto Virtual Meetup #7 - Anypoint VPC, VPN and DLB Architecture
Toronto Virtual Meetup #7 - Anypoint VPC, VPN and DLB ArchitectureAlexandra N. Martinez
 
How to use Salesforce composite request connector in Mule
How to use Salesforce composite request connector in MuleHow to use Salesforce composite request connector in Mule
How to use Salesforce composite request connector in MuleAlexandra N. Martinez
 
Meetup en español #4 - MuleSoft para profesionales de Java
 Meetup en español #4 - MuleSoft para profesionales de Java Meetup en español #4 - MuleSoft para profesionales de Java
Meetup en español #4 - MuleSoft para profesionales de JavaAlexandra N. Martinez
 
Toronto Virtual Meetup #5 - API Security and Threats
Toronto Virtual Meetup #5 - API Security and ThreatsToronto Virtual Meetup #5 - API Security and Threats
Toronto Virtual Meetup #5 - API Security and ThreatsAlexandra N. Martinez
 
Toronto Virtual Meetup #4 - Anypoint Monitoring (Dashboards, Alerts) and Visu...
Toronto Virtual Meetup #4 - Anypoint Monitoring (Dashboards, Alerts) and Visu...Toronto Virtual Meetup #4 - Anypoint Monitoring (Dashboards, Alerts) and Visu...
Toronto Virtual Meetup #4 - Anypoint Monitoring (Dashboards, Alerts) and Visu...Alexandra N. Martinez
 
Toronto MuleSoft Meetup: Virtual Meetup #3
Toronto MuleSoft Meetup: Virtual Meetup #3Toronto MuleSoft Meetup: Virtual Meetup #3
Toronto MuleSoft Meetup: Virtual Meetup #3Alexandra N. Martinez
 

More from Alexandra N. Martinez (20)

Mejora tu productividad creando aplicaciones de Slack
Mejora tu productividad creando aplicaciones de SlackMejora tu productividad creando aplicaciones de Slack
Mejora tu productividad creando aplicaciones de Slack
 
Women Who Mule - Workshop series #2: Ghost
Women Who Mule - Workshop series #2: GhostWomen Who Mule - Workshop series #2: Ghost
Women Who Mule - Workshop series #2: Ghost
 
Women Who Mule - Workshop series: Create your own blog from scratch without a...
Women Who Mule - Workshop series: Create your own blog from scratch without a...Women Who Mule - Workshop series: Create your own blog from scratch without a...
Women Who Mule - Workshop series: Create your own blog from scratch without a...
 
Toronto Virtual Meetup #12 - Testing Strategies and MUnit Test Recorder
Toronto Virtual Meetup #12 - Testing Strategies and MUnit Test RecorderToronto Virtual Meetup #12 - Testing Strategies and MUnit Test Recorder
Toronto Virtual Meetup #12 - Testing Strategies and MUnit Test Recorder
 
Women Who Mule - June Meetup (EMEA)
Women Who Mule - June Meetup (EMEA)Women Who Mule - June Meetup (EMEA)
Women Who Mule - June Meetup (EMEA)
 
Cómo generar e implementar monitoreo para aplicaciones de Mule
Cómo generar e implementar monitoreo para aplicaciones de MuleCómo generar e implementar monitoreo para aplicaciones de Mule
Cómo generar e implementar monitoreo para aplicaciones de Mule
 
reCONNECT 2021 May Meetup - Women Who Mule #4
reCONNECT 2021 May Meetup - Women Who Mule #4reCONNECT 2021 May Meetup - Women Who Mule #4
reCONNECT 2021 May Meetup - Women Who Mule #4
 
Women Who Mule - April Meetup (Diane Kesler's Journey)
Women Who Mule - April Meetup (Diane Kesler's Journey)Women Who Mule - April Meetup (Diane Kesler's Journey)
Women Who Mule - April Meetup (Diane Kesler's Journey)
 
Toronto Virtual Meetup #9 - KPIs and metrics accelerator
Toronto Virtual Meetup #9 - KPIs and metrics acceleratorToronto Virtual Meetup #9 - KPIs and metrics accelerator
Toronto Virtual Meetup #9 - KPIs and metrics accelerator
 
What is munit and how to create your first unit test
What is munit and how to create your first unit testWhat is munit and how to create your first unit test
What is munit and how to create your first unit test
 
Truly Human part 1
Truly Human part 1Truly Human part 1
Truly Human part 1
 
Toronto Virtual Meetup #8 - Tips for Reusability
Toronto Virtual Meetup #8 - Tips for ReusabilityToronto Virtual Meetup #8 - Tips for Reusability
Toronto Virtual Meetup #8 - Tips for Reusability
 
Meetup en español #6 - MuleSoft para profesionales de Java (segunda edición)
Meetup en español #6 - MuleSoft para profesionales de Java (segunda edición)Meetup en español #6 - MuleSoft para profesionales de Java (segunda edición)
Meetup en español #6 - MuleSoft para profesionales de Java (segunda edición)
 
Meetup en español #5 - Continuous Integration and Continuous Delivery (CI/CD)...
Meetup en español #5 - Continuous Integration and Continuous Delivery (CI/CD)...Meetup en español #5 - Continuous Integration and Continuous Delivery (CI/CD)...
Meetup en español #5 - Continuous Integration and Continuous Delivery (CI/CD)...
 
Toronto Virtual Meetup #7 - Anypoint VPC, VPN and DLB Architecture
Toronto Virtual Meetup #7 - Anypoint VPC, VPN and DLB ArchitectureToronto Virtual Meetup #7 - Anypoint VPC, VPN and DLB Architecture
Toronto Virtual Meetup #7 - Anypoint VPC, VPN and DLB Architecture
 
How to use Salesforce composite request connector in Mule
How to use Salesforce composite request connector in MuleHow to use Salesforce composite request connector in Mule
How to use Salesforce composite request connector in Mule
 
Meetup en español #4 - MuleSoft para profesionales de Java
 Meetup en español #4 - MuleSoft para profesionales de Java Meetup en español #4 - MuleSoft para profesionales de Java
Meetup en español #4 - MuleSoft para profesionales de Java
 
Toronto Virtual Meetup #5 - API Security and Threats
Toronto Virtual Meetup #5 - API Security and ThreatsToronto Virtual Meetup #5 - API Security and Threats
Toronto Virtual Meetup #5 - API Security and Threats
 
Toronto Virtual Meetup #4 - Anypoint Monitoring (Dashboards, Alerts) and Visu...
Toronto Virtual Meetup #4 - Anypoint Monitoring (Dashboards, Alerts) and Visu...Toronto Virtual Meetup #4 - Anypoint Monitoring (Dashboards, Alerts) and Visu...
Toronto Virtual Meetup #4 - Anypoint Monitoring (Dashboards, Alerts) and Visu...
 
Toronto MuleSoft Meetup: Virtual Meetup #3
Toronto MuleSoft Meetup: Virtual Meetup #3Toronto MuleSoft Meetup: Virtual Meetup #3
Toronto MuleSoft Meetup: Virtual Meetup #3
 

Recently uploaded

EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 

Recently uploaded (20)

EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 

Reviewing a Complex DataWeave Transformation Use-case

  • 1. Reviewing a Complex DataWeave Transformation Use-case Alexandra Martinez
  • 2. All contents © MuleSoft Inc. 2 • Functions (fun) – Parameters using types – Calling functions with 2 parameters • Variables (var) • do statement to create scopes (local variables) • Object manipulation using object destructor {( )} • If/else • Selectors: – Index (array[0]) – Range (1 to 10) • Setting default values • Core functions/operators – isEmpty – reduce – map – groupBy – flatten – Remove (-) – Sum (+) – Concatenation (++) – Prepend (>>) Solution will make use of the following:
  • 3. All contents © MuleSoft Inc. 3 • Input JSON structure: – FlightOptions (array of objects) • Connections (array of objects) – ReferenceID (number) – TaxCode (string) – EndOfConnection (Boolean) Requirement
  • 4. All contents © MuleSoft Inc. 4 • Input JSON structure: – FlightOptions (array of objects) • Connections (array of objects) – ReferenceID (number) – TaxCode (string) – EndOfConnection (Boolean) • Output JSON structure: – Array of objects • AppliedTaxCode (string – from TaxCode) • AppliedConnections (array of objects) – Type (string – hardcoded value “Connection”) – IndexValue (number - dynamic) Requirement
  • 5. All contents © MuleSoft Inc. 5 • Logic: 1. For each object from the FlightOptions array, create one output object inside the output array. Requirement
  • 6. All contents © MuleSoft Inc. 6 • 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
  • 7. All contents © MuleSoft Inc. 7 • 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, even though the Connection might be inside a FlightOption object. Requirement
  • 8. All contents © MuleSoft Inc. 8 • 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, even though the Connection might be inside a FlightOption 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 object’s TaxCode. Requirement
  • 9. All contents © MuleSoft Inc. 9 • 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, even though the Connection might be inside a FlightOption 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 object’s TaxCode. 5. For each object from the Connections array (taking into account the EndOfConnection true/false logic), create one AppliedConnections object with: 1. a hardcoded Type value ”Connection” 2. an incrementing IndexValue throughout the complete output. Requirement
  • 10. All contents © MuleSoft Inc. • Examples per FlightOptions object: – 1) EndOfConnection: false – 2) EndOfConnection: true Requirement • Output: – 1 object containing – 2 AppliedConnections objects
  • 11. All contents © MuleSoft Inc. • Examples per FlightOptions object: – 1) EndOfConnection: true – 2) EndOfConnection: true Requirement • Output: – 2 objects containing – 1 AppliedConnections object each
  • 12. All contents © MuleSoft Inc. • Examples per FlightOptions object: – 1) EndOfConnection: false – 2) EndOfConnection: false – 3) EndOfConnection: false Requirement • Output: – 1 object containing – 3 AppliedConnections objects
  • 13. All contents © MuleSoft Inc. • Examples per FlightOptions object: – 1) EndOfConnection: false • Note: if this was true, it would behave the same Requirement • Output: – 1 object containing – 1 AppliedConnections object
  • 14. All contents © MuleSoft Inc. • Examples per FlightOptions object: – 1) EndOfConnection: false – 2) EndOfConnection: true – 3) EndOfConnection: false Requirement • Output: – 2 objects. • First: 2 AppliedConnections objects • Second: 1 AppliedConnections object
  • 15. All contents © MuleSoft Inc. 15 • DW Playground: https://dwl.mule.club/ • Input payload: {"FlightOptions":[{"Connections":[{"ReferenceID":111,"TaxCode":"ABC","EndOfConnection":false},{"ReferenceID":222,"TaxCode":"DEF","EndOfConnection":true}]},{"C onnections":[{"ReferenceID":333,"TaxCode":"GHI","EndOfConnection":true},{"ReferenceID":444,"TaxCode":"JKL","EndOfConnection":true}]},{"Connections":[{"Refere nceID":555,"TaxCode":"MNO","EndOfConnection":false},{"ReferenceID":666,"TaxCode":"PQR","EndOfConnection":false},{"ReferenceID":777,"TaxCode":"STU","EndOfC onnection":false}]},{"Connections":[{"ReferenceID":888,"TaxCode":"VWX","EndOfConnection":false}]},{"Connections":[{"ReferenceID":999,"TaxCode":"MNO","EndOfC onnection":false},{"ReferenceID":101,"TaxCode":"PQR","EndOfConnection":true},{"ReferenceID":102,"TaxCode":"STU","EndOfConnection":false}]}]} • Expected output: [{"AppliedTaxCode":"DEF","AppliedConnections":[{"Type":"Connection","IndexValue":1},{"Type":"Connection","IndexValue":2}]},{"AppliedTaxCode":"GHI","AppliedCon nections":[{"Type":"Connection","IndexValue":3}]},{"AppliedTaxCode":"JKL","AppliedConnections":[{"Type":"Connection","IndexValue":4}]},{"AppliedTaxCode":"STU", "AppliedConnections":[{"Type":"Connection","IndexValue":5},{"Type":"Connection","IndexValue":6},{"Type":"Connection","IndexValue":7}]},{"AppliedTaxCode":"VWX" ,"AppliedConnections":[{"Type":"Connection","IndexValue":8}]},{"AppliedTaxCode":"PQR","AppliedConnections":[{"Type":"Connection","IndexValue":9},{"Type":"Conn ection","IndexValue":10}]},{"AppliedTaxCode":"STU","AppliedConnections":[{"Type":"Connection","IndexValue":11}]}] • Format JSONs for better view: https://jsonformatter.curiousconcept.com/ Building the Solution
  • 16. All contents © MuleSoft Inc. 16 • 1) Extract the Connections arrays. Building the Solution
  • 17. All contents © MuleSoft Inc. 17 • 2) Change all the EndOfConnection to true for the last Connection object from the Connections array. Building the Solution
  • 18. All contents © MuleSoft Inc. 18 • 3) flatten the array of arrays to be just one array. Building the Solution
  • 19. All contents © MuleSoft Inc. 19 • 4) Add a new field to keep track of the object’s index, basing on the EndOfConnection field. – (i.e. for each EndOfConnection=true, stop incrementing the index) Building the Solution Index 1 Index 2 Index 1 Index 1 Index 1 Index 3 Index 2
  • 20. All contents © MuleSoft Inc. 20 • 5) Add a new field to keep track of the final AppliedConnections object’s (first) index where the object in question will be added. – This is calculated using the object’s index + 1 (to start at 1) and then minus the previously added indexBasedOnEOC field. Building the Solution Index 0 Index 2 Index 3 Index 4
  • 21. All contents © MuleSoft Inc. 21 • 6) Separate the objects based on the EndOfConnection value (true or false). Building the Solution
  • 22. All contents © MuleSoft Inc. 22 • 7) Take only the objects that are inside the “true” list. Building the Solution
  • 23. All contents © MuleSoft Inc. 23 • 8) Create the final output Building the Solution
  • 24. All contents © MuleSoft Inc. 24 • Playing with the indexes Index based on EndOfConnection 1 2 1 1 1 2 3 1 1 1 2
  • 25. All contents © MuleSoft Inc. 25 • Playing with the indexes index + 1 1 3 4 5 2 6 7 8 9 10 11 Index based on EndOfConnection 1 2 1 1 1 2 3 1 1 1 2
  • 26. All contents © MuleSoft Inc. 26 • Playing with the indexes AppliedConnections Index (index+1) - indexBasedOnEOC 1-1=0 3-1=2 4-1=3 5-1=4 2-2=0 6-2=4 7-3=4 8-1=7 9-1=8 10-2=8 11-1=10 Index based on EndOfConnection 1 2 1 1 1 2 3 1 1 1 2
  • 27. All contents © MuleSoft Inc. 27 • Playing with the indexes AppliedConnections Index (index+1) - indexBasedOnEOC IndexValue indexBasedOnEOC (or actualIndex or actualNum) + indexAppliedConnections 0 2 3 4 0 4 4 7 8 8 10 Index based on EndOfConnection 1 2 1 1 1 2 3 1 1 1 2 1+0=1 2+0=2 1+2=3 1+3=4 1+4=5 2+4=6 3+4=7 1+7=8 1+8=9 2+8=10 1+10=11
  • 28. All contents © MuleSoft Inc. 28 • Github repository: https://github.com/alexandramartinez/reviewing- a-complex-dw-transformation-use-case/ Code
  • 29. All contents © MuleSoft Inc. 29 • https://docs.mulesoft.com/mule-runtime/4.3/dataweave-functions • https://docs.mulesoft.com/mule-runtime/4.3/dataweave-variables • https://docs.mulesoft.com/mule-runtime/4.3/dataweave-flow-control • https://docs.mulesoft.com/mule-runtime/4.3/dataweave-selectors • https://docs.mulesoft.com/mule-runtime/4.3/dataweave-cookbook-defaults • https://docs.mulesoft.com/mule-runtime/3.9/dataweave-operators • https://docs.mulesoft.com/mule-runtime/4.3/dw-operators • https://docs.mulesoft.com/mule-runtime/4.3/dw-core-functions-isempty • https://docs.mulesoft.com/mule-runtime/4.3/dw-core-functions-reduce • https://docs.mulesoft.com/mule-runtime/4.3/dw-core-functions-map • https://docs.mulesoft.com/mule-runtime/4.3/dw-core-functions-groupby • https://docs.mulesoft.com/mule-runtime/4.3/dw-core-functions-flatten References