You are an experienced rule builder now! Add the FraudDetection rule, typing in the Source view or Form view, according to your preference. The source is shown below.
Most of the code is in the conditions. The first condition checks whether the number of debits in the specified interval prior to the current time is greater than the specified number of debits. The interval and the number of debits are set in the
FraudCriteria scorecard.
The second condition checks whether the sum of all debits in the verification interval is greater than the specified percentage of the account average monthly balance. The specified percentage is set in the
FraudCriteria scorecard. The average monthly balance, for the purposes of this tutorial, is set in the Account instance created by the
CreateAccount rule.
You will also add a rule called UnsuspendAccount. This is a convenience rule that allows you to change a customer status from Suspended to Normal at run-time.
How are conditions processed? All conditions in a rule must be met, before the action is done. That is, each condition is joined by an implied
AND operator.
In what order are conditions evaluated? To learn more the effect of filters, equivalent join conditions, and non-equivalent join conditions on the efficiency of a rule, see
Order of Evaluation of Rule Conditions in
TIBCO BusinessEvents Architect’s Guide. Understanding these points helps you design an efficient project.
How can I learn about all these catalog functions? TIBCO BusinessEvents provides hundreds of catalog functions for use in rules and rule functions. You can use functions you already know about by typing the beginning of the name and then using the completion hints that appear. To learn about more functions, you can open the Catalog Functions view and browse. To see the tooltip for a function, hover the mouse over the function name. You can then drag a function into the editor, as you did in
Task M, Add the CreateAccount Rule. As a reminder, here’s how to open the Catalog Functions view:
Window > Show View > Other > TIBCO BusinessEvents > Catalog Functions. The tooltips are also available in HTML form, in the Online References section of the HTML documentation for the product.
Concepts.Account account;
//1. Checks the number of debits in the verification interval
Temporal.History.howMany(account.Debits,
DateTime.getTimeInMillis(DateTime.now())-FraudCriteria.interval,
DateTime.getTimeInMillis(DateTime.now()),
> FraudCriteria.num_txns;
//2. Checks the percentage of the average balance that was
// debited in the verification interval
Temporal.Numeric.addAllHistoryDouble(account.Debits,
DateTime.getTimeInMillis(DateTime.now())-FraudCriteria.interval)
> FraudCriteria.debits_percent*account.AvgMonthlyBalance;
//Check whether Account status is not set to Suspended
account.Status!="Suspended";
account.Status="Suspended";
System.debugOut("#### Account ID "+account@extId+" STATUS set to Suspended. Fraud suspected.");
Concepts.Account account;
Events.Unsuspend request;
account@extId == request.AccountId;
account.Status == "Suspended";
account.Status = "Normal";
Congratulations! You have now configured the project’s ontology and rules. Now you are ready to configure the Cluster Deployment Descriptor and build the archive for deployment. But before you do, it’s wise to validate and analyze the project, and look at it in the Project diagram.