2016-06-28 55 views
0

Decision Table下面的決策表可能會有什麼問題?

public class TestDecisionTable { 
    public static void main(String[] args) 
    { 
    try{ 
     KieServices ks = KieServices.Factory.get(); 
     KieContainer kContainer = ks.getKieClasspathContainer(); 
     KieSession kSession = kContainer.newKieSession("ksession-dtables"); 

     Screens s1 = new Screens(); 
     s1.setDeliveryChannel("Y"); 
     s1.setUsePointsAppl("Y"); 
     s1.setContactDetails("Y"); 
     s1.setRiskScore("Y"); 
     s1.setReasonCode(100); 
     s1.setCurrentScreen(303); 
     kSession.insert(s1); 

     Screens s2 = new Screens(); 
     s2.setDeliveryChannel("Y"); 
     s2.setUsePointsAppl("Y"); 
     s2.setContactDetails("Y"); 
     s2.setRiskScore("Y"); 
     s2.setReasonCode(101); 
     s2.setCurrentScreen(303); 
     kSession.insert(s2);  

     Screens s3 = new Screens(); 
     s3.setDeliveryChannel("Y"); 
     s3.setUsePointsAppl("Y"); 
     s3.setContactDetails("Y"); 
     s3.setRiskScore("Y"); 
     s3.setReasonCode(102); 
     s3.setCurrentScreen(303); 
     kSession.insert(s3); 

     kSession.fireAllRules(); 

    } 
    catch (Throwable t) { 
     t.printStackTrace(); 
    } 
    } 
} 

我實現這個決定表只有一個規則了。我在規則「Screens_11」中得到「不匹配輸入==」],text = parser返回一個空包]]「錯誤。這是堆棧跟蹤:

java.lang.RuntimeException: Error while creating KieBase[Message [id=1, level=ERROR, path=Sample.xls, line=8, column=0 
    text=[ERR 102] Line 8:16 mismatched input '==' in rule "Screens_11"], Message [id=2, level=ERROR, path=Sample.xls, line=0, column=0 
    text=Parser returned a null Package]] 
    at org.drools.compiler.kie.builder.impl.KieContainerImpl.getKieBase(KieContainerImpl.java:450) 
    at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:604) 
    at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:575) 
    at com.sample.TestDecisionTable.main(TestDecisionTable.java:15) 

任何幫助,將不勝感激。

編輯:從電子表格

=== Begin generated DRL === 
package com.sample; 
//generated from Decision Table 
import com.sample.Screens; 
// rule values at C11, header at C6 
rule "Screens_11" 
    when 
     var:Screens(deliveryChannel == "Y") 
     usePointsAppl == "Y" 
     contactDetails == "Y" 
     riskScore == "Y" 
     reasonCode == 100 
     currentScreen == 303 
    then 
     var.setNextScreen(306); 
     System.out.println(var.getNextScreen()); 
end 

// rule values at C12, header at C6 
rule "Screens_12" 
    when 
     var:Screens(deliveryChannel == "Y") 
     usePointsAppl == "Y" 
     contactDetails == "Y" 
     riskScore == "Y" 
     reasonCode == 100 
     currentScreen == 303 
    then 
     var.setNextScreen(306); 
    System.out.println(var.getNextScreen()); 
end 


=== End generated DRL === 
+1

提示:請不要進入screenshort業務。至少對於源代碼:那是** text **;並應該這樣輸入! – GhostCat

回答

0

行8產生添加的文本已經加入細胞。不要超出約束列。

嘗試使用此代碼並返回完整輸出。

private void testSpreadsheet(){ 
    File dtf = new File(dtPath); 
    InputStream is; 
    try { 
    is = new FileInputStream(dtf); 
    SpreadsheetCompiler ssComp = new SpreadsheetCompiler(); 
    String s = ssComp.compile(is, InputType.XLS); 
    System.out.println("=== Begin generated DRL ==="); 
    System.out.println(s); 
    System.out.println("=== End generated DRL ==="); 
    } catch (IOException e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
    } 
} 
+0

謝謝。我編輯它,但錯誤仍然存​​在。 – Tanay

+0

需要查看電子表格中生成的文本。 – laune

+0

已添加到問題中。請檢查。 – Tanay