エンティティー拡張
ビジネス・モデルで定義されたエンティティーが、外部ソースから拡張された属性を持つことが可能です。
エンティティーの拡張で使用するデータ・プロバイダーをビジネス・モデルで定義する必要があります。また、属性の拡張を、ルールに似たステートメントを使用して、ビジネス・モデルで定義する必要があります。 拡張ステートメントには、データ・プロバイダーの名前および返す属性が含まれます。例えば、以下のステートメントでは、エンティティー・タイプが airport の属性 latitude および longitude を定義しています。これらの属性は、weather provider データ・プロバイダーを使用して拡張されます。
an airport is enriched by the weather provider,
given
the latitude from the latitude of this airport,
the longitude from the longitude of this airport,
setting
the temperature to the temperature of this weather provider,
the wind speed to the wind speed of this weather provider,
the precipitation to the precipitation of this weather provider.
ビジネス・モデルには、airport エンティティーの以下の定義が含まれている必要があります。
an airport is a business entity identified by an IATA code with
a latitude (a number),
a longitude (a number),
a precipitation level (a number),
a wind speed (a number),
a temperature (a number).
データ・プロバイダーを定義するには、名前、必要な属性、および返すデータを指定します。
a weather provider is a data provider,
accepts
a latitude (a number),
a longitude (a number),
returns
a temperature (a number),
a wind speed (a number),
a precipitation (a number).
エージェントが airport エンティティーの temperature、wind speed、または precipitation の値を要求すると、ランタイムは関連する weather provider を呼び出します。 デフォルトでは、返された属性の値は、トランザクション時にキャッシュに入れられます。データ・プロバイダーを繰り返し呼び出すコストを低減するために、値を単一のトランザクションよりも長い期間キャッシュに入れることができます。
データ・プロバイダーを実装する際には、「データ・プロバイダー拡張機能 (Data Provider Extension)」ウィザードを使用して、 専用の DataProvider API クラスを作成します。 DataProvider クラスによって、複合属性値を返すための getConceptFactory メソッドが提供されます。デフォルト実装では、ビジネス・モデル・ステートメントで定義されたプロバイダー名に実装をバインドする @DataProviderDescriptor 注釈を使用しています。
DataProvider 実装は、ソリューションの一部である拡張機能プロジェクトにデプロイされます。完全なソリューションは、ビジネス・モデル拡張ステートメントで指定されたプロバイダーごとに 1 つの実装を含む必要があります。また、各データ・プロバイダー名は、ソリューション内で固有でなければなりません。
次の図は、ビジネス・モデルでデータの拡張がどのように定義されるかを示しています。 拡張された属性値をエージェントが (例えば、ルールで属性を参照することによって) 必要とすると、ランタイムがデータ・プロバイダー実装を解決してロードします。 グリッドは、データをキャッシュに入れ、トランザクション間で共有します。
