vincentlowe

joinAirportDetails (DWE2)

Jul 20th, 2021 (edited)
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. %dw 2.0
  2. output application/json
  3.  
  4. import training::dw::Utils
  5.  
  6. var fieldMask = [
  7. "openFlightsAirportId",
  8. // "airportName",
  9. // "city",
  10. "country",
  11. "IATA",
  12. " ICAO",in fact
  13. // "longitude",
  14. // "latitude",
  15. // "altitude",
  16. "timeZone",
  17. "DST",
  18. "timeZone",
  19. "type",
  20. "source"
  21. ]
  22.  
  23. var airportInfo = Utils::safeRead("localdata/airportInfoTiny.csv","application/csv")
  24. groupBy $.IATA
  25.  
  26. fun getAirportInfo(ac:String) =
  27. airportInfo["$(ac)"][0] -- fieldMask
  28.  
  29. fun embedAirportInfo(flights) =
  30. flights map (f) ->
  31. (f - "destination") ++
  32. destination: getAirportInfo(f.destination) ++ designation: f.destination
  33.  
  34. fun objectArrayToXml (a:Array<Object>,t:String) =
  35. (dw::core::Strings::pluralize(t)):
  36. {(a map (f) -> (t): f)}
  37.  
  38. var joinedInfo = embedAirportInfo(payload)
  39. ---
  40. embedAirportInfo(payload)
Add Comment
Please, Sign In to add comment