2015-05-08 50 views
0

我試圖執行Kie工作臺中寫入的規則,並與Kie Exceution服務器集成,並得到了預期的響應。 但我的要求是隻執行一個特定的規則來定義大規則列表。我可以實現什麼樣的可能方式。 我使用了Activation Group,規則流組,但沒有運氣如果有人能幫助我實現這一點。Kie工作臺引導決策表只執行一個規則

我在KIE Workbench中創建了Guided Decision表。並以這種方式

package demo.drools_examples; 
    //from row number: 1 
    rule "Row 1 Rule1" 
    dialect "mvel" 
    when 
     f1 : Account(accountType == "Regular") 
    then 
     f1.setBaseAmount(10.0); 
     f1.setBaseThreshold(10.0); 
     calculateAmount(f1); 
     calculateThreshold(f1); 
    end 
    //from row number: 2 
    rule "Row 2 Rule1" 
    dialect "mvel" 
    when 
     f1 : Account(accountType == "Registered") 
    then 
     f1.setBaseAmount(5.0); 
     f1.setBaseThreshold(15.0); 
     calculateAmount(f1); 
     calculateThreshold(f1); 
    end 
    //from row number: 3 
    rule "Row 3 Rule1" 
    dialect "mvel" 
    when 
     f1 : Account(accountType == "Saving") 
    then 
     f1.setBaseAmount(20.0); 
     f1.setBaseThreshold(10.0); 
     calculateAmount(f1); 
     calculateThreshold(f1); 
    end 

我如何定義saliance生成源,激活組或其他任何政策只能撥打規則1,而不是調用fireallRules(1)..請幫我

回答

0

你要叫fireAllRules,但與一捻:

AgendaFilter af = new SingleRuleFilter("Row 1 Rule1"); 
int nFired = kieSession.fireAllRules(af); 

而你只需要編寫這樣的事:

public class SingleRuleFilter implements AgendaFilter { 
    private String name; 
    public SingleRuleFilter(String name){ 
     this.name = name; 
    } 
    public boolean accept(Activation activation){ 
     return activation.getRule().getName().equals(name); 
    } 
} 
相關問題