< 上一课 | 下一课 >

任务 5:优化词汇表

使用自变量改进短语和方法的主题的表述。

关于此任务

如有必要,您可以编辑缺省表述中的术语或短语以使其更易于理解。您使用编辑术语对话框来编辑 BOM 编辑器的类语言表述。 您使用文本和“内容辅助”在模板字段中编辑成员语言表述或者导航和操作短语。要编辑短语中使用的主体,请使用编辑术语对话框。

在规则 UnderAge 中,必须使以下短语更明确:
the customer age of the rental agreement
the session .displayMessage ( "...")

短语 the customer age of the rental agreement 可能令人混淆,因为它似乎将 age 与 rental agreement 相关联。要减少歧义,可以编辑术语 customer age,它是短语的主题。

过程

  1. 编辑短语 the customer age of the rental agreement 的主题:
    1. 在 Rule Explorer 视图中,双击 BOM 条目 model。
    2. 在“概要”视图中,展开 RentalAgreement,然后单击方法 getCustomerAge。
    3. 在“成员表述”部分中,单击编辑短语中使用的主题。

      “编辑术语”对话框将打开。

    4. 在 Singular 字段中,将文本更改为 age of the customer,然后单击确定。

      警告消息将通知您这些更改可能会影响规则。

    5. 在文件菜单上,单击保存。

      “重构词汇表”对话框打开。

    6. 确保选择规则 UnderAge,然后单击是。
    7. 打开规则 UnderAge。

      您已使用新语言表述来更新此规则的条件部分:

      if
      the age of the customer of the rental agreement is less than 18

    缺省情况下,会对具有诸如 Session.displayMessage 之类的自变量的方法进行表述,但是必须修改表述以明确含义。

  2. 编辑方法 Session.displayMessage 的表述:
    1. 在 Intellirule 编辑器中打开规则 UnderAge。
    2. 按 Ctrl,然后单击 the session .displayMessage ( "The rental agreement is rejected.");,这将显示为链接。

      BOM 编辑器的“成员”页面将打开。

    3. 在“成员表述”部分中,删除操作短语模板字段的内容。
    4. 输入以下操作短语:
      display the message {0} in {this}

      您可以使用“内容辅助”框(Ctrl+空格键)将占位符 {0} 和 {this} 插入到新操作短语中。您必须输入此短语的剩余部分。

      警告消息通知您这些更改可能会影响业务规则。

    5. 在文件菜单上,单击保存。

      “重构词汇表”对话框打开。

    6. 确保选择规则 UnderAge,然后单击是。
    7. 打开规则 UnderAge。您可以看到已使用新语言表述更新了此规则:
      if
         the age of the customer of the rental agreement is less than 18
      then
         make it true that the rental agreement is rejected; 
         display the message "The rental agreement is rejected" in the session;

      有关规则编辑器的更多信息,请参阅处理操作规则。

结果

在下一个任务中,您将通过创建在业务规则中显示为列表的枚举域来扩展 BOM。

< 上一课 | 下一课 >