ILOG JRules User Guide > Running and Debugging > Getting Started > Tutorial: Debugging a Ruleset > Task 4: Correcting the Problem

When the application determines that a customer qualifies for a special offer, for instance through the pricing.qualifyFor.LongTermDiscount rule, the RentalAgreement object is supposed to be updated to include that offer. The rule engine should then evaluate the updated RentalAgreement object and fire the rule that computes the price for this special offer, for instance the pricing.price.LongTermDiscount rule. Since the rules that compute the price are not being triggered, it means that the RentalAgreement object is not being updated, and the rule engine cannot see the offer to evaluate it.

In this task, you are going to modify the Business Object Model (BOM) so that the addOffer method updates the Rental Agreement object. You will then remove the breakpoints you inserted earlier.

To modify the BOM so that the addOffer method updates the RentalAgreement object:

  1. To make sure you are in the Rule perspective: on the Window menu, click Open Perspective > Other and choose Rule in the Select Perspective dialog.
  2. Open the pricing.qualifyFor.LongTermDiscount rule
  3. In the rule actions, press and hold the Ctrl key while passing the cursor over the words qualifies for; when the phrase becomes underlined, press the left mouse button.
  4. This opens the BOM editor for the member bom > model > carrental > RentalAgreement > addOffer(String) corresponding to the {this} qualifies for the {0} offer phrase.
  5. Check Update object state, and save your work.
  6. Now when the rules execute, the addOffer method will update the RentalAgreement object to show that it qualifies for a special offer.
  7. Start the debugging session again (click images/tut_icon_debug.png on the toolbar or select Run > Debug) with debug-start-configuration, and execute the application until you stop in the qualifyFor.LongTermDiscount rule.
  8. Inspect the Agenda view, and note that the qualifyFor.SuperBowl rule is listed.
  9. The execution is stopped before the phrase 'the current rental agreement' qualifies for the "long term" offer in the pricing.qualifyFor.LongTermDiscount rule. If you switch the rule view from Intellirule to IRL, you will see that the ?context.updateContext(); statement is now present in the rule.
  10. Step over updateContext by clicking twice on images/tut_icon_stepOver.png Step Over on the toolbar or in the Run menu.
  11. In the Agenda view, note that the pricing.price.LongTermDiscount rule was triggered.
  12. Continue stepping over until you reach this line in the pricing.price.LongTermDiscount rule:
in 'the current session' , display the message : " set the price of the long term offer for the" + 'the current rental agreement' description ;
  1. Inspect the agenda, and note in pricing.price.LongTermDiscount that a price was computed for the long term offer.
  2. Press images/tut_icon_stepOver.png Step Over until the console displays:
Rental Agreement for Julian Bayles (May 20, 1970)qualifies for the long term offer
  set the price of the long term offer for the Rental Agreement for Julian Bayles (May 20, 1970)
  Rental Agreement for Julian Bayles (May 20, 1970)qualifies for the Super Bowl offer
Allocating the small discount to the Super Bowl offer for Rental Agreement for Julian Bayles (May 20, 1970)
   * Offer: standard price: 579.90
   * Offer: Super Bowl price: 550.90 (5.00 % discount)
   * Offer: long term price: 529.90
   # Best Offer: long term price: 529.90
The output now includes the prices for all offers and shows the long term price as the best offer.

Now that the RentalAgreement object is being updated correctly, you can remove the breakpoints in the rules so that they execute normally.

To remove the breakpoints:

  1. In the Debug perspective, open the Breakpoints view.
  2. Click images/remove_all_breakpoints.png Remove All Breakpoints.
  3. Now that the breakpoints are removed, resume execution (click Resume or press F8).

images/arrow_next.gif Next: Task 5: Stepping through the BOM to XOM Mapping