These sections explain in detail how to use the Drools page to define business rules. However, keep in mind that you must deploy the rule before being able to use it in any production environment. For further information, see Building and deploying business rules.
From Talend Administration Center, you can create rules using
WHEN-THEN statements with conditions that are logical groupings of
logical operators. Based on data that comes from a variety of sources and
departments, the business expert can then define actions, to be executed if the rule
condition evaluates to true.
In the following example, you will create a Guided Rule named CheckYoungAge that will be used to trigger loan agreement decisions based on the age of the people who apply for bank loans.
Prerequisites: You have already defined an organizational unit, a repository and a project in Drools web application. For further information see Steps to follow when using Drools, and for detail information about using Drools, check Drools Workbench.
To create a business rule:
From the Drools page, click Authoring and select Project Authoring.
From the New Items list, select Guided Rule.
The [Create new Guided Rule] dialog box opens.
In the Guided Rule field, enter a name for the new rule, CheckYoungAge in this example.
From the Package list, select the package in which you want to create the rule.
The package list will include only the packages to which you have access.
Select the Use Domain Specific Language (DSL) check box if you want to provide access to a list of "DSL Sentences" from which you can choose a condition to add to the rule.
Click OK to complete the rule creation and close the dialog box.
The new rule is added under the Guided Rules folder in the left panel and is opened in the rule editor in the workspace.
At any time, you can view a list of rules you have created by either selecting your category from the Browse panel, or selecting your package from the Knowledge Bases panel, and open a rule by clicking the corresponding Open button.
Upon creating a business rule, you need to define the conditions and actions of
your new rule in the
Suppose that you want to approve or disapprove a loan according to strict rules regarding the age of the borrower. The defined statement in the below example says that if the age of the person who wants to get a loan meets the specified conditions (younger than 20, or older than 70) then the loan will not be approved.
To define a condition in the
WHEN statement, do the following:
Click the green [ + ] button next to
WHENto open the [Add a condition to the rule] dialog box.
Select a class from the list, LoanSimulator in this example, and then click OK.
Click There is a LoanSimulator to open a dialog box and set a variable name.
In the Variable name field, enter a variable name, customer in this example, and click Set. The variable name is written in the
Click There is a LoanSimulator [customer] to open the [Modify constraints] dialog box again.
From the Add a restriction on a field list, select age to add an age field to the
From the logical operators list, select a logical operator, less than in this example, and then click the pencil icon to open the [Field value] dialog box.
Click the New formula button to add a value field next the logical operator, and enter 20 in the field.