tBRMS
Applies Drools business rules to an incoming flow and writes the output data to an
XML file.
tBRMS retrieves
business rules from a Drools repository and applies them to a Job.
tBRMS Standard properties
These properties are used to configure tBRMS running in the Standard Job framework.
The Standard
tBRMS component belongs to the Processing family.
This component is available in the Palette of the Studio only if you have subscribed to one of the Talend Platform products.
Basic settings
Property type |
Either Built-in or |
|
Built-in: No property data stored |
|
Repository: Select the repository |
Schema and Edit Schema |
A schema is a row description, it defines the number of fields Click Edit schema to make changes to the schema.
|
|
Built-in: You create and store |
|
Repository: The schema already |
XML Field |
Select the XML field for the data to be written to the output |
Choose rule module |
Select from the list: – Use latest deployment from Kie – Use last imported module: with Do not use this option when you run your Job for the first The fields that follow will vary according to your choice. |
Drools Workbench URL |
Enter the address of the Drools repository incorporated in |
Username and Password |
Type in the authentication information used to connect to the To enter the password, click the […] button next to the |
TAC URL |
Enter the address of the |
Module list |
Click the three-dot button next to the field to open a list of the |
Maven Deployment Path |
After you select the Jar file from the Drools |
Class Name |
After you select the Jar file, this field is automatically |
Drools flow ID (optional) |
A Drools flow describes the order in which a series of business When you need to call a specific Drools flow via tBRMS to use the execution order it For more information about Drools flow, see the relevant Drools |
Advanced Settings
Configure XML Tree |
Click […] to map the source |
Group by |
Use the tool bar to modify the column order. |
Advanced separator |
Select this check box to modify the separators used for |
Encoding |
Select the encoding type from the list or select Custom and define it manually. This field |
tStatCatcher Statistics |
Select this check box to collect the log data at the component |
Global Variables
Global Variables |
ERROR_MESSAGE: the error message generated by the
NB_LINE: the number of rows read by an input component or A Flow variable functions during the execution of a component while an After variable To fill up a field or expression with a variable, press Ctrl + For further information about variables, see |
Usage
Usage rule |
This component handles data flows. Therefore it requires input and |
Limitation |
When using the tBRMS component in subJobs with the For further information about the |
Scenario: Applying business rules to an input flow to filter relevant data
This scenario applies only to a subscription-based Talend solution.
This scenario describes a Job in which tBRMS applies
Drools business rules to an input flow, in order that relevant data can be retrieved in
the output. In this case, rules are applied to input data about candidates applying for
a loan. The output will show whether the candidates are qualified or not.

