Skip to main content

Simulating a weather service response

6 Tasks

30 mins

Visible to: All users
Advanced Pega Platform 8.6 English
Verify the version tags to ensure you are consuming the intended content or, complete the latest version.

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.

You must initiate your own Pega instance to complete this Challenge.

Initialization may take up to 5 minutes so please be patient.

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 1 Image showing the source of the data page

Option 2:

Associate a simulation activity to the rest connector.

Option 2 image showing how to use the simulation option

Option 3:

Create a REST service and get the forecast results from the service.

2 Evaluate design options

Design Pros Cons
Simulate Data Source
  • Easy to configure
  • Can be sourced as Data transform, Report definition, lookup, activity
  • Need unlocked ruleset version unless managed by a when rule referring a logic when to refer simulated data source and a Dynamic system setting set to true when needed to call simulated source
Connector Simulation Activity
  • Can control the simulation activity applicability whether applies to a particular requestor session (user session) or to all requestors sessions (global)
  • Need to Associate with a ruleset version
Creating REST Service
  • More control as needed to manage the endpoint URL (actual service or simulated service)
  • More development effort is needed to create and consume a completely new REST service like actual 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:

  1. Create a new Rest connector by consuming the weather forecast service.
  2. Create a new D_FCbyCoords data page.
  3. Configure the new D_FCbyCoords data page to use the REST Connector created in step 1.
  4. Create a Simulation data transform to replicate the response as the web service is not available.
  5. Create different strategies to have the rain forecast of varying probability.
  6. Simulate the data source of the data page D_FCbyCoords
  7. Capture the location coordinates (latitude/longitude) of the event location and event days (start date and end date) from the Booking case.
  8. 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.
  9. 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.

WeatherFC - Routing - Solution Detail Requirements 1

 

WeatherFC - Routing - Solution Detail Requirements 2

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.

Class structure

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.

WeatherFC - Data Types and Integration Simulation _4

 

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.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice