デシジョンサービスのスタートガイド
ガイド
概要
前書き
ビジネスルールの開発者は、Red Hat Process Automation Manager の Business Central を使用して、さまざまなデシジョンサービスを設計できます。Red Hat Process Automation Manager は、参考用として、Business Central 内に直接、ビジネスアセットサンプルを含むサンプルプロジェクトを提供しています。本書は、Business Central に含まれる Traffic_Violation サンプルプロジェクトをもとに、交通違反例を作成してテストする方法を説明します。このサンプルプロジェクトは、Decision Model and Notation (DMN) モデルを使用して、交通違反のデシジョンサービスで運転手の罰則と免許停止のルールを定義します。本書の手順に従い、プロジェクトとプロジェクトに含まれるアセットを作成するか、既存の Traffic_Violation サンプルプロジェクトを開き、レビューします。
Red Hat Process Automation Manager における DMN コンポーネントと実装についての情報は、『DMN モデルを使用したデシジョンサービスの作成』 を参照してください。
前提条件
- Red Hat JBoss Enterprise Application Platform 7.3 がインストールされている。詳細は、Red Hat JBoss EAP 7.3 インストールガイド を参照してください。
- Red Hat Process Automation Manager がインストールされ、KIE Server で設定されている。詳細は 『Red Hat JBoss EAP 7.3 への Red Hat Process Automation Manager のインストールおよび設定 』を参照してください。
-
Red Hat Process Automation Manager が稼働し、
developer
ロールで Business Central にログインできる。詳細は、『 Red Hat Process Automation Manager インストールの計画』を 参照してください。
第1章 Business Central のプロジェクトおよびビジネスアセットの例
Business Central には、プロジェクトサンプルがビジネスアセット例と合わせて同梱されており、ルール、プロセス、その他のアセットを、独自の Red Hat Process Automation Manager プロジェクトに作成するときの参考として使用できます。各プロジェクトは、Red Hat Process Automation Manager のプロセス自動化、意思決定管理、またはビジネス最適化アセットおよび論理を異なる方法で説明するように設計されています。
Red Hat は、Red Hat Process Automation Manager ディストリビューションに含まれるコードサンプルのサポートはしていません。
以下のプロジェクト例が、Business Central で利用できます。
- Evaluation_Process: (プロセス自動化) ビジネスプロセスアセットを使用したプロセス評価。実績に基づいて従業員を評価します。
- Mortgage_Process (住宅ローン): (プロセス自動化) ビジネスプロセスとデシジョンアセットを使用した住宅ローン審査プロセス。申し込み者のデータと資格を基にローンの申し込み資格を判定します。
- IT_Orders: (プロセス自動化およびケース管理) ビジネスプロセスとケース管理アセットを使用したケース注文。ニーズと承認に基づいて IT ハードウェアを注文します。
- Traffic_Violation: (DMN でのデシジョン管理) Decision Model and Notation (DMN) モデルを使用した交通違反のデシジョンサービス。交通違反をもとに運転手の罰則および免許停止を判断します。
- Mortgages (住宅ローン): (ルールでのデシジョン管理) ルールベースのデシジョンアセットを使用した住宅ローン審査プロセス。申し込み者のデータと資格を基にローンの申し込み資格を判定します。
- Employee_Rostering (従業員勤務表) : (ビジネス最適化) デシジョンおよびソルバーアセットを使用した従業員勤務表の最適化。スキルに基づいて従業員をシフトに割り当てます。
- OptaCloud: (ビジネス最適化) デシジョンおよびソルバーアセットを使用したリソース割り当ての最適化。リソースが制限されるなかでプロセスをコンピューターに割り当てます。
- Course_Scheduling: (ビジネス最適化) コースのスケジュールとカリキュラム決定プロセス。講師を教室に割り当て、コースの競合や教室の収容能力といった要素を基にして学生のカリキュラムを決定します。
- Dinner_Party: (ビジネス最適化) ガイド付きデシジョンテーブルを使用したゲストの座席割り当ての最適化。各ゲストの職種、政治的信条、既知の関係を基にしてゲストに座席を割り当てます。
1.1. Business Central のプロジェクトおよびビジネスアセット例へのアクセス
Business Central のプロジェクト例を使用すると、独自の Red Hat Process Automation Manager プロジェクトにルールや他のアセットを作成するときに、参考としてビジネスアセットを確認できます。
前提条件
- Business Central をインストールし、実行している。インストールオプションは『 Red Hat Process Automation Manager インストールの計画』を 参照してください。
手順
- Business Central で、Menu → Design → Projects に移動します。既存のプロジェクトがある場合には、MySpace のデフォルトのスペースをクリックして、Add Project プルダウンメニューから Try Samples を選択して、サンプルにアクセスできます。既存のプロジェクトがない場合には、Try samples をクリックします。
- 各サンプルプロジェクトの説明を読んで、どのプロジェクトが最適か確認します。各プロジェクトは、Red Hat Process Automation Manager のプロセス自動化、意思決定管理、またはビジネス最適化アセットおよび論理を異なる方法で説明するように設計されています。
- サンプルプロジェクトを選択し、Ok をクリックして自分のスペースにプロジェクトを追加します。
- 自分のスペースの Projects ページで、サンプルプロジェクトの 1 つを選択して、そのプロジェクトのアセットを表示します。
各アセットを選択して、指定のゴールまたはワークフローに到達するためにプロジェクトがどのように設計されているのかを確認します。サンプルのプロジェクトには、アセットが複数ページ含まれているものもあります。右上隅の左向きまたは右向き矢印をクリックして、全アセット一覧を表示します。
図1.1 アセットページの選択
プロジェクトの Assets ページの右上隅にある Build をクリックしてサンプルプロジェクトをビルドするか、Deploy をクリックしてプロジェクトをビルドしてから、KIE Server にデプロイします。
注記Build & Install オプションを選択してプロジェクトをビルドし、KJAR ファイルを KIE Server にデプロイせずに設定済みの Maven リポジトリーに公開することもできます。開発環境では、Deploy をクリックすると、ビルドされた KJAR ファイルを KIE Server に、実行中のインスタンス (がある場合はそれ) を停止せずにデプロイできます。または Redeploy をクリックして、ビルドされた KJAR ファイルをデプロイしてすべてのインスタンスを置き換えることもできます。次回、ビルドされた KJAR ファイルをデプロイまたは再デプロイすると、以前のデプロイメントユニット (KIE コンテナー) が同じターゲット KIE Server で自動的に更新されます。実稼働環境では Redeploy オプションは無効になっており、Deploy をクリックして、ビルドされた KJAR ファイルを KIE Server 上の新規デプロイメントユニット (KIE コンテナー) にデプロイすることのみが可能です。
KIE Server の環境モードを設定するには、
org.kie.server.mode
システムプロパティーをorg.kie.server.mode=development
またはorg.kie.server.mode=production
に設定します。Business Central でそれぞれのプロジェクトのデプロイメント動作を設定するには、プロジェクトの Settings → General Settings → Version に移動し、Development Mode オプションを選択して、Save をクリックします。デフォルトでは、KIE Server および Business Central のすべての新規プロジェクトは開発モードになっています。Development Mode をオンにしたプロジェクトをデプロイしたり、実稼働モードになっている KIE Server に手動でSNAPSHOT
バージョンの接尾辞を追加したプロジェクトをデプロイしたりすることはできません。プロジェクトのデプロイメントに関する詳細を確認するには、画面の上部にあるデプロイメントバナーの View deployment details か、Deploy のドロップダウンメニューをクリックします。このオプションを使用すると、Menu → Deploy → Execution Servers ページに移動します。
第2章 交通違反プロジェクトの作成
この例では、traffic-violation
という名前の新規プロジェクトを作成します。プロジェクトは、データオブジェクト、DMN アセット、およびテストシナリオなどのアセットのコンテナーです。作成中のプロジェクト例は、Business Central に含まれる既存の Traffic_Violation サンプルプロジェクトに似ています。
手順
Business Central で、Menu → Design → Projects に移動します。
Red Hat Process Automation Manager は以下のイメージのように MySpace と呼ばれるデフォルトスペースを提供します。このデフォルトスペースを使用してサンプルプロジェクトを作成およびテストできます。
図2.1 デフォルトのスペース
- Add Project をクリックします。
-
Name フィールドに
traffic-violation
と入力します。 Add をクリックします。
図2.2 Add Project ウインドウ
プロジェクトの Assets ビューを開きます。
第3章 DMN (Decision Model and Notation)
DMN (Decision Model and Notation) は、業務的意思決定を説明してモデル化するために、OMG (Object Management Group) が確立している規格です。DMN は XML スキーマを定義して、DMN モデルを DMN 準拠のプラットフォーム間や組織間で共有し、ビジネスアナリストやビジネスルール開発者が DMN デシジョンサービスの設計と実装で協力できるようにするものです。DMN 規格は、ビジネスプロセスを開発してモデル化する BPMN (Business Process Model and Notation) 規格と類似しており、一緒に使用できます。
DMN の背景およびアプリケーションの詳細は、OMG の Decision Model and Notation specification を参照してください。
3.1. 交通違反 DMN デシジョン要件ダイアグラム (DRD) の作成
デシジョン要件ダイアグラム (DRD) は、DMN モデルを視覚的にしたものです。Business Central の DMN デザイナーを使用して交通違反プロジェクトの DRD を設計し、DRD コンポーネントのデシジョン論理を定義します。
図3.1 交通違反の例の DRD
前提条件
- Business Central に交通違反プロジェクトを作成している。
手順
- traffic-violation プロジェクトのホーム画面で Add Asset をクリックします。
Add Asset ページで DMN をクリックします。Create new DMN ウィンドウが開きます。
-
Create new DMN ウィンドウの DMN 名フィールドで
Traffic Violation
を入力します。 -
Package リストから
com.myspace.traffic_violation
を選択します。 - OK をクリックします。DMN デザイナーで DMN アセットが開きます。
-
Create new DMN ウィンドウの DMN 名フィールドで
DMN デザイナーキャンバスで、DMN Input Data の入力ノード 2 つをキャンバスにドラッグします。
図3.2 DMN 入力データノード
- 右上隅の Properties アイコンをクリックします。
-
各入力ノードをダブルクリックして、Name フィールドで、1 つを
Driver
に、もう 1 つをViolation
に変更します。 - DMN Decision デシジョンノードをキャンバスにドラッグします。
-
デシジョンノードをダブルクリックして、
Fine
に名前を変更します。 Violation 入力ノードをクリックして Create DMN Information Requirement アイコンを選択し、2 つのノードを接続する
Fine
デシジョンノードをクリックします。図3.3 DMN 情報要件アイコンの作成
- DMN Decision デシジョンノードをキャンバスにドラッグします。
-
デシジョンノードをダブルクリックして、
Should the driver be suspended?
に名前を変更します。 - Driver 入力ノードをクリックして Create DMN Information Requirement アイコンを選択し、2 つのノードを接続する Should the driver be suspended? デシジョンノードをクリックします。
- Fine デシジョンノードをクリックして Create DMN Information Requirement アイコンを選択し、Should the driver be suspended? デシジョンノードを選択します。
Save をクリックします。
注記DRD を定期的に保存すると、DMN デザイナーは DMN モデルを静的に検証し、モデルが完全に定義されるまでエラーメッセージが出力される可能性があります。DMN モデルをすべて定義し終えてもエラーが発生する場合には、特定の問題を随時トラブルシューティングしてください。
3.2. 交通違反 DMN カスタムデータタイプの作成
DMN データタイプは、デシジョン論理の定義向けの DMN ボックス式のテーブル、列、フィールドで使用するデータ構造を決定します。デフォルトの DMN データタイプ (文字列、数字、ブール値など) を使用するか、または独自のデータタイプを作成して、ボックス式の値に実装する新たなフィールドや制限を指定することもできます。Business Central の DMN デザイナーの Data Types タブを使用して交通違反プロジェクトのカスタムデータタイプを定義します。
図3.4 カスタムデータタイプのタブ
以下のテーブルでは、このプロジェクト用に作成する tDriver
、tViolation
、および tFine
のカスタムデータタイプを一覧表示しています。
表3.1 tDriver
カスタムデータタイプ
名前 | タイプ |
---|---|
tDriver | Structure |
名前 | string |
Age | number |
State | string |
City | string |
Points | number |
表3.2 tViolation
カスタムデータタイプ
名前 | タイプ |
---|---|
tViolation | Structure |
Code | string |
Date | date |
タイプ | string |
Speed Limit | number |
Actual Speed | number |
表3.3 tFine
カスタムデータタイプ
名前 | タイプ |
---|---|
tFine | Structure |
Amount | number |
Points | number |
前提条件
- 交通違反 DMN デシジョン要件ダイアグラム (DRD) を Business Central で作成している。
手順
-
tDriver
カスタムデータタイプを作成するには、Data Types タブの Add a custom Data Type をクリックし、Name フィールドにtDriver
と入力して、Type リストからStructure
を選択します。 新しいデータタイプの右側にあるチェックマークをクリックして、変更を保存します。
図3.5 tDriver のカスタムデータタイプ
新しくネスト化されたデータタイプごとに、
tDriver
の横にあるプラス記号をクリックして、tDriver
の構造化データタイプに、以下のネスト化されたデータタイプを追加します。新規データタイプの右側にあるチェックマークをクリックして、変更を保存します。-
Name
(文字列) -
Age
(数字) -
State
(文字列) -
City
(文字列) -
Points
(数字)
-
-
tViolation
カスタムデータタイプを作成するには、New Data Types をクリックし、Name フィールドにtViolation
と入力して、Type リストからStructure
を選択します。 新しいデータタイプの右側にあるチェックマークをクリックして、変更を保存します。
図3.6 tViolation のカスタムデータタイプ
新しくネスト化されたデータタイプごとに、
tVoilation
の横にあるプラス記号をクリックして、tVoilation
の構造化データタイプに、以下のネスト化されたデータタイプを追加します。新規データタイプの右側にあるチェックマークをクリックして、変更を保存します。-
Code
(文字列) -
Date
(日付) -
Type
(文字列) -
Speed Limit
(数字) -
Actual Speed
(数字)
-
以下の制約を
Type
のネスト化されたデータタイプに追加するには、編集アイコンをクリックして Add Constraints をクリックし、Select constraint type プルダウンメニューから Enumeration を選択します。-
speed
-
parking
-
driving under the influence
-
- OK をクリックしてから、type データタイプの右側にあるチェックマークをクリックし、変更を保存します。
tFine
カスタムデータタイプを作成するには、New Data Types をクリックし、Name フィールドにtFine
と入力して、Type リストからStructure
を選択し、Save をクリックします。図3.7 tFine のカスタムデータタイプ
新しくネスト化されたデータタイプごとに、
tFine
の横にあるプラス記号をクリックして、tFine
の構造化データタイプに、以下のネスト化されたデータタイプを追加します。新規データタイプの右側にあるチェックマークをクリックして、変更を保存します。-
Amount
(数字) -
Points
(数字)
-
- Save をクリックします。
3.3. DRD 入力およびデシジョンノードへのカスタムデータタイプの割り当て
DMN カスタムデータタイプを作成したら、それらを交通違反 DRD 内で適切な DMN Input Data と DMN Decision のノードに割り当てます。
前提条件
- Business Central で交通違反 DMN カスタムデータタイプを作成している。
手順
- DMN デザイナーで Model タブをクリックし、右上の Properties アイコンをクリックして DRD プロパティーを開きます。
-
DRD で Driver 入力データノードを選択し、Properties パネルで Data type プルダウンメニューから
tDriver
を選択します。 -
Violation 入力データノードを選択し、Data type プルダウンメニューから
tViolation
を選択します。 -
Fine 入力データノードを選択し、Data type プルダウンメニューから
tFine
を選択します。 Should the driver be suspended? デシジョンノードを選択し、以下のプロパティーを設定します。
-
Data type:
string
-
Question:
Should the driver be suspended due to points on his driver license?
-
Allowed Answers:
Yes,No
-
Data type:
- Save をクリックします。
これでカスタムデータタイプが DRD の入力およびデシジョンノードに割り当てられました。
3.4. 交通違反 DMN デシジョン論理の定義
罰金を計算し、ドライバーが免許停止になるかどうかを判定するために、DMN デシジョンテーブルとコンテキストボックス式を使用した交通違反 DMN デシジョン論理を定義します。
図3.8 罰金のデシジョンテーブル
図3.9 ドライバーを免許停止にする必要がありますか ?
前提条件
- Business Central の交通違反 DRD で、DMN カスタムデータタイプが適切なデシジョンおよび入力ノードに割り当てられている。
手順
罰金を計算するには、DMN デザイナーキャンバスで Fine デシジョンノードを選択し、Edit をクリックして DMN ボックス式デザイナーを開きます。
図3.10 デシジョンノードの編集アイコン
Select expression → Decision Table をクリックします。
図3.11 デシジョンテーブルロジックタイプの選択
- パラメーターフィールド Violation.Date、Violation.Code、および Violation.Speed Limit で右クリックして、各フィールドで Delete を選択します。
-
Violation.Actual Speed 列ヘッダーをクリックし、Expression フィールドに
Violation.Actual Speed - Violation.Speed Limit
式を入力します。 -
Fine パラメーターフィールドを右クリックして、
Insert left
またはInsert right
を選択します。 -
output-2 列サブヘッダーをクリックし、Name フィールドに
Amount
を入力し、Data Type プルダウンメニューからnumber
を選択します。 -
同様に output-1 列サブヘッダーをクリックして Name フィールドに
Points
と入力し、Data Type フィールドからnumber
を選択します。 次に、デシジョンテーブルの一行目に以下の値を入力します。
-
Violation.Type:
"speed"
-
Violation.Actual Speed - Violation.Speed Limit:
[10..30)
-
Amount:
500
Points:
3
1 行目を右クリックし、
Insert below
を選択して新たな行を追加します。
-
Violation.Type:
デシジョンテーブルの 2 行目に以下の値を入力します。
-
Violation.Type:
"speed"
-
Violation.Actual Speed - Violation.Speed Limit:
>= 30
-
Amount:
1000
Points:
7
2 行目を右クリックし、
Insert below
を選択して新たな行を追加します。
-
Violation.Type:
デシジョンテーブルの 3 行目に以下の値を入力します。
-
Violation.Type:
"parking"
-
Violation.Actual Speed - Violation.Speed Limit:
-
-
Amount:
100
Points:
1
3 行目を右クリックし、
Insert below
を選択して新たな行を追加します。
-
Violation.Type:
デシジョンテーブルの 4 行目に以下の値を入力します。
-
Violation.Type:
"driving under the influence"
-
Violation.Actual Speed - Violation.Speed Limit:
-
-
Amount:
1000
-
Points:
5
-
Violation.Type:
- Save をクリックします。
- ドライバーの免許停止ルールを定義するには DMN デザイナーキャンバスに戻って Should the driver be suspended? デシジョンノードを選択し、Edit をクリックして DMN ボックス式デザイナーを開きます。
- Select expression → Context をクリックします。
-
ContextEntry-1 をクリックして Name に
Total Points
と入力し、Data Type プルダウンメニューからnumber
を選択します。 -
Total Points の横のセルをクリックしてコンテキストメニューから
Literal Expression
を選択し、Driver.Points + Fine.Points
式を入力します。 -
Driver.Points + Fine.Points の下のセルのコンテキストメニューから
Literal Expression
を選択し、if Total Points >= 20 then "Yes" else "No"
と入力します。 Save をクリックします。
これで罰金の計算方法とドライバーをいつ免許停止にするかを決定するコンテキストが定義されました。traffic-violation プロジェクトページに移動して Build をクリックすると、用例のプロジェクトがビルドされ、Alerts パネルのエラー (ある場合) が対処されます。
第4章 テストシナリオ
Red Hat Process Automation Manager のテストシナリオでは、ビジネスルールを実稼働環境にデプロイする前に、(ルールベースのテストシナリオの場合) ビジネスルールの機能とデータの妥当性、および (DMN ベースのテストシナリオの場合) DMN モデルを検証できます。このテストシナリオでは、プロジェクトのデータを使用して、指定した条件と、定義した 1 つ以上のビジネスルールで想定される結果を設定できます。シナリオを実行する際は、想定した結果と、ルールのインスタンスから実際に得られた結果を比較します。想定される結果が実際の結果と一致すると、テストは成功します。想定された結果が実際の結果と一致しないと、テストは失敗します。
Red Hat Process Automation Manager は現在、新規の テストシナリオ デザイナーと以前の テストシナリオ (レガシー) デザイナーの両方を含みます。デフォルトのデザイナー、新規のテストシナリオデザイナーで、ルールと DMN モデルのテストをサポートし、テストシナリオの全体的な使用感が改善されています。必要に応じて、レガシーのテストシナリオをそのまま使用することができますが、ルールベースのテストシナリオしかサポートされません。
レガシーのテストシナリオデザイナーは、Red Hat Process Automation Manager バージョン 7.3.0 で非推奨になりました。このツールは、今後の Red Hat Process Automation Manager リリースで削除予定です。代わりに、新しいテストシナリオデザイナーを使用してください。
プロジェクトレベルや、特定のシナリオアセット内で利用可能なテストシナリオを実行するなど、複数の方法で定義済みのテストシナリオを実行できます。テストシナリオは独立しており、他のテストシナリオに影響を与えたり、テストシナリオを変更したりできません。テストシナリオは、Business Central のプロジェクト開発時にいつでも実行できます。テストシナリオを実行するために、デシジョンサービスをコンパイルまたはデプロイする必要はありません。
別のパッケージからのデータオブジェクトは、テストシナリオと同じプロジェクトパッケージにインポートできます。同じパッケージに含まれるアセットはデフォルトでインポートされます。必要なデータオブジェクトとテストシナリオを作成したら、テストシナリオデザイナーの Data Objects タブを使用して、必要なデータオブジェクトがすべてリストされていることを検証するか、アイテムを追加 して既存のデータオブジェクトをインポートします。
テストシナリオのドキュメント全体で、テストシナリオ および テストシナリオデザイナー に関する言及はすべて、レガシーバージョンと明示的に記載がない限り、新規バージョンを対象としています。
4.1. テストシナリオを使用した交通違反のテスト
Business Central のテストシナリオデザイナーを使用して DMN 意思決定要件図 (DRD) をテストし、交通違反プロジェクトのデシジョン論理を定義します。
図4.1 交通違反の例のテストシナリオ
前提条件
- Business Central で交通違反プロジェクトを作成している。
手順
- traffic-violation プロジェクトのホーム画面で Add Asset をクリックして Add Asset 画面を開きます。
Test Scenario をクリックして Create new Test Scenario ダイアログを開きます。
-
Test Scenario フィールドに
Violation Scenarios
と入力します。 -
Package リストから
com.myspace.traffic_violation
を選択します。 -
Source type で
DMN
を選択します。 - Choose DMN asset リストから DMN アセットへのパスを選択します。
- Ok をクリックして、Test Scenarios デザイナーで Violation Scenarios テストシナリオを開きます。
-
Test Scenario フィールドに
- Driver 列サブヘッダー下で、State、City、Age、および Name の値のセルを右クリックし、コンテキストメニューから Delete column を選択してそれらを削除します。
- Violation 列サブヘッダー下で Date と Code の値のセルを右クリックし、Delete column を選択してそれらを削除します。
以下の情報をテストシナリオの 1 行目に入力します。
-
Scenario description:
Above speed limit: 10km/h and 30 km/h
-
Points (Given 列ヘッダー下):
10
-
Type:
"speed"
-
Speed Limit:
100
-
Actual Speed:
120
-
Points:
3
-
Amount:
500
Should the driver be suspended?:
"No"
1 行目を右クリックし、Insert row below を選択して新たな行を追加します。
-
Scenario description:
以下の情報をテストシナリオの 2 行目に入力します。
-
Scenario description:
Above speed limit: more than 30 km/h
-
Points (Given 列ヘッダー下):
10
-
Type:
"speed"
-
Speed Limit:
100
-
Actual Speed:
150
-
Points:
7
-
Amount:
1000
Should the driver be suspended?:
"No"
2 行目を右クリックし、Insert row below を選択して新たな行を追加します。
-
Scenario description:
以下の情報をテストシナリオの 3 行目に入力します。
-
Scenario description:
Parking violation
-
Points (Given 列ヘッダー下):
10
-
Type:
"parking"
- Speed Limit: 空白のまま
- Actual Speed: 空白のまま
-
Points:
1
-
Amount:
100
Should the driver be suspended?:
"No"
3 行目を右クリックし、Insert row below を選択して新たな行を追加します。
-
Scenario description:
以下の情報をテストシナリオの 4 行目に入力します。
-
Scenario description:
DUI violation
-
Points (Given 列ヘッダー下):
10
-
Type:
"driving under the influence"
- Speed Limit: 空白のまま
- Actual Speed: 空白のまま
-
Points:
5
-
Amount:
1000
Should the driver be suspended?:
"No"
4 行目を右クリックし、Insert row below を選択して新たな行を追加します。
-
Scenario description:
以下の情報をテストシナリオの 5 行目に入力します。
-
Scenario description:
Driver suspended
-
Points (Given 列ヘッダー下):
15
-
Type:
"speed"
-
Speed Limit:
100
-
Actual Speed:
140
-
Points:
7
-
Amount:
1000
-
Should the driver be suspended?:
"Yes"
-
Scenario description:
- Save をクリックします。
再生 ボタン をクリックして、テストシナリオが合格するかどうかを確認します。
図4.2 交通違反の例のテストシナリオ実行結果
失敗した場合は、エラーを修正してサイドテストシナリオを実行します。
第5章 DMN モデルの実行
Business Central を使用して Red Hat Process Automation Manager のプロジェクトに DMN ファイルをインポートまたは作成するか、Business Central を使用しないプロジェクトのナレッジ JAR (KJAR) ファイルの一部として DMN ファイルをパッケージ化できます。Red Hat Decision Manager プロジェクトに DMN ファイルに実装した後、リモートアクセスの KIE Server にそれを含む KIE コンテナーをデプロイして、KIE Server REST API を使用するコンテナーと対話することで、DMN デシジョンサービスを実行できます。
プロジェクトのパッケージングおよびデプロイメントの方法に外部 DMN アセットを含める方法については、『Red Hat Process Automation Manager プロジェクトのパッケージ化およびデプロイ 』を参照してください
5.1. KIE Server REST API を使った DMN サービスの実行
KIE Server の REST エンドポイントで直接対話することで、呼び出しコードと、意思決定ロジックの定義の分離が最大になります。呼び出しコードに直接の依存関係がないため、Node.js
、.NET
など、完全に異なる開発プラットフォームに実装できます。このセクションの例では、Nix スタイルの curl コマンドを示しますが、REST クライアントに適用するための関連情報を提供します。
KIE Server の REST エンドポイントを使用する場合、標準の KIE Server マーシャリングアノテーションが付けられたドメインオブジェクト POJO Java クラスを定義することが推奨されます。たとえば、以下のコードは、適切にアノテーションが付けられたドメインオブジェクトの Person
クラスを使用しています。
POJO Java クラスの例
@javax.xml.bind.annotation.XmlAccessorType(javax.xml.bind.annotation.XmlAccessType.FIELD) public class Person implements java.io.Serializable { static final long serialVersionUID = 1L; private java.lang.String id; private java.lang.String name; @javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter(org.kie.internal.jaxb.LocalDateXmlAdapter.class) private java.time.LocalDate dojoining; public Person() { } public java.lang.String getId() { return this.id; } public void setId(java.lang.String id) { this.id = id; } public java.lang.String getName() { return this.name; } public void setName(java.lang.String name) { this.name = name; } public java.time.LocalDate getDojoining() { return this.dojoining; } public void setDojoining(java.time.LocalDate dojoining) { this.dojoining = dojoining; } public Person(java.lang.String id, java.lang.String name, java.time.LocalDate dojoining) { this.id = id; this.name = name; this.dojoining = dojoining; } }
KIE Server REST API についての詳細は、『KIE API を使用した Red Hat Process Automation Manager の操作』を参照してください。
前提条件
-
KIE Server がインストールされ、設定されている (
kie-server
ロールが割り当てられているユーザーの既知のユーザー名と認証情報を含む)。インストールオプションは『 Red Hat Process Automation Manager インストールの計画』を 参照してください。 KJAR アーティファクトとして DMN プロジェクトをビルドして、KIE Server にデプロイしておく。理想的には、より効率的な実行ができるように、実行可能なモデルとして DMN プロジェクトをビルドしておいてください。
mvn clean install -DgenerateDMNModel=yes
プロジェクトのパッケージ化およびデプロイメント、実行可能モデルに関する詳細は、『 Red Hat Process Automation Manager プロジェクトのパッケージ化およびデプロイ 』を参照してください。
- KIE コンテナーの ID に DMN モデルを含んでいる。1 つ以上のモデルが存在する場合は、そのモデルの名前空間およびモデル名が必要です。
手順
KIE Server REST API エンドポイントにアクセスするためのベース URL を決定します。これには、以下の値が必要です (例ではローカルデプロイメントのデフォルト値を使用しています)。
-
ホスト (
localhost
) -
ポート (
8080
) -
ルートコンテキスト (
kie-server
) -
ベース REST パス (
services/rest/
)
交通違反プロジェクトでのローカルデプロイメントにおけるベース URL の例:
http://localhost:8080/kie-server/services/rest/server/containers/traffic-violation_1.0.0-SNAPSHOT
-
ホスト (
ユーザー認証要件を決定します。
ユーザーを KIE Server 設定に直接定義すると、ユーザー名およびパスワードを要求する HTTP Basic 認証が使用されます。要求を成功させるには、ユーザーに
kie-server
ルールが必要です。以下の例は、curl 要求に認証情報を追加する方法を示します。
curl -u username:password <request>
Red Hat Single Sign-On を使用して KIE Server を設定している場合は、要求にベアラートークンが必要です。
curl -H "Authorization: bearer $TOKEN" <request>
要求と応答の形式を指定します。REST API エンドポイントには JSON と XML の両方の書式が利用でき、要求ヘッダーを使用して設定されます。
JSON
curl -H "accept: application/json" -H "content-type: application/json"
XML
curl -H "accept: application/xml" -H "content-type: application/xml"
(任意) デプロイしたデシジョンモデルのリストに対するコンテナーのクエリーです。
[GET]
server/containers/{containerId}/dmn
curl 要求例:
curl -u wbadmin:wbadmin -H "accept: application/xml" -X GET "http://localhost:8080/kie-server/services/rest/server/containers/traffic-violation_1.0.0-SNAPSHOT/dmn"
サンプルの XML 出力:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <response type="SUCCESS" msg="Ok models successfully retrieved from container 'traffic-violation_1.0.0-SNAPSHOT'"> <dmn-model-info-list> <model> <model-namespace>https://github.com/kiegroup/drools/kie-dmn/_60b01f4d-e407-43f7-848e-258723b5fac8</model-namespace> <model-name>Traffic Violation</model-name> <model-id>_2CD7D1AA-BD84-4B43-AD21-B0342ADE655A</model-id> <decisions> <dmn-decision-info> <decision-id>_23428EE8-DC8B-4067-8E67-9D7C53EC975F</decision-id> <decision-name>Fine</decision-name> </dmn-decision-info> <dmn-decision-info> <decision-id>_B5EEE2B1-915C-44DC-BE43-C244DC066FD8</decision-id> <decision-name>Should the driver be suspended?</decision-name> </dmn-decision-info> </decisions> <inputs> <dmn-inputdata-info> <inputdata-id>_CEB959CD-3638-4A87-93BA-03CD0FB63AE3</inputdata-id> <inputdata-name>Violation</inputdata-name> <inputdata-typeref> <namespace-uri>https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri> <local-part>tViolation</local-part> <prefix></prefix> </inputdata-typeref> </dmn-inputdata-info> <dmn-inputdata-info> <inputdata-id>_B0E810E6-7596-430A-B5CF-67CE16863B6C</inputdata-id> <inputdata-name>Driver</inputdata-name> <inputdata-typeref> <namespace-uri>https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri> <local-part>tDriver</local-part> <prefix></prefix> </inputdata-typeref> </dmn-inputdata-info> </inputs> <itemdefinitions> <dmn-itemdefinition-info> <itemdefinition-id>_9C758F4A-7D72-4D0F-B63F-2F5B8405980E</itemdefinition-id> <itemdefinition-name>tViolation</itemdefinition-name> <itemdefinition-itemcomponent> <dmn-itemdefinition-info> <itemdefinition-id>_0B6FF1E2-ACE9-4FB3-876B-5BB30B88009B</itemdefinition-id> <itemdefinition-name>Code</itemdefinition-name> <itemdefinition-typeref> <namespace-uri>https://github.com/kiegroup/drools/kie-dmn/_60b01f4d-e407-43f7-848e-258723b5fac8</namespace-uri> <local-part>string</local-part> <prefix></prefix> </itemdefinition-typeref> <itemdefinition-itemcomponent/> <itemdefinition-iscollection>false</itemdefinition-iscollection> </dmn-itemdefinition-info> <dmn-itemdefinition-info> <itemdefinition-id>_27A5DA18-3CA7-4C06-81B7-CF7F2F050E29</itemdefinition-id> <itemdefinition-name>date</itemdefinition-name> <itemdefinition-typeref> <namespace-uri>https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri> <local-part>date</local-part> <prefix></prefix> </itemdefinition-typeref> <itemdefinition-itemcomponent/> <itemdefinition-iscollection>false</itemdefinition-iscollection> </dmn-itemdefinition-info> <dmn-itemdefinition-info> <itemdefinition-id>_8961969A-8A80-4F12-B568-346920C0F038</itemdefinition-id> <itemdefinition-name>type</itemdefinition-name> <itemdefinition-typeref> <namespace-uri>https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri> <local-part>string</local-part> <prefix></prefix> </itemdefinition-typeref> <itemdefinition-itemcomponent/> <itemdefinition-iscollection>false</itemdefinition-iscollection> </dmn-itemdefinition-info> <dmn-itemdefinition-info> <itemdefinition-id>_7450F12A-3E95-4D5E-8DCE-2CB1FAC2BDD4</itemdefinition-id> <itemdefinition-name>speed limit</itemdefinition-name> <itemdefinition-typeref> <namespace-uri>https://github.com/kiegroup/drools/kie-dmn/_60b01f4d-e407-43f7-848e-258723b5fac8</namespace-uri> <local-part>number</local-part> <prefix></prefix> </itemdefinition-typeref> <itemdefinition-itemcomponent/> <itemdefinition-iscollection>false</itemdefinition-iscollection> </dmn-itemdefinition-info> <dmn-itemdefinition-info> <itemdefinition-id>_0A9A6F26-6C14-414D-A9BF-765E5850429A</itemdefinition-id> <itemdefinition-name>Actual Speed</itemdefinition-name> <itemdefinition-typeref> <namespace-uri>https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri> <local-part>number</local-part> <prefix></prefix> </itemdefinition-typeref> <itemdefinition-itemcomponent/> <itemdefinition-iscollection>false</itemdefinition-iscollection> </dmn-itemdefinition-info> </itemdefinition-itemcomponent> <itemdefinition-iscollection>false</itemdefinition-iscollection> </dmn-itemdefinition-info> <dmn-itemdefinition-info> <itemdefinition-id>_13C7EFD8-B85C-43BF-94D3-14FABE39A4A0</itemdefinition-id> <itemdefinition-name>tDriver</itemdefinition-name> <itemdefinition-itemcomponent> <dmn-itemdefinition-info> <itemdefinition-id>_EC11744C-4160-4549-9610-2C757F40DFE8</itemdefinition-id> <itemdefinition-name>Name</itemdefinition-name> <itemdefinition-typeref> <namespace-uri>https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri> <local-part>string</local-part> <prefix></prefix> </itemdefinition-typeref> <itemdefinition-itemcomponent/> <itemdefinition-iscollection>false</itemdefinition-iscollection> </dmn-itemdefinition-info> <dmn-itemdefinition-info> <itemdefinition-id>_E95BE3DB-4A51-4658-A166-02493EAAC9D2</itemdefinition-id> <itemdefinition-name>Age</itemdefinition-name> <itemdefinition-typeref> <namespace-uri>https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri> <local-part>number</local-part> <prefix></prefix> </itemdefinition-typeref> <itemdefinition-itemcomponent/> <itemdefinition-iscollection>false</itemdefinition-iscollection> </dmn-itemdefinition-info> <dmn-itemdefinition-info> <itemdefinition-id>_7B3023E2-BC44-4BF3-BF7E-773C240FB9AD</itemdefinition-id> <itemdefinition-name>State</itemdefinition-name> <itemdefinition-typeref> <namespace-uri>https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri> <local-part>string</local-part> <prefix></prefix> </itemdefinition-typeref> <itemdefinition-itemcomponent/> <itemdefinition-iscollection>false</itemdefinition-iscollection> </dmn-itemdefinition-info> <dmn-itemdefinition-info> <itemdefinition-id>_3D4B49DD-700C-4925-99A7-3B2B873F7800</itemdefinition-id> <itemdefinition-name>city</itemdefinition-name> <itemdefinition-typeref> <namespace-uri>https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri> <local-part>string</local-part> <prefix></prefix> </itemdefinition-typeref> <itemdefinition-itemcomponent/> <itemdefinition-iscollection>false</itemdefinition-iscollection> </dmn-itemdefinition-info> <dmn-itemdefinition-info> <itemdefinition-id>_B37C49E8-B0D9-4B20-9DC6-D655BB1CA7B1</itemdefinition-id> <itemdefinition-name>Points</itemdefinition-name> <itemdefinition-typeref> <namespace-uri>https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri> <local-part>number</local-part> <prefix></prefix> </itemdefinition-typeref> <itemdefinition-itemcomponent/> <itemdefinition-iscollection>false</itemdefinition-iscollection> </dmn-itemdefinition-info> </itemdefinition-itemcomponent> <itemdefinition-iscollection>false</itemdefinition-iscollection> </dmn-itemdefinition-info> <dmn-itemdefinition-info> <itemdefinition-id>_A4077C7E-B57A-4DEE-9C65-7769636316F3</itemdefinition-id> <itemdefinition-name>tFine</itemdefinition-name> <itemdefinition-itemcomponent> <dmn-itemdefinition-info> <itemdefinition-id>_79B152A8-DE83-4001-B88B-52DFF0D73B2D</itemdefinition-id> <itemdefinition-name>Amount</itemdefinition-name> <itemdefinition-typeref> <namespace-uri>https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri> <local-part>number</local-part> <prefix></prefix> </itemdefinition-typeref> <itemdefinition-itemcomponent/> <itemdefinition-iscollection>false</itemdefinition-iscollection> </dmn-itemdefinition-info> <dmn-itemdefinition-info> <itemdefinition-id>_D7CB5F9C-9D55-48C2-83EE-D47045EC90D0</itemdefinition-id> <itemdefinition-name>Points</itemdefinition-name> <itemdefinition-typeref> <namespace-uri>https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri> <local-part>number</local-part> <prefix></prefix> </itemdefinition-typeref> <itemdefinition-itemcomponent/> <itemdefinition-iscollection>false</itemdefinition-iscollection> </dmn-itemdefinition-info> </itemdefinition-itemcomponent> <itemdefinition-iscollection>false</itemdefinition-iscollection> </dmn-itemdefinition-info> </itemdefinitions> <decisionservices/> </model> </dmn-model-info-list> </response>
サンプルの JSON 出力:
{ "type" : "SUCCESS", "msg" : "OK models successfully retrieved from container 'Traffic-Violation_1.0.0-SNAPSHOT'", "result" : { "dmn-model-info-list" : { "models" : [ { "model-namespace" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "model-name" : "Traffic Violation", "model-id" : "_2CD7D1AA-BD84-4B43-AD21-B0342ADE655A", "decisions" : [ { "decision-id" : "_23428EE8-DC8B-4067-8E67-9D7C53EC975F", "decision-name" : "Fine" }, { "decision-id" : "_B5EEE2B1-915C-44DC-BE43-C244DC066FD8", "decision-name" : "Should the driver be suspended?" } ], "inputs" : [ { "inputdata-id" : "_CEB959CD-3638-4A87-93BA-03CD0FB63AE3", "inputdata-name" : "Violation", "inputdata-typeRef" : { "namespace-uri" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "local-part" : "tViolation", "prefix" : "" } }, { "inputdata-id" : "_B0E810E6-7596-430A-B5CF-67CE16863B6C", "inputdata-name" : "Driver", "inputdata-typeRef" : { "namespace-uri" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "local-part" : "tDriver", "prefix" : "" } } ], "itemDefinitions" : [ { "itemdefinition-id" : "_13C7EFD8-B85C-43BF-94D3-14FABE39A4A0", "itemdefinition-name" : "tDriver", "itemdefinition-typeRef" : null, "itemdefinition-itemComponent" : [ { "itemdefinition-id" : "_EC11744C-4160-4549-9610-2C757F40DFE8", "itemdefinition-name" : "Name", "itemdefinition-typeRef" : { "namespace-uri" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "local-part" : "string", "prefix" : "" }, "itemdefinition-itemComponent" : [ ], "itemdefinition-isCollection" : false }, { "itemdefinition-id" : "_E95BE3DB-4A51-4658-A166-02493EAAC9D2", "itemdefinition-name" : "Age", "itemdefinition-typeRef" : { "namespace-uri" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "local-part" : "number", "prefix" : "" }, "itemdefinition-itemComponent" : [ ], "itemdefinition-isCollection" : false }, { "itemdefinition-id" : "_7B3023E2-BC44-4BF3-BF7E-773C240FB9AD", "itemdefinition-name" : "State", "itemdefinition-typeRef" : { "namespace-uri" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "local-part" : "string", "prefix" : "" }, "itemdefinition-itemComponent" : [ ], "itemdefinition-isCollection" : false }, { "itemdefinition-id" : "_3D4B49DD-700C-4925-99A7-3B2B873F7800", "itemdefinition-name" : "City", "itemdefinition-typeRef" : { "namespace-uri" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "local-part" : "string", "prefix" : "" }, "itemdefinition-itemComponent" : [ ], "itemdefinition-isCollection" : false }, { "itemdefinition-id" : "_B37C49E8-B0D9-4B20-9DC6-D655BB1CA7B1", "itemdefinition-name" : "Points", "itemdefinition-typeRef" : { "namespace-uri" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "local-part" : "number", "prefix" : "" }, "itemdefinition-itemComponent" : [ ], "itemdefinition-isCollection" : false } ], "itemdefinition-isCollection" : false }, { "itemdefinition-id" : "_A4077C7E-B57A-4DEE-9C65-7769636316F3", "itemdefinition-name" : "tFine", "itemdefinition-typeRef" : null, "itemdefinition-itemComponent" : [ { "itemdefinition-id" : "_79B152A8-DE83-4001-B88B-52DFF0D73B2D", "itemdefinition-name" : "Amount", "itemdefinition-typeRef" : { "namespace-uri" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "local-part" : "number", "prefix" : "" }, "itemdefinition-itemComponent" : [ ], "itemdefinition-isCollection" : false }, { "itemdefinition-id" : "_D7CB5F9C-9D55-48C2-83EE-D47045EC90D0", "itemdefinition-name" : "Points", "itemdefinition-typeRef" : { "namespace-uri" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "local-part" : "number", "prefix" : "" }, "itemdefinition-itemComponent" : [ ], "itemdefinition-isCollection" : false } ], "itemdefinition-isCollection" : false }, { "itemdefinition-id" : "_9C758F4A-7D72-4D0F-B63F-2F5B8405980E", "itemdefinition-name" : "tViolation", "itemdefinition-typeRef" : null, "itemdefinition-itemComponent" : [ { "itemdefinition-id" : "_0B6FF1E2-ACE9-4FB3-876B-5BB30B88009B", "itemdefinition-name" : "Code", "itemdefinition-typeRef" : { "namespace-uri" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "local-part" : "string", "prefix" : "" }, "itemdefinition-itemComponent" : [ ], "itemdefinition-isCollection" : false }, { "itemdefinition-id" : "_27A5DA18-3CA7-4C06-81B7-CF7F2F050E29", "itemdefinition-name" : "Date", "itemdefinition-typeRef" : { "namespace-uri" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "local-part" : "date", "prefix" : "" }, "itemdefinition-itemComponent" : [ ], "itemdefinition-isCollection" : false }, { "itemdefinition-id" : "_8961969A-8A80-4F12-B568-346920C0F038", "itemdefinition-name" : "Type", "itemdefinition-typeRef" : { "namespace-uri" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "local-part" : "string", "prefix" : "" }, "itemdefinition-itemComponent" : [ ], "itemdefinition-isCollection" : false }, { "itemdefinition-id" : "_7450F12A-3E95-4D5E-8DCE-2CB1FAC2BDD4", "itemdefinition-name" : "Speed Limit", "itemdefinition-typeRef" : { "namespace-uri" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "local-part" : "number", "prefix" : "" }, "itemdefinition-itemComponent" : [ ], "itemdefinition-isCollection" : false }, { "itemdefinition-id" : "_0A9A6F26-6C14-414D-A9BF-765E5850429A", "itemdefinition-name" : "Actual Speed", "itemdefinition-typeRef" : { "namespace-uri" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "local-part" : "number", "prefix" : "" }, "itemdefinition-itemComponent" : [ ], "itemdefinition-isCollection" : false } ], "itemdefinition-isCollection" : false } ], "decisionServices" : [ ] } ] } } }
モデルを実行します。
[POST]
server/containers/{containerId}/dmn
注記model-namespace
の属性は自動生成され、各ユーザーで異なります。model-namespace
とmodel-name
の属性がデプロイされているモデルのものに合致することを確認してください。curl 要求例:
curl -u wbadmin:wbadmin -H "accept: application/json" -H "content-type: application/json" -X POST "http://localhost:8080/kie-server/services/rest/server/containers/traffic-violation_1.0.0-SNAPSHOT/dmn" -d "{ \"model-namespace\" : \"https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8\", \"model-name\" : \"Traffic Violation\", \"dmn-context\" : {\"Driver\" : {\"Points\" : 15}, \"Violation\" : {\"Type\" : \"speed\", \"Actual Speed\" : 135, \"Speed Limit\" : 100}}}"
JSON 要求例:
{ "model-namespace" : "https://github.com/kiegroup/drools/kie-dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8", "model-name" : "Traffic Violation", "dmn-context" : { "Driver" : { "Points" : 15 }, "Violation" : { "Type" : "speed", "Actual Speed" : 135, "Speed Limit" : 100 } } }
XML 要求例 (JAXB 形式):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <dmn-evaluation-context> <dmn-context xsi:type="jaxbListWrapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <type>MAP</type> <element xsi:type="jaxbStringObjectPair" key="Violation"> <value xsi:type="jaxbListWrapper"> <type>MAP</type> <element xsi:type="jaxbStringObjectPair" key="Type"> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema">speed</value> </element> <element xsi:type="jaxbStringObjectPair" key="Speed Limit"> <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">100</value> </element> <element xsi:type="jaxbStringObjectPair" key="Actual Speed"> <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">135</value> </element> </value> </element> <element xsi:type="jaxbStringObjectPair" key="Driver"> <value xsi:type="jaxbListWrapper"> <type>MAP</type> <element xsi:type="jaxbStringObjectPair" key="Points"> <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">15</value> </element> </value> </element> </dmn-context> </dmn-evaluation-context>
注記要求には、その形式にかかわらず、以下の要素が必要です。
- モデルの名前空間
- モデル名
- 入力値を含むコンテキストオブジェクト
JSON 応答例:
{ "type": "SUCCESS", "msg": "OK from container 'Traffic-Violation_1.0.0-SNAPSHOT'", "result": { "dmn-evaluation-result": { "messages": [], "model-namespace": "https://github.com/kiegroup/drools/kie-dmn/_7D8116DE-ADF5-4560-A116-FE1A2EAFFF48", "model-name": "Traffic Violation", "decision-name": [], "dmn-context": { "Violation": { "Type": "speed", "Speed Limit": 100, "Actual Speed": 135 }, "Should Driver be Suspended?": "YES", "Driver": { "Points": 15 }, "Fine": { "Points": 7, "Amount": 1000 } }, "decision-results": { "_E1AF5AC2-E259-455C-96E4-596E30D3BC86": { "messages": [], "decision-id": "_E1AF5AC2-E259-455C-96E4-596E30D3BC86", "decision-name": "Should the Driver be Suspended?", "result": "YES", "status": "SUCCEEDED" }, "_D7F02CE0-AF50-4505-AB80-C7D6DE257920": { "messages": [], "decision-id": "_D7F02CE0-AF50-4505-AB80-C7D6DE257920", "decision-name": "Fine", "result": { "Points": 7, "Amount": 1000 }, "status": "SUCCEEDED" } } } } }
XML (JAXB 形式) 応答例:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <response type="SUCCESS" msg="OK from container 'Traffic_1.0.0-SNAPSHOT'"> <dmn-evaluation-result> <model-namespace>https://github.com/kiegroup/drools/kie-dmn/_A4BCA8B8-CF08-433F-93B2-A2598F19ECFF</model-namespace> <model-name>Traffic Violation</model-name> <dmn-context xsi:type="jaxbListWrapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <type>MAP</type> <element xsi:type="jaxbStringObjectPair" key="Violation"> <value xsi:type="jaxbListWrapper"> <type>MAP</type> <element xsi:type="jaxbStringObjectPair" key="Type"> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema">speed</value> </element> <element xsi:type="jaxbStringObjectPair" key="Speed Limit"> <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">100</value> </element> <element xsi:type="jaxbStringObjectPair" key="Actual Speed"> <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">135</value> </element> </value> </element> <element xsi:type="jaxbStringObjectPair" key="Driver"> <value xsi:type="jaxbListWrapper"> <type>MAP</type> <element xsi:type="jaxbStringObjectPair" key="Points"> <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">15</value> </element> </value> </element> <element xsi:type="jaxbStringObjectPair" key="Fine"> <value xsi:type="jaxbListWrapper"> <type>MAP</type> <element xsi:type="jaxbStringObjectPair" key="Points"> <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">7</value> </element> <element xsi:type="jaxbStringObjectPair" key="Amount"> <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">1000</value> </element> </value> </element> <element xsi:type="jaxbStringObjectPair" key="Should the driver be suspended?"> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema">Yes</value> </element> </dmn-context> <messages/> <decisionResults> <entry> <key>_4055D956-1C47-479C-B3F4-BAEB61F1C929</key> <value> <decision-id>_4055D956-1C47-479C-B3F4-BAEB61F1C929</decision-id> <decision-name>Fine</decision-name> <result xsi:type="jaxbListWrapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <type>MAP</type> <element xsi:type="jaxbStringObjectPair" key="Points"> <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">7</value> </element> <element xsi:type="jaxbStringObjectPair" key="Amount"> <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">1000</value> </element> </result> <messages/> <status>SUCCEEDED</status> </value> </entry> <entry> <key>_8A408366-D8E9-4626-ABF3-5F69AA01F880</key> <value> <decision-id>_8A408366-D8E9-4626-ABF3-5F69AA01F880</decision-id> <decision-name>Should the driver be suspended?</decision-name> <result xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">Yes</result> <messages/> <status>SUCCEEDED</status> </value> </entry> </decisionResults> </dmn-evaluation-result> </response>
第6章 関連資料
付録A バージョン情報
本書の最終更新日: 2022 年 3 月 8 日(火)