From bd27eb73df8b25a7dd0fe2452d2728214ff3b513 Mon Sep 17 00:00:00 2001 From: Cristian Date: Mon, 23 Jun 2025 16:33:52 -0300 Subject: [PATCH 1/2] W-18850512-Update-tut-DW-CP --- .../pages/tut-af-integrate-use-dataweave.adoc | 161 ++---------------- 1 file changed, 11 insertions(+), 150 deletions(-) diff --git a/modules/ROOT/pages/tut-af-integrate-use-dataweave.adoc b/modules/ROOT/pages/tut-af-integrate-use-dataweave.adoc index a49be264c..bd4b3f8a5 100644 --- a/modules/ROOT/pages/tut-af-integrate-use-dataweave.adoc +++ b/modules/ROOT/pages/tut-af-integrate-use-dataweave.adoc @@ -14,168 +14,29 @@ Complete these procedures: . xref:tut-af-integrate-am-flights.adoc[] . xref:tut-af-integrate-connect-to-a-db.adoc[] -[[snippets]] -== Create a User Snippet for the Transformation - -Define snippets in the `mule-xml.json` file. For information about snippets, see xref:work-with-code-snippets.adoc[]. - -// Pointer to Configure Snippets -include::partial$acb-reusable-steps.adoc[tags="configure-user-snippets"] -. In the *Select Snippets File or Create Snippets* field that opens, enter: -+ -[source,command] ----- -mule-xml.json (Mule XML) ----- -. If the file has no configurations, `mule-xml.json` provides comments within curly braces: -+ -[source,json] --- -{ - // Place your snippets for mule-xml here. Each snippet is defined under a snippet name and has a prefix, body and - // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: - // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the - // same ids are connected. - // Example: - // "Print to console": { - // "prefix": "log", - // "body": [ - // "console.log('$1');", - // "$2" - // ], - // "description": "Log output to console" - // } -} --- -. Add this snippet code to the file: -+ -[[collapsible]] -[source,json] ----- -{ - "Transform Message": { - "prefix": "muledx:transform-message", - "body": [ - "", - " ", - " ", - " ", - " ", - " ", - "" - ] - }, - "Mule Flow": { - "prefix": "muledx:flow", - "body": [ - "", - "", - "" - ] - }, - "HTTP Listener Config": { - "prefix": "muledx:http-listener-config", - "body": [ - "", - " ", - "" - ] - }, - "HTTP Listener": { - "prefix": "muledx:http-listener", - "body": [ - "" - ] - }, - "Set Payload": { - "prefix": "muledx:set-payload", - "body": [ - "" - ] - }, - "Set Variable": { - "prefix": "muledx:set-variable", - "body": [ - "" - ] - }, - "Logger": { - "prefix": "muledx:logger", - "body": [ - "" - ] - }, - "Database Config - MySQL": { - "prefix": "muledx:db-config-mysql", - "body": [ - "", - " ", - "" - ] - }, - "Database Select": { - "prefix": "muledx:db-select", - "body": [ - "", - " ", - " ", - " ", - "" - ] - } -} ----- -+ -The snippets provide starting configurations for several Mule components, including Transform Message. -. Proceed to <>. - [[return-payload]] == Return the Payload as JSON . In Anypoint Code Builder, open `american-ws-anypoint-code-builder.xml`. -. From the canvas, insert the snippet `Transform Message` below the *Database Select* operation. +. From the canvas, add a `Transform Message` component after the *Database Select* operation. + -After the listener, click the image:icon-plus.png["",15,15] (*Add component*) icon and navigate to *Snippets* > *User Snippets* > *Transform Message*. +After the listener, click the image:icon-plus.png["",15,15] (*Add component*) icon and add a *Transform Message* component. + -If the *User Snippets* panel is empty at first, wait a moment, and try again. Alternatively, navigate to the `muledx:transform-message` snippet from the configuration XML: +image::transformation-builder-dataweave-tab.png["Transformation Builder DataWeave tab"] + -//TODO: image seems out of date; where's the plus icon? -image::transform-with-output-json.png["Transform component highlighted"] +. Enter this DataWeave script into the script editor: + -.User snippet XML: -[source,xml] +[source,dataweave] ---- - - - - - - - +%dw 2.0 +output application/json +--- +payload ---- -. In the configuration XML, add the `doc:name` value *Transform Message* or similar to the `` component: + ----- - -... ----- -. Within `` add a DataWeave script that outputs the message payload to a JSON format: +The `payload` variable holds the output from the previous component, which in this case is the array of flight data from the *Database Select* operation. + -[source,dataweave] --- - - - - - - - --- +. Use the *Preview* tab to see the JSON output. . Deploy your app within the IDE by selecting *Run* > *Start Debugging (F5)*. + For guidance, see xref:tut-af-integrate-am-flights.adoc#run[Run Your App in Debug Mode]. From d310c6c99903f8ed41582ee1afa0d63b5aec651e Mon Sep 17 00:00:00 2001 From: Cristian Pose <101070178+Crispy-Salesforce@users.noreply.github.com> Date: Mon, 23 Jun 2025 17:09:39 -0300 Subject: [PATCH 2/2] W-18850512-Update-content-CP W-18850512-Update-content-CP --- modules/ROOT/pages/tut-af-integrate-use-dataweave.adoc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/ROOT/pages/tut-af-integrate-use-dataweave.adoc b/modules/ROOT/pages/tut-af-integrate-use-dataweave.adoc index bd4b3f8a5..80ab9752a 100644 --- a/modules/ROOT/pages/tut-af-integrate-use-dataweave.adoc +++ b/modules/ROOT/pages/tut-af-integrate-use-dataweave.adoc @@ -18,12 +18,9 @@ Complete these procedures: == Return the Payload as JSON . In Anypoint Code Builder, open `american-ws-anypoint-code-builder.xml`. -. From the canvas, add a `Transform Message` component after the *Database Select* operation. +. From the canvas, add a *Transform Message* component after the *Database Select* operation. + After the listener, click the image:icon-plus.png["",15,15] (*Add component*) icon and add a *Transform Message* component. -+ -image::transformation-builder-dataweave-tab.png["Transformation Builder DataWeave tab"] -+ . Enter this DataWeave script into the script editor: + [source,dataweave]