Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Dataweave in studio

247 views

Published on

The DataWeave Language is a powerful template engine that allows you to transform data to and from any kind of format (XML, CSV, JSON, Pojos, Maps, etc).

Published in: Software
  • Be the first to comment

  • Be the first to like this

Dataweave in studio

  1. 1. USING DATAWEAVE IN STUDIO BY ACHYUTA LAXMI
  2. 2. Overview  Introduction  Using the DataWeave Transformer  The DataWeave Text Editor UI  The Graphical UI  Defining Input Structure  Explicitly Defining a MIME Type  Conclusion
  3. 3. INTRODUCTION DataWeave is Mule’s most powerful and versatile tool for transforming data. TheTransform Message component carries out a transformation of your Mule message that follows a transform script, this transform script can be explicitly written in DataWeave code or you can use the UI to build it implicitly through dragging and dropping elements. DataWeave fully supports DataSense, allowing you to leverage metadata from connectors, schemas and sample documents to more easily design your transformations. DataSense provides content assist while you are coding and scaffolds and auto generates lines of code form actions performed in the UI. TheTransform Message component offers you a preview of your output that is built on sample data and is updated in real time as you make changes to your transform, so that you can be sure of what you’ll be getting out of the other end.
  4. 4. USING THE DATAWEAVE TRANSFORMER When adding a Transform Message element to a Mule Flow, it takes the elements from the incoming Mule Message as its inputs. It then performs the necessary actions to produce a Mule message as output for the next element in the flow.
  5. 5. THE DATAWEAVE TEXT EDITOR UI Although DataWeave as a language supports adding input directives and naming these by any name you like, when using DataWeave in Anypoint Studio, it’s not necessary to declare any input directives for any of the components of the Mule Message that arrives to the DataWeave transformer (Payload, flow variables and input/outbound properties) nor for any system variables. These are already implicitly recognized as inputs and can be referenced anywhere in the DataWeave body without a need to include them in the header, their type is known from Mule metadata.
  6. 6. THE GRAPHICAL UI Two tree views show the known metadata contents of the incoming and the outgoing Mule Messages, allowing you to explore them and know what data is available for using as an input and where it can fit into, and how to reference each of these parts. You can simplify or hide the graphical UI if you wish by clicking the icons on the top right to select between the different views for this properties editor:
  7. 7. DEFINING INPUT STRUCTURE If the other elements in your Mule flow expose metadata about their input and output, then this information will already be available to the Transform Message component. If they don’t, you can configure these elements so that they expose this information by editing their Metadata tab. For example, you can configure an HTTP connector and assign it a JSON sample file so that this sample’s structure is exposed as metadata that your Transform Message component can read. If the Mule flow doesn’t expose Metadata about the elements you need from the incoming message, you can also manually specify it directly in the input section of your Tranform Message component. If a metadata definition is missing, a notification will advise you to provide one, otherwise you can also right-click your input and select Set Metadata.
  8. 8. YOU CAN SELECT AN EXISTING METADATA TYPE, THIS MAY SAVE YOU SEVERAL STEPS:
  9. 9. OR YOU CAN ALSO BUILD YOUR METADATA FREELY USING AN EDITOR:
  10. 10. This sample data is used together with your DataWeave code to produce a sample output in the output section, which gets updated in real time as you make changes. You can then define the data structure manually by writing or pasting a sample into the newly created tab.
  11. 11. By default, DataWeave should be able to recognize the type of an input from the metadata. If you must explicitly define an input payload type, use the mime type attribute in an XML tag as in the example below . Explicitly Defining a MIME Type
  12. 12. CONCLUSION The DataWeave Language is a powerful template engine that allows you to transform data to and from any kind of format (XML, CSV, JSON, Pojos, Maps, etc). References: https://docs.mulesoft.com/ https://docs.mulesoft.com/mule-user-guide/v/3.7/using-dataweave-in-studio
  13. 13. Thank you

×