Simulating a weather service response
6 Tasks
30 mins
Advanced
Pega Platform 8.6
English
Scenario
Front Stage needs to know if the probability of rain equals or exceeds 40 percent during an event. At present, the weather forecast queries a data transform. Front Stage now wants to query a true weather forecast service the day before an event.
The forecast is performed for the location where the event is being held, as opposed to the user's browser location. Given that the role of the user is Facility Coordinator, assume the browser user is in close proximity to the event.
The following table provides the credentials you need to complete the challenge.
Role |
User name |
Password |
---|---|---|
Administrator |
admin@forecast |
rules |
In order to provide the best services and arrangements, FSG wants the prediction/forecast to happen one day before each day of the event.
Create an interface a data page to pull the weather forecast. The parameters when querying the service are:
- StartDate
- EndDate
- Latitude
- Longitude
The response is a list of pages.
{ "forecast":[ { "Date":"20170731" ,"Probability":"35" ,"Unit":"Percent" }, { "Date":"20170801" ,"Probability":"40" ,"Unit":"Percent" } ] }
Use any weather URL for the simulated weather service (for example, http://weather-forecast.com). Develop a UI to display the request parameters. The REST response may contain as many elements as the number of days the event is held. Post-process the response to identify if the probability of rain equals or exceeds 40 percent.
Detailed Tasks
1 Identify design options
The data can be simulated using one of the following options.
Option 1:
Enable simulate data source option of the data page and create a data transform to simulate the response.
Option 2:
Associate a simulation activity to the rest connector.
Option 3:
Create a REST service and get the forecast results from the service.
2 Evaluate design options
Design | Pros | Cons |
---|---|---|
Simulate Data Source |
|
|
Connector Simulation Activity |
|
|
Creating REST Service |
|
|
3 Recommend the best design option
In this scenario, we used simulate data source approach as its easily configurable and have multiple source options. The approach might change based on the strategy we use to forecast the weather forecast service results.
4 Identify required configuration tasks
To complete the assignment, accomplish the following tasks:
- Create a new Rest connector by consuming the weather forecast service.
- Create a new D_FCbyCoords data page.
- Configure the new D_FCbyCoords data page to use the REST Connector created in step 1.
- Create a Simulation data transform to replicate the response as the web service is not available.
- Create different strategies to have the rain forecast of varying probability.
- Simulate the data source of the data page D_FCbyCoords
- Capture the location coordinates (latitude/longitude) of the event location and event days (start date and end date) from the Booking case.
- Modify the Weather case life cycle to conditionally make preparations if the probability of rain captured part of service response exceeds or equal to 40 percent.
- Verify the work.
5 Review solution details
Per the requirement, the forecast needs to occur for all the event days and one day before each event day. When a weather case is created, it needs to have the data (event days, event location details) propagated from the Booking case. One day prior to each event day, weather forecast service is invoked with the event days and location coordinates as parameters.
If the forecast service responds that there is a probability of rain for a specific event day, the case needs to be routed to the weather specialized facility coordinator to make arrangements. Once the arrangements are made, the facility coordinator submits the case and waits for the next forecast.
If the forecast service responds that there is no possibility of rain for a specified event day, the case proceeds and waits for the next forecast.
The process repeats for all the event days. After the forecast of the last event day, the case waits for the event closure. When the event ends, the forecast case gets routed to the weather-specialized facility coordinator for the teardown.
In case the forecast responds that there is no probability of rain, but does indeed rain, the facility coordinator must have an option to manually invoke the arrangements while the case waits for the next forecast.
The case is resolved when the facility coordinator completes the teardown.
The solution is implemented in the WForecast and WForecastInt rulesets. The case life cycle and workflow are designed as shown in the following image.
As the service is invoked by using dates and coordinates as parameters, the service is consumed under FCCoord (forecast by coordinates) class under application-specific Int- layer. There is a possibility that the forecast service can provide services based on the event ZIP code. The FCZip class is created for the ZIP code.
It is assumed that the application-specific constants (Rain Probability and Weather Preparation SLA) can be changed at any point by the business and it needs to be easily configurable.
6 Implement an additional challenge
The number of days before the event the weather forecast case gets created should be easily configurable by a citizen developer.
Available in the following mission:
If you are having problems with your training, please review the Pega Academy Support FAQs.
Want to help us improve this content?