自動例外処理の例

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

条件での自動例外処理では、例外になる可能性のあるブール式のすべての組み合わせに適用される以下の 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 ...

過去 4 人の借り手のコレクションに、where 節が false の借り手が 3 人と不明の借り手が 1 人含まれる場合、ルール・アクションは実行されます。

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 ...

過去 3 人の借り手のコレクションに、where 節が true の借り手が 1 人、false の借り手が 1 人、不明の借り手が 1 人含まれる場合、ルール・アクションは実行されます。

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 が含まれる場合、ルール・アクションはいっさい実行されません。

意思決定表

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

意思決定表の例のイメージ。

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

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

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

コレクションを使用する式

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

if  
	there are less than 3 borrowers 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
   reject 'the loan';
   add "more than 3 similar borrowers found" to the messages of 'the loan' ;

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

if  
	there are more than 3 borrowers where the name of each borrower is the name of 'the borrower',
then
   reject 'the loan';
   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' ;

contain を使用する式

次に示すサンプルの式は、コレクションをテストするための代替方法である contain を使用しています。 コレクション ('duplicateBorrowers') にオブジェクト 'the borrower' が含まれる場合、条件は true になります。

definitions
	set 'duplicateBorrowers' to all borrowers where the customer status of each borrower starts with "duplicate" ;
if
    'duplicateBorrowers' contain  'the borrower' 
then
add "duplicate detected" to the messages of 'the loan' ;
	reject 'the loan' ;