数値のテストをする条件

オブジェクトがデータ・セット内に 1 つ以上存在するかどうかをチェックする条件を作成できます。

以下に示す定義は、指定されたデータの存在をテストする演算子を説明しています。

there are

演算子の there are は、ルールを呼び出すアプリケーションから提供されるデータに一定タイプのオブジェクトが特定の数だけ存在するかをテストします。

以下の条件は、2 本のフライトについてチェックします。

if 
   there are 2 flights in the flights of 'the customer'
then... 

演算子 where を使用して、ビジネス用語に適用する追加条件を指定することができます。

次のルール条件は、顧客の数が 10 人で、かつ各顧客がゴールド・カテゴリーのメンバーの場合のみ true になります。

if
   there are 10 customers where the category of each customer is Gold, 
then... 

また、時間フィルター演算子を使用して、オブジェクトのコレクションが、特定の期間または時刻に関連する時間に存在するかどうかをチェックすることもできます。演算子 where を使用した条件では、時間フィルター演算子が最初に指定されます。

以下の演算子を使用して、期間に従ってオブジェクトのコレクションをフィルターに掛けます。
  • before
  • after
  • during
以下の演算子を使用して、時刻に従ってオブジェクトのコレクションをフィルターに掛けます。
  • before
  • after
  • at
  • before or at
  • at or after

例えば、時間枠に during 演算子を使用して、この時間枠に従ってビジネス用語にフィルターを適用します。以下のルール条件は、顧客がゴールド・カテゴリーのメンバーである、過去 2 週間の 2 本のフライトについてチェックします。

if
   there are 2 flights in the flights of 'the customer' during the last period of 2 weeks 
     where the category of 'the customer' is Gold, 
then... 
there are at least と there are at most

次の演算子は、データに含まれるビジネス用語の出現箇所が指定された数より多いか、少ないかをチェックします。

  • there are at least: ビジネス用語の出現箇所の数が指定された数以上である場合、この条件は真です。

  • there are at most: ビジネス用語の出現箇所の数が指定された数以下である場合、この条件は真です。

次の条件は、ゴールド顧客の数が 3 人以下であることをチェックします。

if 
	there are at most 3 customers 
		where the category of each customer is Gold, 
then... 

次の条件は、シルバー顧客よりもゴールド顧客の方が多いかどうかをチェックします。 次の変数を定義することでルールを開始します。

  • silver customers: シルバー・カテゴリーの顧客のリスト。

  • silver count: シルバー・カテゴリーの顧客の数。

その後、ルールはこれらの変数を使用して、ゴールド顧客の数とシルバー顧客の数を比較します。

definitions 
	set 'silver customers' to all customers in the boarded passengers of 'the flight'
		where the category of each customer is Silver; 
	set 'silver count' to the number of 'silver customers'
if 
	there are at least ('silver count' + 1) customers 
		where the category of each customer is Gold, 
then... 
there is at least one

演算子 there is at least one は、ルールを呼び出すアプリケーションからのデータに、ビジネス用語のインスタンスが少なくとも 1 つあることをチェックします。データには、そのビジネス用語の複数のインスタンスが含まれていてもかまいません。

次の条件は、少なくとも 1 つの customer オブジェクトがあるかどうか探します。

if 
	there is at least one customer 
then... 

次の例では、高齢のゴールド顧客が少なくとも 1 人存在するかどうかをチェックします。

definitions
   set 'gold customers' to all customers in the boarded passengers of 'the flight'
      where the category of each customer is Gold; 
if 
   there is at least one customer in 'gold customers' 
      where the age of this customer is at least 65, 
then...