I'm using ODM 8.5 (the JRules successor). In my Java domain, I have a three-character String field
that represents a number, "000" to "999". I'd like to have a decision table that represents logic like:
if field is between "000" and "012" then set the result to "tiny"
if field is between "013" and "060" then set the result to "less tiny"
...
IBM's documentation on defining columns states - "A condition statement is an incomplete BAL predicate expression...". Is there anything in the BAL that does the kind of String comparison I want to do? If not, is it possible to call a function defined in the IRL from the BAL? If so, how? I'm also open to other suggestions on how to handle this simple problem in ODM (without changing the existing Java XOM). Right now, it looks to me that I can't use an ODM decision table, although the underlying logic seems well-suited to a decision table.
This answer is heavily based on Justin Phillips's nice answer to this question, updated for ODM 8.5. Please plus up his answer.
The main idea is to create a function in the Business Object Model (BOM) that can be called from your rules. To add a BOM function:
bom
folder in the Eclipse rules project.New -> BOM Entry
from the menu.Create an empty BOM entry
option and then clickFinish
.New Class
.Finish
.Members
section, click theNew
button.New Member
dialog, select theMethod
option, enter aName
(isBetween
), returnType
for the method (boolean
), and add three String parameters (testee
- the value being tested,min
andmax
). Click theFinish
button.Members
section, and select theStatic
andFinal
options.{0} is between {1,min} to {2,max}
BOM to XOM Mapping
section, enter your Java code.11. Go back to the class level BOM editor and set the
Execution name
to the valuevoid
in the "BOM to XOM Mapping" section. This indicates that the BOM class is not linked to a Java class (XOM).The verbalization for the newly created member should now be accessible when filling out the
Test
in theCondition Column
for the decision table.