vincentlowe

enrichPassengerRecords (DWE2)

Jul 20th, 2021 (edited)
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. %dw 2.0
  2. output application/dw
  3. import training::dw::Utils
  4. import * from dw::core::Strings
  5.  
  6. var passengerRecords = Utils::safeReadInput("localdata/passengerRecords.csv","application/csv")
  7. var flightsWithDetails = payload.flights
  8.  
  9. var reservationsXml = Utils::jsonArrayToXML (
  10. dw::core::Arrays::join(
  11. passengerRecords as Array<Object>,
  12. flightsWithDetails.*flight,
  13. (pass) -> pass."Flight Code",
  14. (flight) -> flight.flightCode
  15. ).r, "reservation"
  16. )
  17.  
  18. ---
  19. reservationsXml
  20. update {
  21. case lat at .reservations.*reservation.*destination.latitude ->
  22. lat as Number as String {format: "###.0000"}
  23. case long at .reservations.*reservation.*destination.longitude ->
  24. long as Number as String {format: "###.0000"}
  25. }
  26. update {
  27. case res at .reservations.*reservation ->
  28. res mapObject (v,k,i) ->
  29. (capitalize(k)): v
  30. }
  31. dw::util::Values::mask "Price" with "*****.**"
  32.  
  33.  
Add Comment
Please, Sign In to add comment