アクション・ルール

アクションと条件をマッチさせる、ルール内のビジネス・ポリシーを記述します。

アクション・ルールでは、特定の条件が満たされた場合に実行する具体的なアクションを定義します。 基本的なアクション・ルールは、if-then ステートメントを使用して、条件 (if) とアクション (then) を関連付けます。 ルールでは、条件が true である場合に実行するアクションを記述します。以下に例を示します。

if
	the credit score of ‘the borrower’ is less than 200
then
	in 'the loan report', reject the loan with the message "Credit score too low.";

アクション・ルールは、自然言語での文として書きます。ルールは、ビジネス用語、演算子、および値で構成されます。 この例では、the credit score of the borrower がビジネス用語、is less than が算術演算子、200 が値です。

ビジネス・アプリケーションは、ルールを呼び出してこれらを実行し、ビジネス用語に対するデータ値を提供します。 この例では、アクション・ルールは、ビジネス用語の the credit score of the borrower と the loan report のデータにアクセスする必要があります。

完全なステートメントを提供するために、アクション・ルールは、4 つの部分 (definitions、if、then、および else) から構成することができます。

次の例は、ルール内の 4 つの部分を示しています。

definitions 
	set applicant to a customer 
		where the category of this customer is Gold 
if 
	the value of the applicant's shopping cart is more than $100 
then 
	apply a 15% discount 
else 
	apply a 5% discount
定義 (definitions)
definitions 部分で、ルールの変数を定義します。

definitions 部分はオプションです。

条件 (if)
if 部分を使用して、then と else の各部分のアクションが実行される場合の条件を指定します。この例の条件は the value of the applicant's shopping cart is more than $100 です。

if 部分はオプションです。条件を伴わないルールは、すべての状況下でそのアクションを実行します。

アクション (then)
then 部分を使用して、 if 部分が true の場合に実行する 1 つ以上のアクションを定義します。この例のアクションは、if 部分が true の場合に、 apply a 15% discount を行うことを述べています。

then 部分は必須です。 ルールには、少なくとも 1 つのアクションが必要です。

代替アクション (else)
else 部分を使用して、if 部分が false の場合に実行する 1 つ以上のアクションを定義します。この例の else 部分は、if 部分が false の場合に apply a 5% discount を行うことを述べています。

else 部分はオプションです。ルールの if 部分が false の場合で、かつ、 else 部分が無い場合には、ルールは何もアクションを実行しません。