What would possibly be wrong with the following decision table?

你。 提交于 2019-12-11 13:27:05

问题


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();
     }
     }
}

I am implementing this decision table with just one rule for now. I am getting "mismatch input '==' in rule "Screens_11"],text=parser returned a null Package]]" error. This is the stack trace:

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)

Any help would be appreciated.

Edit: Added text generated from the spreadsheet

=== 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:


Row 8 has joined cells. Don't join beyond the constraint columns.

Try this code and report back with the full output.

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();
  }
}


来源:https://stackoverflow.com/questions/38073917/what-would-possibly-be-wrong-with-the-following-decision-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!