To help business users write rules easily, you must create a meaningful vocabulary for them.
In this task, you use Rule Designer to create a vocabulary directly from the object model of the existing Miniloan application.
Business users need to write and edit rules using familiar terms. As the rule project developer, you must create a business rule vocabulary for them. The process for creating this vocabulary is called “verbalization”. You create a Business Object Model (BOM) based on an object model defined in a Java™ project. The classes and members of the BOM map to the terms and phrases familiar to the business user, as follows:
This task should take you about 20 to 30 minutes to complete.
Rule Designer is the development environment for business rule applications. Developers can take advantage of its integration with Eclipse to develop Java projects along with rule projects.
In this tutorial, the rule project containing the rules to import is provided in American English (en_US) only. Therefore, you must start Rule Designer in American English (en_US) to edit and create business rules. To start Rule Designer in American English (en_US) and to import the projects for this tutorial, you open the samples console.
To open the samples console:
The Rule perspective contains various views that you will discover in this tutorial:
The Rule Explorer currently contains two projects:
You can inspect these rules in the validateWithJava method of the miniloan-server-webapp/src/miniloanweb/MiniloanBean.java class.
The Rule Project Map guides you through the different steps for setting up a rule project. It is currently empty because you have not created a rule project yet.
If the Rule Project Map is not displayed, click
to open it.The Miniloan business object model is composed of two classes, one for the borrower and one for the loan. Before creating the rule project itself, make sure that the miniloan-xom Java project is displayed in the Rule Explorer.
To create the rule project:
Now that you have an empty rule project, you can use the Rule Project Map to guide you through the steps of building the project.
The first thing that your rule project needs is the object model of the Miniloan Java project, which you imported into your workspace. This is referred to as the execution object model (XOM).
To import the XOM into your rule project:
Before you create and edit rules, you need to define a business object model (BOM). You can create a BOM from scratch or create it automatically by parsing your execution object model (XOM).
Here you use Rule Designer to parse your Java classes (XOM) automatically and create the BOM from their methods and properties. Then, you can write rules from the vocabulary terms that are contained in the BOM.
To create a BOM from the XOM:
A ruleset is an executable package that includes rule artifacts and non-rule artifacts. It contains a set of rules that can be executed by the rule engine. Ruleset parameters are part of the design of the project because they define the data that is sent to the rule engine and the type of information that can be retrieved. Rules can then use these parameters to manipulate objects passed to the rule engine, as you will see later.
Ruleset parameters are equivalent to Java method parameters. They are references that you can use when you write your rules.
To enable a decision to be made on the status of a loan, you need to create ruleset parameters for a borrower and a loan:The borrower must be an IN parameter. The value of the IN parameter is provided as input to the ruleset on execution.
The loan must be an IN_OUT parameter. The value of the IN_OUT parameter is provided as input to the ruleset on execution, and can be modified by the ruleset and provided as output at execution completion.
To declare ruleset parameters:
You now have a rule project with a vocabulary, and ruleset parameters. You have completed the design part of your rule project.
Before writing the actual rules in Rule Designer, you will orchestrate how your rules will be executed. You do this with a ruleflow in the next task.