第2章 データオブジェクト


データオブジェクトは、作成するルールアセットの構成要素です。データオブジェクトは、プロジェクトで指定したパッケージに Java オブジェクトして実装されているカスタムのデータ型です。たとえば、データフィールド NameAddress、および Date of Birth を使用して Person オブジェクトを作成し、ローン申し込みルールに詳細な個人情報を指定できます。このカスタムのデータ型は、アセットとディシジョンサービスがどのデータに基づいているかを指定します。

以下の表は、本チュートリアルで作成する Violation (違反) および Driver (運転者) データオブジェクトを示しています。

Expand
表2.1 Violation データオブジェクト
IDLabelType

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

Expand
表2.2 Driver データオブジェクト
IDLabelType

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 プロジェクトを作成していること。

手順

  1. Add Asset Data Object の順にクリックします。
  2. Create new Data Object ウィザードで以下の値を入力します。

    • Data Object: Violation
    • Package: com.myspace.driver_department_traffic_violations を選択します。
  3. OK をクリックします。

    図2.1 Create new Data Object ウインドウ

    data object

2.1.1. Violation データオブジェクト制限の追加

Violation データオブジェクトフィールドに、ルールを定義する際に選択する制限を設定します

前提条件

Violation データオブジェクトを作成していること。

手順

  1. 'Violation'-general properties セクションの Label フィールドに Violation と入力します。

    図2.2 プロパティー

    gen props
  2. + add field をクリックします。
  3. 以下の値を入力します。

    • Id: code
    • Label: Code
    • Type: String
  4. Create and continue をクリックした後、以下の値を入力します。

    • Id: points
    • Label: Points
    • Type: Integer
  5. Create and continue をクリックした後、以下の値を入力します。

    • Id: violationDate
    • Label: Violation Date
    • Type: Date
  6. Create and continue をクリックした後、以下の値を入力します。

    • Id: type
    • Label: Type
    • Type: String
  7. Create and continue をクリックした後、以下の値を入力します。

    • Id: fineAmount
    • Label: Fine Amount
    • Type: Double
  8. Create and continue をクリックした後、以下の値を入力します。

    • Id: speedLimit
    • Label: Speed Limit
    • Type: Integer
  9. Create and continue をクリックした後、以下の値を入力します。

    • Id: actualSpeed
    • Label: Actual Speed
    • Type: Integer
  10. Create をクリックします。
  11. Save をクリックした後、Save をクリックして変更を確認します。
  12. Driver_department_traffic_violations ラベルをクリックして、プロジェクトの Assets ビューに戻ります。

    図2.3 Violation データオブジェクトフィールド

    violation data fields

2.2. Driver データオブジェクトの作成

Driver データオブジェクトには、NameAgeTotal Points などのドライバーの詳細に基づくデータフィールドが含まれます。

前提条件

Driver_department_traffic_violations プロジェクトを作成していること。

手順

  1. Add Asset Data Object の順にクリックします。
  2. Create new Data Object ウィザードで以下の値を入力します。

    • Data Object: Driver
    • Package: com.myspace.driver_department_traffic_violations を選択します。
  3. OK をクリックします。

    図2.4 Create new Data Object ウインドウ

    data object2

2.2.1. Driver データオブジェクト制限の追加

Driver データオブジェクトフィールドに、ルールを定義する際に選択する制限を設定します

前提条件

Driver データオブジェクトを作成していること。

手順

  1. 'Driver'-general properties セクションの Label フィールドに Driver と入力します。
  2. + add field をクリックします。
  3. 以下の値を入力します。

    • Id: name
    • Label: Full Name
    • Type: String
  4. Create and continue をクリックした後、以下の値を入力します。

    • Id: age
    • Label: Age
    • Type: Integer
  5. Create and continue をクリックした後、以下の値を入力します。

    • Id: state
    • Label: State
    • Type: String
  6. Create and continue をクリックした後、以下の値を入力します。

    • Id: city
    • Label: City
    • Type: String
  7. Create and continue をクリックした後、以下の値を入力します。

    • Id: violations
    • Label: Violations
    • Type: Violation(com.myspace.driver_department_traffic_violations.Violation)
    • List: このチェックボックスを選択すると、このフィールドで、指定した型のアイテムを複数保持できるようになります。
  8. Create and continue をクリックした後、以下の値を入力します。

    • Id: fineAmount
    • Label: Fine Amount
    • Type: Double
  9. Create and continue をクリックした後、以下の値を入力します。

    • Id: totalPoints
    • Label: Total Points
    • Type: Integer
  10. Create and continue をクリックした後、以下の値を入力します。

    • Id: reason
    • Label: Reason
    • Type: String
  11. Create をクリックします。
  12. Save をクリックした後、Save をクリックして変更を確認します。
  13. Driver_department_traffic_violations ラベルをクリックして、プロジェクトの Assets ビューに戻ります。

    図2.5 Driver データオブジェクトフィールド

    driver data fields
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2026 Red Hat
トップに戻る