第2章 データオブジェクト
データオブジェクトは、作成するルールアセットの構成要素です。データオブジェクトは、プロジェクトで指定したパッケージに Java オブジェクトして実装されているカスタムのデータ型です。たとえば、データフィールド Name、Address、および Date of Birth を使用して Person オブジェクトを作成し、ローン申し込みルールに詳細な個人情報を指定できます。このカスタムのデータ型は、アセットとディシジョンサービスがどのデータに基づいているかを指定します。
以下の表は、本チュートリアルで作成する Violation (違反) および Driver (運転者) データオブジェクトを示しています。
| ID | Label | Type |
|---|---|---|
|
code |
Code |
String |
|
points |
Points |
Integer |
|
violationDate |
Violation Date |
Date |
|
type |
Type |
String |
|
fineAmount |
Fine Amount |
Double |
|
speedLimit |
Speed Limit |
Integer |
|
actualSpeed |
Actual Speed |
Integer |
| ID | Label | Type |
|---|---|---|
|
name |
Name |
String |
|
age |
Age |
Integer |
|
state |
State |
String |
|
city |
City |
String |
|
violations |
Violations |
Violation (org.jboss.example.traffic_violations.Violation) 注記: violations フィールドは、指定されたタイプの複数のアイテムを保持するために "List" に設定されています。 |
|
fineAmount |
Fine Amount |
Double |
|
totalPoints |
Total Points |
Integer |
|
reason |
Reason |
String |
2.1. Violation データオブジェクトの作成 リンクのコピーリンクがクリップボードにコピーされました!
Violation データオブジェクトには、Violation Date (違反日)、Fine Amount (罰金額)、Speed Limit (制限速度) など、違反の詳細を基にしたデータフィールドが含まれます。
前提条件
Driver_department_traffic_violations プロジェクトを作成していること。
手順
-
Add Asset
Data Object の順にクリックします。 Create new Data Object ウィザードで以下の値を入力します。
-
Data Object:
Violation -
Package:
com.myspace.driver_department_traffic_violationsを選択します。
-
Data Object:
OK をクリックします。
図2.1 Create new Data Object ウインドウ
2.1.1. Violation データオブジェクト制限の追加 リンクのコピーリンクがクリップボードにコピーされました!
Violation データオブジェクトフィールドに、ルールを定義する際に選択する制限を設定します
前提条件
Violation データオブジェクトを作成していること。
手順
'Violation'-general propertiesセクションの Label フィールドに Violation と入力します。図2.2 プロパティー
- + add field をクリックします。
以下の値を入力します。
-
Id:
code -
Label:
Code -
Type:
String
-
Id:
Create and continue をクリックした後、以下の値を入力します。
-
Id:
points -
Label:
Points -
Type:
Integer
-
Id:
Create and continue をクリックした後、以下の値を入力します。
-
Id:
violationDate -
Label:
Violation Date -
Type:
Date
-
Id:
Create and continue をクリックした後、以下の値を入力します。
-
Id:
type -
Label:
Type -
Type:
String
-
Id:
Create and continue をクリックした後、以下の値を入力します。
-
Id:
fineAmount -
Label:
Fine Amount -
Type:
Double
-
Id:
Create and continue をクリックした後、以下の値を入力します。
-
Id:
speedLimit -
Label:
Speed Limit -
Type:
Integer
-
Id:
Create and continue をクリックした後、以下の値を入力します。
-
Id:
actualSpeed -
Label:
Actual Speed -
Type:
Integer
-
Id:
- Create をクリックします。
- Save をクリックした後、Save をクリックして変更を確認します。
Driver_department_traffic_violations ラベルをクリックして、プロジェクトの Assets ビューに戻ります。
図2.3 Violation データオブジェクトフィールド
2.2. Driver データオブジェクトの作成 リンクのコピーリンクがクリップボードにコピーされました!
Driver データオブジェクトには、Name、Age、Total Points などのドライバーの詳細に基づくデータフィールドが含まれます。
前提条件
Driver_department_traffic_violations プロジェクトを作成していること。
手順
-
Add Asset
Data Object の順にクリックします。 Create new Data Object ウィザードで以下の値を入力します。
-
Data Object:
Driver -
Package:
com.myspace.driver_department_traffic_violationsを選択します。
-
Data Object:
OK をクリックします。
図2.4 Create new Data Object ウインドウ
2.2.1. Driver データオブジェクト制限の追加 リンクのコピーリンクがクリップボードにコピーされました!
Driver データオブジェクトフィールドに、ルールを定義する際に選択する制限を設定します
前提条件
Driver データオブジェクトを作成していること。
手順
-
'Driver'-general propertiesセクションの Label フィールドに Driver と入力します。 - + add field をクリックします。
以下の値を入力します。
-
Id:
name -
Label:
Full Name -
Type:
String
-
Id:
Create and continue をクリックした後、以下の値を入力します。
-
Id:
age -
Label:
Age -
Type:
Integer
-
Id:
Create and continue をクリックした後、以下の値を入力します。
-
Id:
state -
Label:
State -
Type:
String
-
Id:
Create and continue をクリックした後、以下の値を入力します。
-
Id:
city -
Label:
City -
Type:
String
-
Id:
Create and continue をクリックした後、以下の値を入力します。
-
Id:
violations -
Label:
Violations -
Type:
Violation(com.myspace.driver_department_traffic_violations.Violation) - List: このチェックボックスを選択すると、このフィールドで、指定した型のアイテムを複数保持できるようになります。
-
Id:
Create and continue をクリックした後、以下の値を入力します。
-
Id:
fineAmount -
Label:
Fine Amount -
Type:
Double
-
Id:
Create and continue をクリックした後、以下の値を入力します。
-
Id:
totalPoints -
Label:
Total Points -
Type:
Integer
-
Id:
Create and continue をクリックした後、以下の値を入力します。
-
Id:
reason -
Label:
Reason -
Type:
String
-
Id:
- Create をクリックします。
- Save をクリックした後、Save をクリックして変更を確認します。
Driver_department_traffic_violations ラベルをクリックして、プロジェクトの Assets ビューに戻ります。
図2.5 Driver データオブジェクトフィールド