【发布时间】: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 存在一个包含该性能的 Attention。 Attention 是一个具有 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