デシジョンサービスのスタートガイド
ガイド
概要
はじめに
ビジネスルールの開発者は、Red Hat Decision Manager の Business Central を使用して、さまざまなデシジョンサービスを設計できます。Red Hat Decision Manager は、Business Central に直接参考用として、ビジネスアセット例を含むプロジェクトサンプルを提供しています。本書は、Business Central に含まれる Traffic_Violation サンプルプロジェクトをもとに、交通違反例を作成してテストする方法を説明します。このサンプルプロジェクトは、Decision Model and Notation (DMN) モデルを使用して、交通違反のデシジョンサービスで運転手の罰則と免許停止のルールを定義します。本書の手順に従い、プロジェクトとプロジェクトに含まれるアセットを作成するか、既存の Traffic_Violation サンプルプロジェクトを開き、レビューします。
Red Hat Decision Manager における DMN コンポーネントと実装についての情報は、DMN モデルを使用したデシジョンサービスの作成 を参照してください。
前提条件
- Red Hat JBoss Enterprise Application Platform 7.2 がインストールされている。詳細は、Red Hat JBoss EAP 7.2 インストールガイド を参照してください。
- Red Hat Decision Manager がインストールされ、Decision Server で設定されていること。詳細は、Red Hat JBoss EAP 7.2 への Red Hat Decision Manager のインストールおよび設定 を参照してください。
-
Red Hat Decision Manager が稼働し、
developer
ロールで Business Central にログインできる。詳細は、Red Hat Decision Manager インストールの計画 を参照してください。
第1章 Business Central のプロジェクトおよびビジネスアセットの例
Business Central には、自分の Red Hat Decision Manager プロジェクトにルールや他のアセットを作成する際に参照可能な、ビジネスアセットのあるプロジェクト例が含まれています。各プロジェクトは、Red Hat Decision Manager の意思決定管理やビジネス最適化アセットおよび論理を異なる方法で説明するように設計されています。
Red Hat は、Red Hat Decision Manager ディストリビューションに含まれるコードサンプルのサポートはしていません。
以下のプロジェクト例が、Business Central で利用可能になっています。
- Traffic_Violation: (DMN でのデシジョン管理) Decision Model and Notation (DMN) モデルを使用した交通違反のデシジョンサービスの例。交通違反をもとに運転手の罰則および免許停止を判断します。
- Mortgages (住宅ローン): (ルールでのデシジョン管理) ルールベースのデシジョンアセットを使用した住宅ローン審査プロセスの例。申し込み者のデータと資格を基にローンの申し込み資格を判定します。
- Employee_Rostering (従業員勤務表) : (ビジネス最適化) デシジョンおよびソルバーアセットを使用した従業員勤務表の最適化の例。スキルに基づいて従業員をシフトに割り当てます。
- OptaCloud: (ビジネス最適化) デシジョンおよびソルバーアセットを使用したリソース割り当ての最適化の例。リソースが制限されるなかでプロセスをコンピューターに割り当てます。
- Course_Scheduling: (ビジネス最適化) コースのスケジュールとカリキュラム決定プロセスの例。講師を教室に割り当て、コースの競合や教室の収容能力といった要素を基にして学生のカリキュラムを決定します。
- Dinner_Party: (ビジネス最適化) ガイド付きデシジョンテーブルを使用したゲストの座席割り当ての最適化。各ゲストの職種、政治的信条、既知の関係を基にしてゲストに座席を割り当てます。
1.1. Business Central のプロジェクトおよびビジネスアセット例へのアクセス
Business Central のプロジェクト例を使用すると、自分の Red Hat Decision Manager プロジェクトにルールや他のアセットを作成する際に参照可能なビジネスアセットの例を調べることができます。
前提条件
- Business Central をインストールし、実行している。インストールオプションは Red Hat Decision Manager インストールの計画 を参照してください。
手順
Business Central にログインし、Menu → Design → Projects の順にクリックし、Mortgage Process をクリックします。
プロジェクトが既にある場合は、Projects ページの画面右上の縦に並んだ 3 つの点をクリックし、Try Samples をクリックします。
- 各サンプルプロジェクトの説明を読んで、どのプロジェクトが最適か確認します。各プロジェクトは、Red Hat Decision Manager の意思決定管理やビジネス最適化アセットおよび論理を異なる方法で説明するように設計されています。
- サンプルプロジェクトを選択し、Ok をクリックして自分のスペースにプロジェクトを追加します。
- 自分のスペースの Projects ページで、サンプルプロジェクトを選択してアセットを確認します。
- 各サンプルアセットを選択して、指定された目標またはワークフローを達成するためにプロジェクトがどのように設計されているかを調べます。
プロジェクトの Assets ページの右上にある Build をクリックしてサンプルプロジェクトをビルドするか、Deploy をクリックして、プロジェクトをビルドして Decision Server にデプロイします。
注記実稼働または開発環境では、Build & Install オプションを選択してプロジェクトをビルドし、KJAR ファイルを Decision Server にデプロイせずに設定済みの Maven リポジトリーに公開できます。開発環境では、Deploy をクリックして、実行中のインスタンスを停止せずにビルドされた KJAR ファイルを Decision Server にデプロイするか (該当する場合)、ビルドされた KJAR ファイルを Redeploy をクリックしてデプロイし、実行中のインスタンスを停止します。ビルドした KJAR ファイルを次回にデプロイまたは再デプロイすると、以前のデプロイメントユニット (KIE コンテナー) が同じターゲット Decision Server で自動的に更新されます。実稼働環境では Redeploy オプションは無効になっており、Deploy をクリックして KJAR ファイルを Decision Server 上の新規デプロイメントユニット (KIE コンテナー) にデプロイすることのみが可能です。
Decision Server 環境モードを設定するには、
org.kie.server.mode
システムプロパティーをorg.kie.server.mode=development
またはorg.kie.server.mode=production
に設定します。Business Central の対応するプロジェクトでのデプロイメント動作を設定するには、プロジェクトの Settings → General Settings → Version に移動し、Development Mode オプションを選択します。デフォルトでは、Decision Server と Business Central の新規プロジェクトはすべて、開発モードになっています。Development Mode がオンのプロジェクトや、実稼働モードの Decision Server に手動でSNAPSHOT
バージョンの接尾辞を追加したプロジェクトをデプロイすることはできません。(該当する場合は) プロジェクトのデプロイメント詳細を確認するには、Menu → Deploy → Execution servers に移動します。
第2章 交通違反プロジェクトの作成
この例では、traffic-violation
という名前の新規プロジェクトを作成します。プロジェクトは、データオブジェクト、DMN アセット、およびテストシナリオなどのアセットのコンテナーです。作成中のプロジェクト例は、Business Central に含まれる既存の Traffic_Violation サンプルプロジェクトに似ています。
手順
- Business Central にログインします。
Menu → Design → Projects を選択します。
Red Hat Decision Manager は以下のイメージのように MySpace と呼ばれるデフォルトスペースを提供します。このデフォルトスペースを使用してサンプルプロジェクトを作成およびテストできます。
図2.1 デフォルトのスペース
- Add Project をクリックします。
-
Name フィールドに
traffic-violation
と入力します。 Configure Advanced Options ボタンをクリックして GAV フィールドを展開し、以下の値を入力します。
-
Group ID:
org.kie.example.traffic
-
Artifact ID:
traffic-violation
-
Version:
1.0.0
-
Group ID:
Add をクリックします。
図2.2 Advanced Options を展開した 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 リストから
org.kie.example.traffic.traffic_violation
を選択します。 - OK をクリックします。DMN デザイナーで DMN アセットが開きます。
-
Create new DMN ウィンドウの DMN 名フィールドで
- DMN デザイナーキャンバスで、DMN Input Data の入力ノード 2 つをキャンバスにドラッグします。
-
各入力ノードをダブルクリックして、1 つを
Driver
に、もう 1 つをViolation
に名前を変更します。 - DMN Decision デシジョンノードをキャンバスにドラッグします。
-
デシジョンノードをダブルクリックして、
Fine
に名前を変更します。 -
Violation 入力ノードをクリックして
Create DMN Information Requirement
アイコンを選択し、2 つのノードを接続するFine
デシジョンノードをクリックします。 - 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 をクリックし、再度 Save をクリックして確定します。
3.2. 交通違反 DMN カスタムデータタイプの作成
DMN データタイプは、デシジョン論理の定義向けの DMN ボックス式のテーブル、列、フィールドで使用するデータ構造を決定します。デフォルトの DMN データタイプ (文字列、数字、ブール値など) を使用するか、または独自のデータタイプを作成して、ボックス式の値に実装する新たなフィールドや制限を指定することもできます。Business Central の DMN デザイナーの Data Types タブを使用して交通違反プロジェクトのカスタムデータタイプを定義します。
図3.2 カスタムデータタイプのタブ
別の方法では、右側にある Diagram properties タブから Data Types タブにアクセスすることもできます。Diagram properties タブから、Information item 下にある Data type の Manage をクリックします。
図3.3 Diagram properties タブ
以下のテーブルでは、このプロジェクト用に作成する Violation
、Driver
、および Fine
のカスタムデータタイプを一覧表示しています。
表3.1 Driver のカスタムデータタイプ
名前 | タイプ |
---|---|
tDriver | Structure |
名前 | string |
Age | number |
State | string |
City | string |
Points | number |
表3.2 Violation のカスタムデータタイプ
Name | タイプ |
---|---|
tViolation | Structure |
Code | string |
Date | date |
タイプ | string |
Speed Limit | number |
Actual Speed | number |
表3.3 Fine のカスタムデータタイプ
Name | タイプ |
---|---|
tFine | Structure |
Amount | number |
Points | number |
前提条件
- 交通違反 DMN デシジョン要件ダイアグラム (DRD) を Business Central で作成している。
手順
- Data Types タブから Add をクリックします。
最初に tDriver カスタムデータタイプを作成します。Name に
tDriver
と、Type にStructure
と入力します。Save をクリックして保存します。図3.4 tDriver のカスタムデータタイプ
次に tDriver の横にある 3 つの点をクリックして Insert nested field を選択し、以下のネスト化されたデータタイプを追加します。Save をクリックして保存します。
- Name (string)
- Age (number)
- State (string)
- City (string)
- Points (number)
次に tViolation データタイプを作成します。Data Types タブから Add をクリックします。
図3.5 tViolation のカスタムデータタイプ
-
Name に
tViolation
と、Type にStructure
と入力します。Save をクリックして保存します。 次に tViolation の横にある 3 つの点をクリックして Insert nested field を選択し、以下のネスト化されたデータタイプを追加します。Save をクリックして保存します。
- Code (string)
- Date (date)
- Type (string)
- Speed Limit (number)
- Actual Speed (number)
作成したネスト型の
Type
データタイプで、Edit → Constraints → Enumeration とクリックして以下の制限を追加します。チェックアイコン をクリックして、追加した各列挙制約を保存します。-
"speed"
-
"parking"
-
"Driving under the influence?"
-
最後に tFine データタイプを作成します。Data Types タブから Add をクリックします。
図3.6 tFine のカスタムデータタイプ
-
Name に
tFine
と、Type にStructure
と入力します。Save をクリックして保存します。 次に tFine の横にある 3 つの点をクリックして Insert nested field を選択し、以下のネスト化されたデータタイプを追加します。Save をクリックして保存します。
- Amount (number)
- Points (number)
- これらの 3 つのカスタムデータタイプが作成されたら、Save をクリックし、Confirm Save ダイアログボックスで Save を再度クリックします。
3.3. DRD 入力およびデシジョンノードへのカスタムデータタイプの割り当て
DMN カスタムデータタイプを作成したら、それらを交通違反 DRD 内で適切な DMN Input Data と DMN Decision のノードに割り当てます。
前提条件
- Business Central で交通違反 DMN カスタムデータタイプを作成している。
手順
- DMN デザイナーで Model タブをクリックし、右上の Diagram properties をクリックして DRD プロパティーを開きます。
-
DRD で Driver 入力データノードを選択し、Diagram 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 をクリックし、Confirm Save ダイアログボックスで Save を再度クリックします。
これでカスタムデータタイプが DRD の入力およびデシジョンノードに割り当てられました。
3.4. 交通違反 DMN デシジョン論理の定義
罰金を計算し、ドライバーが免許停止になるかどうかを判定するために、DMN デシジョンテーブルとコンテキストボックス式を使用した交通違反 DMN デシジョン論理を定義します。
図3.7 罰金のデシジョンテーブル
図3.8 Should the driver be suspended? コンテキストのボックス式
前提条件
- Business Central の交通違反 DRD で、DMN カスタムデータタイプが適切なデシジョンおよび入力ノードに割り当てられている。
手順
- 罰金を計算するには、DMN デザイナーキャンバスで Fine デシジョンノードを選択し、Edit をクリックして DMN ボックス式デザイナーを開きます。
- Select expression → Decision Table をクリックします。
- パラメーターフィールド Violation.Date、Violation.Code、および Violation.Speed Limit で右クリックして、各フィールドで Delete を選択します。
-
Violation.Actual Speed 列ヘッダーをクリックし、Name フィールドに
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 をクリックし、Confirm Save ダイアログボックスで 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 をクリックし、Confirm Save ダイアログボックスで Save を再度クリックします。
これで罰金の計算方法とドライバーをいつ免許停止にするかを決定するコンテキストが定義されました。traffic-violation プロジェクトページに移動して Build をクリックすると、用例のプロジェクトがビルドされ、Alerts パネルのエラー (ある場合) が対処されます。
第4章 テストシナリオ
Red Hat Decision Manager のテストシナリオでは、ビジネスルールを実稼働環境にデプロイする前に、ビジネスルールとビジネスルールデータの機能 (ルールベースのテストシナリオの場合)、および DMN モデルの機能 (DMN ベースのテストシナリオの場合) を検証できます。このテストシナリオでは、プロジェクトのデータを使用して、指定した条件と、定義した 1 つ以上のビジネスルールで想定される結果を設定できます。シナリオを実行する際は、想定した結果と、ルールのインスタンスから実際に得られた結果を比較します。想定される結果が実際の結果と一致すると、テストは成功します。想定された結果が実際の結果と一致しないと、テストは失敗します。
Red Hat Decision Manager は現在、新規の テストシナリオ デザイナーと以前の テストシナリオ (レガシー) デザイナーの両方を含みます。デフォルトのデザイナー、新規のテストシナリオデザイナーで、ルールと DMN モデルのテストをサポートし、テストシナリオの全体的な使用感が改善されています。必要に応じて、レガシーのテストシナリオをそのまま使用することができますが、ルールベースのテストシナリオしかサポートされません。
レガシーのテストシナリオデザイナーは、Red Hat Decision Manager バージョン 7.3.0 で非推奨になりました。今後の Red Hat Decision 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 リストから
org.kie.example.traffic.traffic_violations
を選択します。 -
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 (Expect コラムヘッダー下):
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 (Expect コラムヘッダー下):
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 (Expect コラムヘッダー下):
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 (Expect コラムヘッダー下):
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 (Expect コラムヘッダー下):
7
-
Amount:
1000
-
Should the driver be suspended?:
"Yes"
-
Scenario description:
- Save をクリックし、Confirm Save ダイアログボックスで Save を再度クリックします。
再生ボタンをクリックして、テストシナリオが合格するかどうかを確認します。
図4.2 交通違反の例のテストシナリオ実行結果
失敗した場合は、エラーを修正してサイドテストシナリオを実行します。
第5章 DMN モデルの実行
Business Central を使用して Red Hat Decision Manager のプロジェクトに DMN ファイルをインポートまたは作成するか、Business Central を使用しないプロジェクトのナレッジ JAR (KJAR) ファイルの一部として DMN ファイルをパッケージ化できます。Red Hat Decision Manager プロジェクトに DMN ファイルに実装した後、リモートアクセスの Decision Server にそれを含む KIE コンテナーをデプロイして、Decision Server REST API を使用するコンテナーと対話することで、DMN デシジョンサービスを実行できます。
プロジェクトのパッケージングおよびデプロイメントの方法に外部 DMN アセットを含める方法は、Red Hat Decision Manager プロジェクトのパッケージ化およびデプロイ を参照してください。
5.1. Decision Server REST API を使った DMN サービスの実行
Decision Server の REST エンドポイントで直接対話することで、呼び出しコードと、意思決定ロジックの定義の分離が最大になります。呼び出しコードに直接の依存関係がないため、node.js
、.net
など、完全に異なる開発プラットフォームに実装できます。このセクションの例では、Nix スタイルの curl コマンドを示しますが、REST クライアントに適用するための関連情報を提供します。
Decision Server REST API についての詳細は、KIE API を使用した Red Hat Decision Manager の操作 を参照してください。
前提条件
-
Decision Server がインストールされ、設定されている (
kie-server
ロールが割り当てられているユーザーの既知のユーザー名と認証情報を含む)。インストールオプションは Red Hat Decision Manager インストールの計画 を参照してください。 KIE コンテナーが、DMN モデルを含む KJAR の形式で、Decision Server でデプロイされている。実行可能モデルとしてコンパイルされていれば尚可。
mvn clean install -DgenerateDMNModel=yes
プロジェクトのパッケージ化およびデプロイメント、ならびに実行可能モデルに関する詳細は、Red Hat Decision Manager プロジェクトのパッケージ化およびデプロイ を参照してください。
- KIE コンテナーのコンテナー ID に DMN モデルを含んでいる。1 つ以上のモデルが存在する場合は、そのモデルの名前空間およびモデル名が必要です。
- DMN モデルをデプロイしている。プロジェクトのデプロイメントに関する詳細は、Red Hat Decision Manager プロジェクトのパッケージ化およびデプロイ を参照してください。
手順
Decision 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
-
ホスト (
ユーザー認証要件を決定します。
ユーザーを Decision Server 設定に直接定義すると、ユーザー名およびパスワードを要求する HTTP Basic 認証 が使用されます。要求を成功させるには、ユーザーに
kie-server
ルールが必要です。以下の例は、curl 要求に認証情報を追加する方法を示します。
curl -u username:password <request>
Red Hat シングルサインオンを使用して Decision 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/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'"> <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'", "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/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'", "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 バージョン情報
本書の最終更新日: 2021 年 11 月 15 日 (月)