Skip to main content

Rule Authoring in JRules

  • Chapter
  • First Online:
Agile Business Rule Development
  • 1748 Accesses

Abstract

Target audience Business analyst, developer, rule author In this chapter you will learn The different rule entry languages and rule artifacts, namely, technical rules, action rules, decision tables, decision trees, and scorecards How to build your custom rule language How to orchestrate rule execution with ruleset parameters and ruleflow How to optimize rule execution by selecting the appropriate rule execution algorithm for a given rule task Key points The Ilog Rule Language (IRL) is the foundation upon which other languages and rule artifacts are built. Action rules, decision tables, decision trees, and scorecards are translated into/executed as IRL technical rules. Be aware of the possibility to develop your own rule language (with the Business Rule Language Development Framework), but resist the temptation to. Refer to your application objects through ruleset parameters. Use ruleflows to orchestrate rule execution. They provide a high-level control mechanism and a context for rule execution. Ruleflows offer opportunities for speeding execution through run-time rule selection, and algorithm selection.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 54.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    The first full-fledged ILOG Rule Language was based on the rule language OPS5 (see Chap. 6).

  2. 2.

    When we build a BOM entry from a Java project, we not only “import” the classes from that project, but we also “import” commonly useful classes from the Java library including basic types, collections, java.util.Date, java.util.Calendar, etc. These additional classes constitute what JRules calls the boot bom. Empty BOM entries actually are not empty: they contain the boot bom. The default boot bom can be changed.

  3. 3.

    Recall the discussion in Sect. 6.3.2 regarding the engine notification. The good news is that BAL rule authors do not need to worry about this, because this behavior can be configured at the BOM level. Indeed, we can set up a particular data member setter (or void function member) to automatically trigger an update when used in the action part of a rule. We will come back to this in the next section when we talk about BAL to IRL translation.

  4. 4.

    EBNF stands for Extended Backus-Naur Form. People familiar with Yacc or ANTLR will recognize the syntax. Things that are supposed to appear as-is (language keywords) appear between quotes. Things that are optional appear between square brackets ([optional]). Groups of things that can appear zero or more times appear as (…)*.

  5. 5.

    The exact type is ilog.rules.engine.IlrCollection, which is a dynamic collection in the sense that objects will be automatically removed from the collection as soon as they no longer satisfy the conditions that got them in.

  6. 6.

    Called logical conditions and logical assert. The system maintains some sort of a reference-count of justifications for Alarm (or ServiceRequest) objects, and we need to redefine the equals method on the class Alarm (or ServiceRequest) accordingly. More can be found in the product documentation.

  7. 7.

    We would not explain it any further, especially that we strongly recommend not using else, because it makes rules error prone and the ruleset hard to maintain.

  8. 8.

    In this and subsequent IRL translations, we omitted class package names for presentation purposes. Just be aware that the real IRL code shows fully qualified class names in class conditions.

  9. 9.

    The lifetime issue is a bit more complex: It spans the evaluation of the condition part and the lifetime of the rule instance, if one is created. See Chap. 6.

  10. 10.

    Please do not write rules like this one at home : This rule breaks every rule writing guideline we mentioned in Chap. 9. It is only meant to illustrate various syntactic constructs.

  11. 11.

    We simplified the underlying IRL to make it more readable, by: (a) removing class package names, (b) reducing the number of extraneous parentheses, and (c) simplifying/faking the way Date constants are handled.

  12. 12.

    This is useful in those situations where (a) all the cells have the same value, or (b) the action takes no arguments – and thus no values to enter – or (c) the action represents a non-business tasks that business rule authors should not care about.

  13. 13.

    This is a misnomer because mathematically speaking, the partition of a set S is a set of non-overlapping subsets of S whose union equals S.

  14. 14.

    Check root package ilog.rules.dt, and more specifically, ilog.rules.dt.model.

  15. 15.

    The Internal Revue Service expects all US entities (corporations, individuals) to file for taxes every year, and it has the necessary authority and … hum … leverage to make sure they comply. With foreign entities, because it lacks such “leverage”, it requires that a percentage of their gains on each transaction be preemptively withheld (typically 30%, but sometimes 15% or 10%) or reported … unless, of course … (a few hundred rules and exceptions based on type of entity, country of origin, existence of treaties, type of transaction, etc.).

  16. 16.

    As is the case with statistical models, it is part science (mostly), part art. Note that the JRules Scorecard Modeler does not support those statistical analyses: They need to be done using other tools such as the SAS Enterprise Miner.

  17. 17.

    We greatly simplified the actual IRL to make it readable. The actual IRL has more actions, and some of the functions have more parameters.

  18. 18.

    If you must know, we need to create an Eclipse plug-in project using the extension point ilog.rules.studio.brl.languages.

  19. 19.

    Of course, we could have several out parameters in Java … if we aggregate them in a single return object.

  20. 20.

    This is a somewhat abusive simplification, but it will do for now: (1) the API for manipulating XML data (XML XOM) is slightly different, for both working memory insertion, and parameter passing, (2) with inout parameters, for the case of local invocation (same JVM, as in the example above) the variable passed as inout will reflect the changes made by rule execution (no need to fetch the new value from outputs), and (3) the RES API does enable us to pass data that is to be inserted in working memory.

  21. 21.

    And in a distant past (Rules C++), they were.

  22. 22.

    For example, public static class data members.

  23. 23.

    JRules enables us to use variable names that contain spaces. However, internally, it replaces spaces by “_” … and “_” by “$_$”.

  24. 24.

    We insist on the term behaves as because internally, it is the same ruleset object and the same rule engine, except that different subsets of the ruleset will be activated as we move from one rule task to another.

  25. 25.

    The properties of a rule can be either extractable, in which case they are available in the run-time representation of rules, or non-extractable, in which case they are development time-only properties. The extractability of a rule property is a true/false attribute than can be set in rule model extensions. See Chap. 17 for more information about extending the rule metamodel.

  26. 26.

    We will be able to extract the ruleset, but when we load it into a ruleset object, we get a ruleset parsing error.

  27. 27.

    Data entry typically involves saving the data entered in the database, but also, pulling out the policy object from the database. Payment requires either printing checks or making automatic transfers by accessing a banking system.

  28. 28.

    Note that the current BOM does not support these rules. They are used for illustration purposes.

  29. 29.

    That is, without the in/from constructs.

  30. 30.

    For example, in RETE mode, when an object is insert’ed, all of the rules that concern it will be evaluated. In sequential and fastpath mode, the new object may or may not be considered depending on the tuple enumerator used by the sequential algorithm or the rule ordering algorithm used by fastpath.

  31. 31.

    Object local variables are variables defined using the form “set <var name>to a <object type> [scope expression].” A variable that represents the value of an attribute (regardless of its type) is not mapped to an IRL class condition.

  32. 32.

    Well. They can also handle simple extensions like specifying value editors or specializing tokens of the language, but they cannot handle different grammatical structures.

  33. 33.

    We can call it a domain-specific language to make it more acceptable .

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Jérôme Boyer .

Rights and permissions

Reprints and permissions

Copyright information

© 2011 Springer-Verlag Berlin Heidelberg

About this chapter

Cite this chapter

Boyer, J., Mili, H. (2011). Rule Authoring in JRules. In: Agile Business Rule Development. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-19041-4_11

Download citation

Publish with us

Policies and ethics