【问题标题】:Using the equivalent of 'not exists' within drools accumulate在流口水累积中使用“不存在”的等价物
【发布时间】:2017-09-27 11:27:09
【问题描述】:

我的问题是关于在 Drools 累积函数中使用“不存在”构造的等价物。

我使用 Performance 对象的简单累积,并带有以下规则部分,可以很好地编译并产生预期的结果:

rule "rule-conflicting-code-set-1" 
...
when
...
    $conflicts : List(size() > 1) 
            from accumulate( 
                $p : Performance(code == "FOO", /*other conditions*/)  
                from $patient.performances,
                collectList($p)) 

then
...
end

现在我想用一个额外的条件来扩展规则。我想防止累积满足特定条件的性能(即,最终在 $conflicts 列表中)。

新的条件是:我不想累积一个 Performance 存在一个包含该性能的 AttentionAttention 是一个具有 performanceSet 字段的对象,该字段包含 Performance 类型的对象(Set performanceSet;)。我创建了 thisPerformance() 作为 Performance 的方法,作为引用 $p 的一种方式。

条件本身如下所示:

not exists Attention(performanceSet contains thisPerformance())

我尝试像这样重写相应的累积:

$conflicts : List(size() > 1) 
        from accumulate( 
            $p : Performance(
                       code == "FOO", 
                       not exists Attention(performanceSet contains 
                           thisPerformance()),
                       /*other conditions*/)  
            from $patient.performances,
            collectList($p)) 

编译器抱怨“exists”关键字:[ERR 102] 第 50:40 行在规则“rule-conflicting-code-set-1”中不匹配输入“exists”。解析器返回了一个空包。

我怀疑我的问题的解决方案看起来会完全不同,但让这个示例解释我想要实现的目标。

【问题讨论】:

    标签: java drools exists accumulate


    【解决方案1】:

    not exists 不是 Drools 中的有效构造。只需改用not

    然后,您正在寻找的是在累积中使用多个模式。你需要将你的规则改写成这样:

    $conflicts : List(size() > 1) 
        from accumulate( 
            ($p : Performance(code == "FOO") from $patient.performances and
            not Attention(performanceSet contains $p)),
            collectList($p)) 
    

    希望对你有帮助,

    【讨论】:

    • 这正是我正在寻找的语法!非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-23
    • 2021-06-19
    • 2011-12-31
    • 2010-11-13
    • 1970-01-01
    相关资源
    最近更新 更多