Red Hat Training
A Red Hat training course is available for Red Hat Decision Manager
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 DateOfBirth
to specify personal details for loan application rules. These custom data types determine what data your assets and your decision services are based on.
The following tables show the Violation
and Driver
data objects that you will create in this tutorial.
Table 2.1. Violation data object
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 |
Table 2.2. Driver data object
ID | Label | Type |
---|---|---|
name | Name | String |
age | Age | Integer |
state | State | String |
city | City | String |
violations | Violations | Violation (org.jboss.example.traffic_violations.Violation) Note: The violations field is set to "List" to hold multiple items for the given type. |
fineAmount | Fine Amount | Double |
totalPoints | Total Points | Integer |
reason | Reason | String |
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
- Click Add Asset → Data Object.
In the Create new Data Object wizard, enter the following values:
-
Data Object:
Violation
-
Package: select
com.myspace.driver_department_traffic_violations
-
Data Object:
Click Ok.
Figure 2.1. Create new Data Object window
2.1.1. Adding the Violation data object constraints
Populate the Violation data object fields with the constraints that you will select when you define your rules.
Prerequisites
You have created the Violation data object.
Procedure
In the
'Violation'-general properties
section, enter Violation in the Label field.Figure 2.2. General properties
- Click + add field.
Enter the following values:
-
Id:
code
-
Label:
Code
-
Type:
String
-
Id:
Click Create and continue, then enter the following values:
-
Id:
points
-
Label:
Points
-
Type:
Integer
-
Id:
Click Create and continue, then enter the following values:
-
Id:
violationDate
-
Label:
Violation Date
-
Type:
Date
-
Id:
Click Create and continue, then enter the following values:
-
Id:
type
-
Label:
Type
-
Type:
String
-
Id:
Click Create and continue, then enter the following values:
-
Id:
fineAmount
-
Label:
Fine Amount
-
Type:
Double
-
Id:
Click Create and continue, then enter the following values:
-
Id:
speedLimit
-
Label:
Speed Limit
-
Type:
Integer
-
Id:
Click Create and continue, then enter the following values:
-
Id:
actualSpeed
-
Label:
Actual Speed
-
Type:
Integer
-
Id:
- Click Create.
- Click Save, and then click Save to confirm your changes.
Click the Driver_department_traffic_violations label to return to the Assets view of the project.
Figure 2.3. Violation data object 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
- Click Add Asset → Data Object.
In the Create new Data Object wizard, enter the following values:
-
Data Object:
Driver
-
Package: select
com.myspace.driver_department_traffic_violations
-
Data Object:
Click Ok.
Figure 2.4. Create new Data Object window
2.2.1. Adding the Driver data object constraints
Populate the Driver data object fields with the constraints that you will select when you define your rules.
Prerequisites
You have created the Driver data object.
Procedure
-
In the
'Driver'-general properties
section, enter Driver in the Label field. - Click + add field.
Enter the following values:
-
Id:
name
-
Label:
Full Name
-
Type:
String
-
Id:
Click Create and continue, then enter the following values:
-
Id:
age
-
Label:
Age
-
Type:
Integer
-
Id:
Click Create and continue, then enter the following values:
-
Id:
state
-
Label:
State
-
Type:
String
-
Id:
Click Create and continue, then enter the following values:
-
Id:
city
-
Label:
City
-
Type:
String
-
Id:
Click Create and continue, then enter the following values:
-
Id:
violations
-
Label:
Violations
-
Type:
Violation(com.myspace.driver_department_traffic_violations.Violation)
- List: Select this check box to enable the field to hold multiple items for the specified type.
-
Id:
Click Create and continue, then enter the following values:
-
Id:
fineAmount
-
Label:
Fine Amount
-
Type:
Double
-
Id:
Click Create and continue, then enter the following values:
-
Id:
totalPoints
-
Label:
Total Points
-
Type:
Integer
-
Id:
Click Create and continue, then enter the following values:
-
Id:
reason
-
Label:
Reason
-
Type:
String
-
Id:
- Click Create.
- Click Save, and then click Save to confirm your changes.
Click the Driver_department_traffic_violations label to return to the Assets view of the project.
Figure 2.5. Driver data object fields