Drools决策表,“不匹配的输入'>”在规则上 [英] Drools decision table, "mismatched input '>' in rule "

查看:306
本文介绍了Drools决策表,“不匹配的输入'>”在规则上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Drools创建决策表,并且遇到大于字符(’>’)的问题。我在drools文档中看到
,您可以使用'>'和'<',但似乎出现了问题。

I'm creating an decision table using Drools and having trouble with the greater than character ('>'). I saw on the drools documentation that you could use '>' and '<' but I seem to get something wrong.

该列为(I尚无足够的声誉来发布图像):

The column is (I don't have enough reputation yet to post images):


  • |条件|

  • | | (空单元格)

  • |持续时间> |

  • |持续时间|

  • | 50 |

  • | 200 |

  • |CONDITION|
  • | | (empty cell)
  • |duration >|
  • |Duration|
  • |50|
  • |200|

问题是架构不允许我获取完整的对象。我只能从 RemoteObject 中获得一些字段。
所以我可以做的是:

The thing is that the architecture doesn't allow me to get the full object. I can only have some fields from the RemoteObject. So the thing I can do is:

Integer duration = getRemoteObjectDuration();
kSession.insert(duration);
kSession.fireAllRules();

其结果是:

[6,2]: [ERR 102] Line 6:2 mismatched input '>' in rule "RuleTable_11"
[14,2]: [ERR 102] Line 14:2 mismatched input '>' in rule "RuleTable_12"
[0,0]: Parser returned a null Package

我可以创建一个包含我的字段的虚拟对象,但是必须做得更好。
有人对此有想法吗?

I could create a dummy object containing my field, but there must be something better to do. Does anyone have an idea about this?

推荐答案

要匹配整数,可以使用

To match an Integer you can use a rule like

rule findInt
when
    Integer( $iv: intValue > 42 )
then
    System.out.println( "got an Integer > 42: " + $iv );
end

,因此,根据

CONDITION
Integer
intValue >
- ... -
42

当然,这注定了当您在工作内存中有多个整数对象漂浮而无法识别什么时失败。

This is, of course, doomed to fail when you have several Integer objects floating around in working memory, not being able to identify what is what.

对于您的困境,我将创建一个影子对象用于保存远程对象的所有字段,而不是单独包装这些字段。

For your predicament I'd create a shadow object for holding all fields of the remote object rather than wrap the fields individually.

这篇关于Drools决策表,“不匹配的输入'&gt;”在规则上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