第2章 データオブジェクト
データオブジェクトは、作成するルールアセットの設定要素です。データオブジェクトは、プロジェクトで指定したパッケージに Java オブジェクトとして実装されているカスタムのデータタイプです。たとえば、データフィールド Name、Address、および DateOfBirth を使用して 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)
注: |
| 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 新規データオブジェクトの作成ウィンドウ
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 データオブジェクトのフィールド