Chapter 2. Data objects

Data objects are the building blocks for the rule assets that you create. Data objects are custom data types implemented as Java objects in specified packages of your project. For example, you might create a Person object with data fields Name, Address, and Date of Birth to specify personal details for loan application rules. These custom data types determine what data your assets and your decision service are based on.

The following illustration shows the Violation and Driver data objects that you will create in this tutorial.

Figure 2.1. Driver department traffic violations data objects

data model

2.1. Creating the Violation data object

The Violation data object contains data fields based on violation details, such as Violation Date, Fine Amount, and Speed Limit.

Prerequisites

You have created the Driver department traffic violations project.

Procedure

  1. Log in to Decision Central. Click MenuDesignProjects, then Driver department traffic violations.
  2. Click Create New AssetData Object.
  3. In the Create new Data Object wizard, enter the following values:

    • Data Object: Violation.
    • Package: select com.myteam.driverdepartmenttrafficviolations.
  4. Click Ok.

    Figure 2.2. Create new Data Object window

    data object

2.1.1. Adding the Violation data object data fields

Prerequisites

You have created the Violation data object.

Procedure

The data fields in the Violation data object define the available constraints that you can select from when you define your violation rules later.

  1. In the Violation-general properties section, locate the Label property and enter: Violation.

    Figure 2.3. General properties

    gen props
  2. Click + add field.
  3. Enter the following values:

    • Id: code
    • Label: Code
    • Type: String
  4. Click Create and continue, then enter the following values:

    • Id: points
    • Label: Points
    • Type: Integer
  5. Click Create and continue, then enter the following values:

    • Id: violationDate
    • Label: Violation Date
    • Type: Date
  6. Click Create and continue, then enter the following values:

    • Id: type
    • Label: Type
    • Type: String
  7. Click Create and continue, then enter the following values:

    • Id: fineAmount
    • Label: Fine Amount
    • Type: Double
  8. Click Create and continue, then enter the following values:

    • Id: speedLimit
    • Label: Speed Limit
    • Type: Integer
  9. Click Create and continue, then enter the following values:

    • Id: actualSpeed
    • Label: Actual Speed
    • Type: Integer
  10. Click Create.
  11. Click Save, then click Save to confirm your changes.
  12. Click the Driver department traffic violations label to return to the Assets view of the project.

    Figure 2.4. Violation data object fields

    violation data fields

2.2. Creating the Driver data object

The Driver data object contains data fields based on driver details, such as Name, Age, and Total Points.

Prerequisites

You have created the Driver department traffic violations project.

Procedure

  1. Log in to Decision Central. Click MenuDesignProjects, then Driver department traffic violations.
  2. Click Create New AssetData Object.
  3. In the Create new Data Object wizard, enter the following values:

    • Data Object: Driver.
    • Package: select com.myteam.driverdepartmenttrafficviolations.
  4. Click Ok.

    Figure 2.5. Create new Data Object window

    data object2

2.2.1. Adding the Driver data object data fields

Prerequisites

You have created the Driver data object.

Procedure

The data fields in the Driver data object define the driver details that you can select from when you define your violation rules later.

  1. In the 'Driver'- general properties section, locate the Label property and enter: Driver.
  2. Click + add field.
  3. Enter the following values:

    • Id: name
    • Label: Full Name
    • Type: String
  4. Click Create and continue, then enter the following values:

    • Id: age
    • Label: Age
    • Type: Integer
  5. Click Create and continue, then enter the following values:

    • Id: state
    • Label: State
    • Type: String
  6. Click Create and continue, then enter the following values:

    • Id: city
    • Label: City
    • Type: String
  7. Click Create and continue, then enter the following values:

    • Id: violations
    • Label: Violations
    • Type: Violation(com.myteam.driverdepartmenttrafficviolations.Violation)
    • List: Select this check box to enable the field to hold multiple items for the specified type.
  8. Click Create and continue, then enter the following values:

    • Id: fineAmount
    • Label: Fine Amount
    • Type: Double
  9. Click Create and continue, then enter the following values:

    • Id: totalPoints
    • Label: Total Points
    • Type: Integer
  10. Click Create and continue, then enter the following values:

    • Id: reason
    • Label: Reason
    • Type: String
  11. Click Create.
  12. Click Save, then click Save to confirm your changes.
  13. Click the Driver department traffic violations label to return to the Assets view of the project.

    Figure 2.6. Driver data object fields

    driver data fields