2017-09-27 118 views
1

我的問題是關於在Drools累積函數中使用「不存在」構造的等價物。在drools中使用「不存在」的等價積累

我使用性能對象的簡單堆積與編譯罰款,併產生預期的結果如下規則部分:

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 

現在我想用一個額外的條件延長規則。我想阻止滿足一定條件的演出積累(即最終在$衝突列表中)。

新的條件是:我不想積攢其中存在一個注意包含性能性能注意是一個對象,其中performanceSet字段保存類型的對象性能(Set performanceSet;)。我創建了thisPerformance()作爲方法性能作爲一種方法來引用$ 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)) 

編譯器抱怨有 '存在' 關鍵字:[ERR 102 ]規則「rule-conflicting-code-set-1」中的行50:40不匹配輸入'exists'。解析器返回一個空包。

我懷疑我的問題的解決方案看起來有很大的不同,但讓我們來舉例說明我想達到的目標。

回答

0

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)) 

希望它能幫助,

+0

這正是我一直在尋找的語法!非常感謝! – Edvaaart