3

我想在 drools 的 when 部分使用 in build 关键字匹配来匹配字符串。

例如

rule "test"
when Foo( fooid : id )
     Bar( barid : id, barid not matches "ID=" + fooid + ", " + name )
then ...

它似乎不起作用,因为它抱怨“ID =”+ fooid +“,”+名称。

但是如果我删除所有参数,它就会运行,即只留下“ID =”

所以问题似乎在于你如何在匹配模式中包含更多参数,你将如何解决这个问题?

谢谢

4

2 回答 2

2

在检查规则之前,您可以同时保存 fooid 和 barid 吗?不确定是否可行,您可以尝试一下。

string fooid = Food id // use correct syntax
string barid = Bar id // use correct syntax
string checkstring = "ID=" + fooid + "," + name

rule "test"  
    when   
        barid: String(this not matches "(?i)." + checkstring)  
    then  
        System.out.println(checkstring);  
    end  

笔记:

(?i) - 忽略大小写

于 2012-12-13T06:57:36.480 回答
0

rule "PuneUser_Rule"

no-loop true
ruleflow-group "EvalLoopcondition"
when
    m:HelloProcessModel(userlocation in ("PuneUser"), count < 4)
then
    m.setLoopcondition(6);update(m);

end

Here we check the rule, if PuneUser and count is less than 4 then loop will run from count till loopcondition that is till 6 .

This rule will be follwed only when you are checking the string is PuneUser or not

于 2013-01-24T10:21:31.680 回答