ricardozanini / tenkichannel

A sample application for test scenarios with Kogito Runtimes
Apache License 2.0
9 stars 8 forks source link

Displays the location in a human readable way #6

Open ricardozanini opened 4 years ago

ricardozanini commented 4 years ago

We're displaying the location using latitude and longitude properties from the location in the UI. It's totally feasible to have a human readable location instead since the Weather API has this value:

{
   "coord":{
      "lon":-46.64,
      "lat":-23.63
   },
   "weather":[
      {
         "id":500,
         "main":"Rain",
         "description":"light rain",
         "icon":"10d"
      },
      {
         "id":701,
         "main":"Mist",
         "description":"mist",
         "icon":"50d"
      }
   ],
   "base":"stations",
   "main":{
      "temp":292.43,
      "pressure":1020,
      "humidity":88,
      "temp_min":291.15,
      "temp_max":293.15
   },
   "visibility":8000,
   "wind":{
      "speed":4.1,
      "deg":160
   },
   "clouds":{
      "all":90
   },
   "dt":1570561353,
   "sys":{
      "type":1,
      "id":8446,
      "message":0.008,
      "country":"BR",
      "sunrise":1570524010,
      "sunset":1570568875
   },
   "timezone":-10800,
   "id":3461570,
   "name":"Ibirapuera",
   "cod":200
}
Fibii commented 4 years ago

using the json you gave, you want to display something like: Your location is Ibirapuera ?

ricardozanini commented 4 years ago

Exactly. I guess that “Ibirapuera/BR” would be better. :)

Fibii commented 4 years ago

I figured out how to get the location from weather-api-gateway by adding a location string to Weather so the returned json has condition and location as data, i couldn't find a way to add location to the returned json from rain-forecast-process tho, since it depends on RainForecastProcess.bpmn2 script? can you give me a little help to get it going?

ricardozanini commented 4 years ago

Yes! Sure! You have to edit the BPMN process using an editor (I recommend the eclipse BPMN2 plugin). There’s a doc how to install it in the jBPM docs (sorry I’m on the cellphone). The return of the Camel call will be injected in the domain Model. Take a look at this:

https://github.com/ricardozanini/tenkichannel/blob/master/rain-forecast-process/src/main/java/org/tenkichannel/forecast/rain/WeatherServiceCallWorkItemHandler.java#L27

Here’s where we treat the Weather service return.

BTW, how did you find this project?

Thanks for your contribution!!