如何在没有更改XOM的情况下定义在ODM决策表中使用的函数?(How to define a function for use in an ODM decision table w/o changin

编程入门 行业动态 更新时间:2024-10-09 20:29:51
如何在没有更改XOM的情况下定义在ODM决策表中使用的函数?(How to define a function for use in an ODM decision table w/o changing the XOM?)

我正在使用ODM 8.5(JRules继承者)。 在我的Java域中,我有一个三字符的字符串field ,表示一个数字,“000”到“999”。 我想要一个代表逻辑的决策表:

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 关于定义列状态的文档 - “条件语句是一个不完整的BAL谓词表达式......”。 BAL中有什么东西可以进行我想做的字符串比较吗? 如果没有,是否可以从BAL调用IRL中定义的函数? 如果是这样,怎么样? 我也对如何在ODM中处理这个简单问题提出了其他建议(不改变现有的Java XOM)。 现在,我认为我不能使用ODM决策表,尽管底层逻辑似乎非常适合决策表。

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.

最满意答案

这个答案很大程度上取决于Justin Phillips对这个问题的好回答,针对ODM 8.5进行了更新。 请加上他的回答。

主要思想是在业务对象模型(BOM)中创建一个可以从规则中调用的函数。 要添加BOM功能:

右键单击Eclipse规则项目中的bom文件夹。 从菜单中选择New -> BOM Entry 。 选择“ Create an empty BOM entry选项,然后单击“ Finish 。 双击新的BOM条目以显示BOM编辑器视图,然后单击“ New Class 。 输入类名,然后单击“ Finish 。 从列表中双击新的BOM类,然后在“ Members部分下,单击“ New按钮。 在New Member对话框中,选择Method选项,输入Name ( isBetween ),返回方法的Type ( boolean ),并添加三个String参数( testee - 要测试的值, min和max )。 单击“ Finish按钮。 双击“ Members部分下的新方法,然后选择“ Static和“ Final选项。 单击“成员语言表”部分下的“创建”链接,然后填写“ {0} is between {1,min} to {2,max}的模板文本框” 在BOM to XOM Mapping部分下,输入您的Java代码。

在此处输入图像描述 11.返回到类级BOM编辑器,并将“ Execution name设置为“BOM到XOM映射”部分中的值void 。 这表明BOM类未链接到Java类(XOM)。

现在,在决策表的Condition Column填写Test时,现在可以访问新创建的成员的语言表达。

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:

Right click the bom folder in the Eclipse rules project. Select New -> BOM Entry from the menu. Select the Create an empty BOM entry option and then click Finish. Double click the new BOM entry to bring up the BOM editor view, and then click New Class. Enter the class name and then click Finish. Double click the new BOM class from the list, then under the Members section, click the New button. In the New Member dialog, select the Method option, enter a Name (isBetween), return Type for the method (boolean), and add three String parameters (testee - the value being tested, min and max). Click the Finish button. Double click the new method under the Members section, and select the Static and Final options. Click the Create link under the "Member Verbalization" section and fill in the Template text box with {0} is between {1,min} to {2,max} Under the BOM to XOM Mapping section, enter your Java code.

enter image description here 11. Go back to the class level BOM editor and set the Execution name to the value void 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 the Condition Column for the decision table.

更多推荐

本文发布于:2023-07-09 10:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1085507.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   情况   如何在   table   XOM

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!