DVM-Domain value mapping
4/3/2025
DVM :
Domain value mapping as the name suggests is the approach of selecting values used in one domain for specific fields to the value used in another domain for same fields.
Purpose
DVMs are used to translate or map values from a source domain (e.g., a database field) to a target domain (e.g., a UI display or a different system)
Implementation:
Example:
Longname | Shortname | Language | Capital |
Karnataka | KA | Kannada | Bangalore |
Tamilnadu | TN | Tamil | Chennai |
Andhrapradesh | AP | Telugu | Amaravathi |
Kerala | KL | Malayalam | Trivandram |
Here the column names are the different fields like Longname, Shortname, Language and Capital and these values are getting changed e.g. for each state like Karnataka or Tamilnadu
So we can think that in one domain Shortname can be used to capture State and whereas in another domain Longname can be used to capture State but their other details will still hold true e.g. Capital or Language or any other fact
To implement such scenario in MuleSoft we have to use YAML as properties file
To Start with – we will create a mule API which will accept Longname or Shortname as input and return different information from the above table
Create a project which will accept state as query parameter
Let’s create YAML to reflect above table structure – CountryDVM.yaml
State:
Karnataka:
Longname: "Karnataka"
Shortname: "KA"
Language: "Kannada"
Capital: "Bangalore"
KA:
Longname: "Karnataka"
Shortname: "KA"
Language: "Kannada"
Capital: "Bangalore"
Tamilnadu:
Longname: "Tamilnadu"
Shortname: "TN"
Language: "Tamil"
Capital: "Chennai"
TN:
Longname: "Tamilnadu"
Shortname: "TN"
Language: "Tamil"
Capital: "Chennai"
Andhrapradesh:
Longname: "Andhrapradesh"
Shortname: "AP"
Language: "Telugu"
Capital: "Hyderbad"
AP:
Longname: "Andhrapradesh"
Shortname: "AP"
Language: "Telugu"
Capital: "Hyderbad"
Kerala:
Longname: "Kerala"
Shortname: "KL"
Language: "Malayalam"
Capital: "Trivandram"
KL:
Longname: "Kerala"
Shortname: "KL"
Language: "Malayalam"
Capital: "Trivandram"
Create a configuration properties entry to read YAML as properties file
Now we will add a transformation to create response from the YAML properties file
Dataweave:
%dw 2.0
output application/json
var inputState = attributes.queryParams.state
---
{
(if (sizeOf(p('State.' ++ inputState ++ '.Longname') default "") > 0)
(
{
Longname: p('State.' ++ inputState ++ '.Longname'),
Shortname: p('State.' ++ inputState ++ '.Shortname'),
Language: p('State.' ++ inputState ++ '.Language'),
Capital: p('State.' ++ inputState ++ '.Capital')
}
)
else
(
{
"message": "info not available"
}
))
}
Now if we will Deploy and test this API in postman
Will get valid response for available states – Tamilnadu
For unavailable states
Advantages of having DVM approach
If new information comes then it will be added into YAML file e.g. add states
YAML provide a better readable structure which is more hierarchical
If one domain retrieve the values on the basis of Longname and other on Shortname then both can use the same DVM
If new domain comes e.g. Initials then we can extend the DVM to accommodate new domain
Conclusion:
Domain Value Mapping in MuleSoft enables seamless integration by transforming data into consistent, standardized formats across systems. It simplifies data handling, improves system interoperability, and enhances overall workflow efficiency. By leveraging MuleSoft’s powerful mapping capabilities, businesses can ensure smooth communication between diverse applications.