< 上一课 | 下一课 >

任务 4:更正问题

将修改 BOM 以更正应用程序中的问题。

关于此任务

当应用程序确定客户符合特殊报价条件时(例如,通过 pricing.qualifyFor.LongTermDiscount 规则),它应该更新 RentalAgreement 对象以包含报价。然后,规则引擎评估已更新的 RentalAgreement 对象。 根据此评估,规则引擎运行用于计算此特殊报价的价格的规则,例如 pricing.price.LongTermDiscount 规则。 问题在于规则不更新 RentalAgreement 对象,并且规则引擎看不到报价,无法对其进行评估。因此,应用程序不运行用于计算价格的规则。

在本任务中,您将修改业务对象模型 (BOM),以便 addOffer 方法更新 RentalAgreement 对象。然后,移除所插入的断点。

步骤 1:修改 BOM

关于此任务

修改 BOM 以使 addOffer 方法更新 RentalAgreement 对象。

过程

  1. 要确保您在“规则”透视图中,请单击窗口 > 打开透视图 > 其他 > 规则。
  2. 使用 Intellirule 编辑器打开 pricing.qualifyFor.LongTermDiscount 规则。
  3. 在规则操作中,在将光标移至单词 qualifies for 上方时按住 Ctrl 键。当该短语变为带下划线时,单击该短语。

    成员 addOffer(String) 的 BOM 编辑器将打开。

  4. 选中常规信息下的更新对象状态框,然后单击文件 > 保存以保存工作。

    现在,当规则运行时,addOffer 方法将更新 RentalAgreement 对象以显示其符合特殊报价条件。

  5. 在“调试配置”对话框中,选择规则项目 > Debug-start-Julian 启动配置,然后单击调试。
  6. 单击继续 "" 按钮或按 F8 键以运行应用程序,直至停止在 qualifyFor.LongTermDiscount 规则中。
  7. 检查议程视图并注意列出了 pricing.qualifyFor.SpringSeason 规则。

    应用程序在 qualifyFor.LongTermDiscount 规则中的短语 'the current rental agreement' qualifies for the "long term" offer 处停止。

  8. 通过在工具栏上或运行菜单中单击两次步进按钮 "" 来步进 updateContext。

    在议程视图中,您可以看到 pricing.price.LongTermDiscount 规则已运行。

  9. 继续步进,直至到达 pricing.price.LongTermDiscount 规则中的以下行:
    in 'the current session' , display the message : " set the price of the long 
    term offer for the" + 'the current rental agreement' description ;
  10. 检查议程。在 pricing.price.LongTermDiscount 中,应用程序已计算长期报价的价格。
  11. 单击恢复按钮 "" 直到控制台显示以下文本:
    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

    输出现在包含所有报价的价格,并且将长期价格显示为最佳报价。

步骤 2:移除断点

关于此任务

现在,应用程序能够正确更新 RentalAgreement 对象,您可以移除规则中的断点,以便其正常运行。

过程

  1. 在调试透视图中,打开断点视图。
  2. 单击除去所有断点按钮 ""。

下一步做什么

在下一个任务中,完成 BOM 到 XOM 映射。
< 上一课 | 下一课 >