Task 5: Using the interaction policy

You add a storm alert by updating the data and decision models. When you run the decision model to test the storm alert, it produces a greeting and a warning to stay home.

Step 1: Adding an attribute

  1. Click the Navigation history Navigation history icon icon in the upper right bar, and then click Data to return to the data model.
  2. In the left panel, select weather.
  3. In the Attributes section, click the Add + button to create an attribute.
  4. Change the name of the attribute to storm alert, and set its type to boolean.

Step 2: Modifying the decision logic

Rules are run in a specific order. By default, they are sequentially run in the order in which they are listed in a decision node. However, you can supersede the default behavior by setting the order for running the rules (see Choosing an interaction policy).

  1. Open the Navigation history Navigation history icon and return to My Model.
  2. Select the Weather advice node, and open the Logic tab.
  3. Click Create rule artifact Add rule artifact button and select Business rule.
  4. Enter storm rule in the Name field, and select Weather is storm alert in the list of criteria.
  5. Click Create.

    The rule opens in the rule editor. The Error report tab shows an error. You fix the error when you define the rule.

  6. Enter the following rule statement:
    if
        Weather is storm alert
    then
        set decision to "Stay home! There is a storm alert." ;
  7. Click Back to the diagram.
  8. To set the order for applying the rules, expand Rules are applied in sequence in the right panel, and select First rule applies in the menu.
  9. Open the overflow menu Overflow menu icon next to the storm rule in the Logic tab, and select Move to top to apply the rule first.

    Now, the storm rule runs first. When the storm alert notice is selected in the list of test data, a storm warning is added to the output message.

Step 3: Running the model

  1. Go to the Run tab.
  2. Add the following test data:
    • name: Jamie
    • rainForecast: 100
    • stormAlert: True (Select the box.)
    • temperature: cold
  3. Click the Rename test data set Rename test data set icon icon.
  4. Enter Jamie-storm as the new name of the data set, and press Enter.
  5. Click Run. You get the following message:
    "Hello Jamie! Stay home! There is a storm alert."
  6. Add another set of test data:
    • name: Robin
    • rainForecast: 90
    • stormAlert: False (Do not select the box.)
    • temperature: cold
  7. Rename the data set Robin-rain.
  8. Click Run. You get the following message:
    "Hello Robin! Rainy day. Take an umbrella."