在 drools accumulate 中使用相当于 'not exists'
Using the equivalent of 'not exists' within drools accumulate
我的问题是关于在 Drools accumulate 函数中使用等效的 'not exists' 构造。
我使用具有以下规则部分的 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())
我试过这样重写相应的accumulate:
$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'。解析器返回了一个空包。
我怀疑我的问题的解决方案看起来会很不一样,但让这个例子来解释我想要实现的目标。
not exists
不是 Drools 中的有效结构。只需使用 not
即可。
那么,您正在寻找的是在 accumulate 中使用多个模式。您需要将规则重写为如下内容:
$conflicts : List(size() > 1)
from accumulate(
($p : Performance(code == "FOO") from $patient.performances and
not Attention(performanceSet contains $p)),
collectList($p))
希望对您有所帮助,
我的问题是关于在 Drools accumulate 函数中使用等效的 'not exists' 构造。
我使用具有以下规则部分的 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())
我试过这样重写相应的accumulate:
$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'。解析器返回了一个空包。
我怀疑我的问题的解决方案看起来会很不一样,但让这个例子来解释我想要实现的目标。
not exists
不是 Drools 中的有效结构。只需使用 not
即可。
那么,您正在寻找的是在 accumulate 中使用多个模式。您需要将规则重写为如下内容:
$conflicts : List(size() > 1)
from accumulate(
($p : Performance(code == "FOO") from $patient.performances and
not Attention(performanceSet contains $p)),
collectList($p))
希望对您有所帮助,