自動例外処理の例

条件での自動例外処理を有効にすると、例外がスローされた後もルール処理を続行できるように、ルール・エンジンによって特定のサブクラスが処理されます。

条件での自動例外処理では、例外になる可能性のあるブール式のすべての組み合わせに適用される以下の 3 値論理を使用して、ブール式の不明な値が解決されます。

イメージには、AND 演算子、OR 演算子、および NOT 演算子の 3 値論理が含まれています。

シンプルなルール条件

以下の例では、借り手の状況が不明の場合、ルール・アクションは実行されません。

if
   the status of 'the borrower' starts with "duplicate"
then
   reject 'the loan' ;
   add "duplicate detected" to the messages of 'the loan' ;
else 
   add "no duplicate found" to the messages of 'the loan' ;

OR 演算子を使用するルール条件

以下の例では、借り手の状況が不明であり、ローンのコメントに duplicate という語が含まれている場合、ローンは拒否され、duplicate detected メッセージが送信されます。

if 
   the status of 'the borrower' starts with "Duplicate" or the comment of 'the loan' contains "duplicate"
then
   reject 'the loan' ;
   add "duplicate detected" to the messages of 'the loan' ;
else 
   add "no duplicate found" to the messages of 'the loan' ;

しかし、借り手の状況が不明で、コメントも不明の場合、ルール・アクションはいっさい実行されません。ローンは拒否されず、メッセージ no duplicate found がローンに追加されることもありません。

AND 演算子を使用するルール条件

以下の例では、借り手の状況が不明であり、ローンのコメントに duplicate という語が含まれている場合、then アクションと else アクションはいずれも実行されません。すなわち、ローンは拒否されず、メッセージ no duplicate found がローンのメッセージに追加されることもありません。

if 
   the status of 'the borrower' starts with "duplicate" and the comment of 'the loan' contains "duplicate"
then
   reject 'the loan' ;
   add "duplicate detected" to the messages of 'the loan' ;
else 
   add "no duplicate found" to the messages of 'the loan' ;

ローンが拒否されるには、両方の式が真にならなければなりません。

If there is no ... then ...

過去の借り手のコレクションに、where 節が不明の借り手が含まれる場合、ルール・アクションはいっさい実行されません。

If there is no borrower in the past borrowers of 'the loan' where the name of this borrower is the name of 'the borrower', 
then 
add "no duplicate found" to the message of 'the loan'

If there is at least one ... then ...

過去の借り手のコレクションに、where 節が真の借り手が含まれる場合、ルール・アクションが実行されます。過去の借り手のコレクションに、where 節が偽または不明の借り手が含まれる場合、ルール・アクションはいっさい実行されません。

If there is at least one borrower in the past borrowers of 'the loan' where the name of this borrower is the name of 'the borrower', 
then 
   reject 'the loan' ;
   add "duplicate detected" to the message of 'the loan'

NOT 演算子を使用するルール条件

以下の例では、状況が不明であり、コメントに duplicate が含まれていない場合、then アクションが実行され、no duplicate found が追加されます。

if it is not true that
   (the status of 'the borrower' starts with "duplicate" and the comment of 'the loan' contains "duplicate")
then
   add "no duplicate found" to the messages of 'the loan' ;
else 
   reject 'the loan' ;
   add "duplicate detected" to the messages of 'the loan' ;

状況が不明で、コメントに duplicate が含まれる場合、ルール・アクションはいっさい実行されません。

意思決定表

以下の例では、条件列内のその他の条件がすべて偽の場合に、条件列の「その他」行が選択されます。代わりに、その他の条件のいずれかが不明の場合、「その他」行は選択されません。

意思決定表サンプル・イメージ。

ルール変数

ルール変数 'statusIsNew' が不明の場合、ルール・エンジンは式の評価を停止します。条件は不明と見なされ、ルール・アクションは実行されません。

definitions
   set 'statusIsNew' to the status of 'the borrower' starts with “New";

if it is not true that 'statusIsNew' and  the comment of 'the loan' contains "similar"
then
   reject 'the loan' ;
   add "duplicate detected" to the messages of 'the loan' ;
else 
   add "no duplicate found" to the messages of 'the loan' ;

オブジェクトのコレクション

コレクション・オブジェクトが満たさなければならないテストに不明な値が存在する場合、このオブジェクトはコレクションに追加されません。

definitions
set 'duplicateBorrowers' to all borrowers where the status of each borrower starts with "duplicate" ; 

ビジネス言語に含まれるサポートされない式

以下の例で、where 節が 3 人の借り手に関しては真で、1 人の借り手に関しては不明の場合、where 節が不明の借り手はカウントされないため、ルール・エンジンは条件を真と見なします。then アクションが実行されます。

If there are at most 3 borrowers in the past borrowers of 'the loan' where the name of each borrower is  the name of 'the borrower', 
then
   add “3 or less similar borrowers found" to the messages of 'the loan' ;
else
   'ローン' を却下 ;
   add “more than 3 similar borrowers found" to the messages of 'the loan' ;

以下の例で、where 節が 1 人の借り手に関しては真で、2 人の借り手に関しては不明の場合、where 節が不明の 2 人の借り手はカウントされないため、ルール・エンジンはルール条件を偽と見なします。else アクションが実行されます。

if there are at least 3 borrowers in the past borrowers of 'the loan' where the name of each borrower is  the name of 'the borrower', 
then
   'ローン' を却下 ;
   add “3 or more similar borrowers found" to the messages of 'the loan' ;
else
   add “less than 3 similar borrowers found" to the messages of 'the loan' ;