第3章 ガイド付きルール
ガイド付きルールとは、ルール作成のプロセスを説明する UI ベースのガイド付きルールデザイナーで作成できるビジネスルールです。ルールデザイナーは、編集されるルールのオブジェクトモデルを基にした許可される入力のフィールドおよびオプションを提供します。ルールに関連するすべてのデータオブジェクトは、ルールと同じプロジェクトパッケージに存在する必要があります。同じパッケージのアセットはデフォルトでインポートされます。ルールデザイナーの Data Objects タブを使用すると、必要なデータオブジェクトがすべてリストされていることを検証したり、他に必要なオブジェクトをインポートしたりできます。
図3.1 ガイド付きルールデザイナー
3.1. Driver License Suspension ルールの作成 リンクのコピーリンクがクリップボードにコピーされました!
ガイド付きルールウィザードを使用して、ドライバーの運転免許停止ルールを作成します。
前提条件
Violation と Driver の両方のデータオブジェクトを作成していること。
手順
- Decision Central にログインします。
-
Menu
Design Projects の順にクリックし、Driver_department_traffic_violations をクリックします。 Add Asset
Guided Rule の順にクリックし、以下を入力します。 -
Guided Rule:
DriverLicenseSuspensionRule -
Package:
com.myspace.driver_department_traffic_violations
-
Guided Rule:
Ok をクリックして ガイド付きルールデザイナー を開きます。
図3.2 Create new Guided Rule ウインドウ
3.2. Suspension ルール条件の設定 リンクのコピーリンクがクリップボードにコピーされました!
運転者の違反を判断する Suspension ルールの条件を設定します。
前提条件
Driver License Suspension (運転免許停止) ルールを作成していること。
手順
-
WHEN ラベルの横にある (
) をクリックして、Add a condition to the rule ウィンドウを開きます。
Driver を選択し、OK をクリックします。
図3.3 Create new Guided Rule ウインドウ
- There is a Driver ラベルをクリックして Modify constraints for Driver ウィンドウを開きます。
-
Variable name フィールドに
driverと入力し、Set をクリックします。 - There is a Driver[driver] をクリックし、Expression editor をクリックします。
- [not bound] をクリックし、Expression editor を開きます。
-
Bind the Expression to a new variable フィールドに
previousPtsと入力し、Set をクリックします。 - Choose メニューで totalPoints を選択します。
-
1 行目 (previousPts ラベル) の横にある (
) をクリックし、Add a condition to the rule を開きます。
- From Accumulate を選択し、Ok をクリックします。
- From Accumulate ラベルの上にある click to add pattern をクリックし、choose fact type メニューで Number を選択します。
- There is a number ラベルをクリックして Modify contraints for Driver ウインドウを開きます。
- Expression editor をクリックし、[not bound]: Choose メニューで intValue() を選択します。
- [not bound] をクリックし、Expression editor を開きます。
-
Bind the Expression to a new variable フィールドに
totalNewPointsと入力し、Set をクリックします。 - click to add pattern をクリックし、choose fact type メニューで Violation を選択します。
- All Violation with: をクリックして Modify contraints for Violation ウインドウを開き、Add a restriction on a field メニューで points を選択します。
- points ラベルの横にある please choose をクリックし、greater than を選択します。
-
(
) をクリックした後、 Literal value をクリックします。
- points ラベルをクリックして Add a field ウインドウを開きます。
-
vPointsと入力し、Set をクリックします。 -
Function フィールドに
sum(vPoints)と入力します。 -
totalNewPoints
please choose メニューで greater than or equal to を選択します。 -
(
) をクリックして New formula をクリックし、新しいフィールドに 20-previousPtsと入力します。 - Save をクリックした後、Save をクリックして変更を確認します。
図3.4 Suspension ルールの条件
3.3. Suspension ルールアクションの設定 リンクのコピーリンクがクリップボードにコピーされました!
Suspension ルールアクションを設定します。これは、ドライバーの罰則を判断するもので、Suspension ルール条件に基づく点数および罰金額が含まれます。
前提条件
Suspension ルール条件が作成されていること。
手順
(show options…) をクリックします。
図3.5 show options の選択
-
THEN ラベルの横にある (
) をクリックし、Change field values of driver を選択した後、Ok をクリックします。
- Set value of Driver [driver] フィールドをクリックし、Add field メニューで state を選択します。
-
Set value of Driver [driver] セクションの state の横にある (
) をクリックし、Field value ウインドウを開きます。
Literal value をクリックし、新しいフィールドに
suspendと入力します。図3.6 新しいフィールド
-
Set value of Driver [driver] セクションの下の (options) ラベルの横にある (
) をクリックします。
- Add an option to the rule ウインドウの Attribute メニューで ruleflow-group オプションを選択します。
-
ruleflow-group フィールドに
trafficViolationと入力します。 Save をクリックした後、Save をクリックして変更を確認します。
図3.7 Suspension ルールアクション