< Previous | Next >

Task 4: Correcting the problem

You modify a BOM to correct a problem in the application.

About this task

When the application determines that a customer qualifies for a special offer, for instance through the pricing.qualifyFor.LongTermDiscount rule, it is supposed to update the RentalAgreement object to include the offer. Then, the rule engine evaluates the updated RentalAgreement object. Based on this evaluation, the rule engine runs the rule that calculates the price for this special offer, for instance the pricing.price.LongTermDiscount rule. The problem is that the rules do not update the RentalAgreement object, and the rule engine cannot see the offer to evaluate it. As a result the application does not run the rules that compute the price.

In this task, you modify the business object model (BOM) so that the addOffer method updates the RentalAgreement object. Then, you remove the breakpoints that you inserted.

Step 1: Modifying the BOM

About this task

You modify the BOM so that the addOffer method updates the RentalAgreement object.

Procedure

  1. To make sure that you are in the Rule perspective, click Window > Open Perspective  > Other > Rule.
  2. Open the pricing.qualifyFor.LongTermDiscount rule with the Intellirule editor.
  3. In the rule actions, press and hold the Ctrl key while you pass the cursor over the words qualifies for. When the phrase becomes underlined, click it.

    The BOM editor for the member addOffer(String) opens.

  4. Select the Update object state box under General Information, and then click File > Save to save your work.

    Now when the rules run, the addOffer method updates the RentalAgreement object to show that it qualifies for a special offer.

  5. In the Debug Configurations dialog, select the Rule Project > Debug-start-Julian launch configuration, and then click Debug.
  6. Click the Resume "" button, or press F8, to run the application until you stop in the qualifyFor.LongTermDiscount rule.
  7. Inspect the Agenda view and note that the pricing.qualifyFor.SpringSeason rule is listed.

    The application stopped at the phrase 'the current rental agreement' qualifies for the "long term" offer in the qualifyFor.LongTermDiscount rule.

  8. Step over updateContext by clicking Step Over button ""twice on the toolbar or in the Run menu.

    In the Agenda view, you can see that the pricing.price.LongTermDiscount rule ran.

  9. 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 ;
  10. Inspect the agenda. In pricing.price.LongTermDiscount, the application computed a price for the long-term offer.
  11. Click the Resume button "" until the console displays the following text:
    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 Spring Season offer
    Allocating the small discount to the Spring Season offer for Rental Agreement 
    for Julian Bayles (May 20, 1970)
       * Offer: standard price: 579.90
       * Offer: Spring Season price: 550.90 (5.00 % discount)
       * Offer: long term price: 529.90
       # Best Offer: long term price: 529.90

    The output now includes prices for all the offers and shows the long-term price as the best offer.

Step 2: Removing the breakpoints

About this task

Now that the application is updating the RentalAgreement object correctly, you can remove the breakpoints in the rules so that they run normally.

Procedure

  1. In the Debug perspective, open the Breakpoints view.
  2. Click the Remove All Breakpoints button "" .

What to do next

In the next task, you step through the BOM-to-XOM mapping.
< Previous | Next >