2013-11-21 22 views
0

我有兩個事實,我插入到我的drools會話。我要檢查以下內容:如何檢查guvnor Web決策表中的等價性?

(!shipment1 = NULL & & shipment1.shipToCustomerNo == waypoint1.shipToNumber)|| shipment1 == null

我該如何在基於guvnor網頁的決策表中添加這個條件?我嘗試過使用謂詞,而waypoint1和shipment1是成功插入會話的綁定變量。如果我使用謂詞並添加上面的內容,那麼我的測試用例可以正常工作,但是當我實際在我的Java應用程序中運行這些規則時,即使數據是等價的,條件也不會評估爲真。我已經嘗試了許多不同的方式來構造這個查詢。以下是生成的源文件:

//from row number: 1 
rule "Row 1 Arrive Destination" 
    salience 3 
    activation-group "arrive-destination" 
    dialect "mvel" 
    when 
     waypoint1 : Waypoint(type == "Destination") 
     clm1 : CarLocationMessage(sightCode == "Z" , loaded == true) 
     shipment1 : Shipment(eval((shipment1 != null && shipment1.shipToCustomerNo == waypoint1.shipToNumber) || shipment1 == null)) 
    then 
     TripEventRuleResult tripEventRuleResult1 = new TripEventRuleResult(); 
     tripEventRuleResult1.setEventType("Arrive"); 
     insert(tripEventRuleResult1); 
end 

回答

1

如果我正確理解了您的域和問題描述,那麼您應該可以按照這樣的規則來執行規則。

//from row number: 1 
rule "Row 1 Arrive Destination" 
    salience 3 
    activation-group "arrive-destination" 
    dialect "mvel" 
    when 
     waypoint1 : Waypoint(type == "Destination") 
     clm1 : CarLocationMessage(sightCode == "Z" , loaded == true) 
     Shipment(shipToCustomerNo == waypoint1.shipToNumber) or 
     not Shipment() 
    then 
     TripEventRuleResult tripEventRuleResult1 = new TripEventRuleResult(); 
     tripEventRuleResult1.setEventType("Arrive"); 
     insert(tripEventRuleResult1); 
end 

總之,您不需要對Shipment對象進行空檢查。它或者是或者不在工作記憶中