Prerequisite:
The business rules to use in the Job have been already created and deployed on the
repository of the Drools incorporated in
Talend Administration Center
.
For further information on using Drools to build and deploy business rules, see
Talend Administration Center User Guide.
You can also clone repositories in Drools to have access to business rules stored in
them. For further information on cloning a Drools repository, see
Talend Administration Center
User Guide.
Dropping and linking the components
-
Drop the following components from the Palette onto the design workspace: tFixedFlowInput, tMap,
tBRMS, tExtractXMLField, tLogRow. -
Link tFixedFlowInput to tMap using a Row >
Main connection. Rename the link as loanAsk to better identify its function. -
Link tMap to tBRMS using a Row > *New Output*
(Main) connection. -
Link tBRMS to tExtractXMLField using a Row > Main connection
and then use another Row > Main
connection to connect tExtractXMLField to
tLogRow.
Configuring the input flow
-
Double-click tFixedFlowInput to open its
Basic settings view: -
Click Edit schema to define the structure
of the source data. In this example, five columns are defined for the input
information of candidates. -
Click OK to validate your changes and
close the dialog box. -
Select Use Inline Content(delimited file)
in the Mode area. -
Change the settings in the Row Separator
and Field Separator fields as needed. In
this example, enter ” “ in the Field Separator field. -
In the Content area, enter the following
data which represents the information of ten
candidates:34 385000 58500 20 50000
25 160000 12000 22 20000
32 285000 8000 18 60000
17 430000 100000 15 40000
24 385000 58500 20 50000
17 430000 100000 15 20000
32 285000 5000 18 60000
71 320000 23000 8 100000
34 160000 12000 22 40000
43 270000 60000 10 150000
Configuring the tMap component
-
Double-click tMap to open its Map Editor.
-
In the lower right part of the map editor, click the plus button to add
eight columns: age, annualRevenue, loanDeposit, loanAmount,
numberOfYears, loanInterest, monthlyPayment, rejected.These columns will appear in the synonyms table on the right side of the
map editor. In this example, the table is row1. -
In the upper left part of the map editor (input flow), select the
age and annualRevenue columns and drop them respectively to the
age and annualRevenue columns in the upper right part of the map
editor (output flow).Alternatively, click Auto map! to map the
columns with the same name automatically. -
In the row1 table, click the Expression column in the loanDeposit row to locate the cursor, and then click the
three-dot […] button to open the
[Expression Builder] dialog box.Enter the following expression to calculate the loan deposit:1Math.round(((loanAsk.downPayment / loanAsk.totalAmount)*100))Click OK to close the [Expression Builder] dialog box.Now the downPayment and totalAmount fields from the incoming data flow
are concatenated to the output column: loanDeposit. -
Click the Expression column in the
loanAmount row to locate the
cursor.Enter the following expression to calculate the amount of
loan:1loanAsk.totalAmount - loanAsk.downPayment -
Click the Expression column in the
numberOfYears row to locate the
cursor.Enter loanAsk.duration to concatenate
the duration row of the input flow to the
numberOfYears row in the output
column. - Enter 0.0 in the Expression column of the loanInterest and monthlyPayment rows respectively.
- Enter false in the Expression column of the rejected row.
- Click OK to close the map editor.
Configuring the tBRMS component
Basic settings of tBRMS
-
Click tBRMS to open its Basic settings view.
-
Click […] next to Edit schema to open the schema editor.
The input schema to the left is automatically retrieved from tMap.
-
In the output area to the right, click [+] to add a new column which will serve to write the output
data to an XML file. Enter a name for the column and define the Type as String.Click OK to validate your changes and
close the dialog box. -
From the XML Field list, select the name
of the XML column you entered in the output schema. -
From the Choose rule module list, select
Use latest deployment from KIE
workbench to download the Jar file from the Drools repository
incorporated in
Talend Administration Center
.For further information on using Drools to build and deploy business
rules, see
Talend Administration Center User Guide. -
In the Drools Workbench URL, enter the
address of the Drools Workbench incorporated in
Talend Administration Center
. -
Type in the user name and the password used to connect to the
Talend Administration Center
that embeds Drools.Enter
Talend Administration Center
address in the TAC URL field.When Drools is installed in the same web server as
Talend Administration Center
, you can use the name of
Talend Administration Center
application instead of the
full URL. -
Next to Module List, click […] to open the [Deploy
Jar] dialog box.In this dialog box, the URL, Username, Password and URL of TAC
fields are already filled with the corresponding information you entered in
the earlier steps. -
Click […] to browse the Jar files in
the [Select Jarfile] dialog box and select
the jar package org.talend.bank for this example. -
From the list next to the selected jar package, select the class org.talend.bank.LoanSimulator and then click
OK to close the dialog box.A
Talend
programme transforms the business rule
library into a form which can be used in the Job and creates an XSD file at
the root of your studio, at
/studio_path/Drools/<project_name>. The XSD
file records the mapping between the incoming data flow and the objects to
be handled by the Drools engine. -
In the Drools Flow ID (optional) field,
enter, between quotation marks, the ID of Drools flow to be used when
executing the rules of interest.In this example, it is loanflow. For
more information about Drools flow, see the relevant Drools manuals.
Advanced settings of tBRMS
-
Click the Advanced Settings tab to set
the additional parameters. -
In the XML Mapping area, click […] to configure the XML tree.
Right-click the first row in the Link
target table and select Import XML
Tree. -
Browse to and select the XSD file from the root of your studio. The
XML Tree schema is completed
automatically. -
Drop all of the relevant columns from the Schema
List onto the corresponding related column fields in the
Link target schema.From the dialog box which appears, select the Add
linker to target node option.Alternatively, you can click Auto map! to
concatenate automatically the columns between the Linker source and Link
target. -
Right-click the reason field and select
Set As Loop Element from the
list. - Click OK to close the dialog box.
Configuring the output flow
To extract the data of interest, you need to configure the output flow. The
operations to be performed are as follows:
-
Double-click tExtractXMLField to open its
Basic settings view. -
Click Edit schema to open the schema
editor. -
In the Output schema to the right of the editor, add and define the
columns which correspond to those columns in the tBRMS input schema. The sequence and names of columns may
vary according to your need. - Click OK to close the editor.
-
In the Loop XPath query field, enter the
name of the XML Tree root tag, as it
appears in the Configure XML Tree editor of
the tBRMS component, preceded by the
forward slash symbol and between double quotation marks, for example:
“/loanSimulator”. -
In the XPath query fields, next to the
corresponding columns, enter the fields exactly as they appear in the
XML Tree fields of the tBRMS component, in the Link Target area of the Configure XML
tree editor, between double quotation marks. -
Double-click tLogRow to open its
Basic settings view: -
In the Mode area, select the Table (print values in cells of a table)
option.
Saving and executing the Job
- Press Ctrl+S to save your Job.
-
Press F6 or click Run on the Run console to
launch the Job.The business rule has been applied to the input data and the table of
results indicates which candidates have been rejected. The Reason column indicates the reason for which the
candidate has been rejected.