[rules-users] How to pass Decision Table (XLS file) into RuleBase in Drools version 4.0.7?

Hong-Qiang Gao hgao at scenpro.com
Thu Feb 5 11:06:00 EST 2009


Hi All,

 

Is this a correct way to pass Decision Table (XLS file) into RuleBase in
Drools version 4.0.7?

Are the exceptions related to the org.drools.decisiontable.model changes
(V2.1 Parameter
<file:///D:\Drools\2.1Drools\drools-2.1\docs\apidocs\org\drools\decisiontabl
e\model\Parameter.html> , Ruleset
<file:///D:\Drools\2.1Drools\drools-2.1\docs\apidocs\org\drools\decisiontabl
e\model\Ruleset.html> , Variable
<file:///D:\Drools\2.1Drools\drools-2.1\docs\apidocs\org\drools\decisiontabl
e\model\Variable.html>  vs V4.0.7 DRLOutput
<file:///D:\Drools\documentation\apidocs\org\drools\decisiontable\model\DRLO
utput.html> , Global
<file:///D:\Drools\documentation\apidocs\org\drools\decisiontable\model\Glob
al.html> , Package
<file:///D:\Drools\documentation\apidocs\org\drools\decisiontable\model\Pack
age.html> )?

 

 

In Drools version 2.1, I can pass  the Decision Table (XLS file) into
RuleBase and it works great;

...

file = new File(dir, XLS _filename);

 InputStream stream = null;

 RuleBase ruleBase = null;

 WorkingMemory wm = null;

try {

                stream = new FileInputStream(file);

} catch{...

}

try{

                ruleBase = DecisionTableLoader.loadFromInputStream(stream);

                wm = ruleBase.newWorkingMemory();

} catch{ ...

}

return wm;

.

 

In Drool version 4.0.7, I tried to pass the Decision Table (XLS file) into
RuleBase in the following way and it is not worked yet, though I used the
same XLS file;

.

file = new File(dir, XLS _filename);

 InputStream stream = null;

 RuleBase ruleBase = null;

 WorkingMemory wm = null;

try {

                stream = new FileInputStream(file);

} catch{...

}

try{

                ruleBase = RuleBaseFactory.newRuleBase();

                PackageBuilder builder = new PackageBuilder();

                SpreadsheetCompiler sCompiler = new SpreadsheetCompiler();

                String drl = sCompiler.compile(stream, InputType.XLS);

                builder.addPackageFromDrl(new StringReader(drl));

                ruleBase.addPackage(builder.getPackage());

                wm = ruleBase.newStatefulSession();

} catch{ ...

}

return wm;

.

 

It complains as following;

java.lang.NullPointerException

        at jxl.biff.drawing.Drawing.initialize(Drawing.java:249)

        at jxl.biff.drawing.Drawing.<init>(Drawing.java:157)

        at jxl.read.biff.SheetReader.read(SheetReader.java:737)

        at jxl.read.biff.SheetImpl.readSheet(SheetImpl.java:620)

        at jxl.read.biff.WorkbookParser.getSheet(WorkbookParser.java:230)

        at
org.drools.decisiontable.parser.xls.ExcelParser.parseFile(ExcelParser.java:7
9)

        at
org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.jav
a:89)

        at
org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.jav
a:68)

...

 

java.lang.IllegalArgumentException: Invalid rule table header cell. Should
be in the format of 'RuleTable YourRuleName'. It was: RuleTable
(ControlledVocab vocab)]

 

        at
org.drools.decisiontable.parser.RuleSheetParserUtil.invalidRuleTableDef(Rule
SheetParserUtil.java:47)

        at
org.drools.decisiontable.parser.RuleSheetParserUtil.getRuleName(RuleSheetPar
serUtil.java:41)

        at
org.drools.decisiontable.parser.DefaultRuleSheetListener.initRuleTable(Defau
ltRuleSheetListener.java:256)

        at
org.drools.decisiontable.parser.DefaultRuleSheetListener.processNonRuleCell(
DefaultRuleSheetListener.java:307)

        at
org.drools.decisiontable.parser.DefaultRuleSheetListener.newCell(DefaultRule
SheetListener.java:232)

        at
org.drools.decisiontable.parser.xls.ExcelParser.newCell(ExcelParser.java:184
)

        at
org.drools.decisiontable.parser.xls.ExcelParser.processSheet(ExcelParser.jav
a:122)

        at
org.drools.decisiontable.parser.xls.ExcelParser.parseFile(ExcelParser.java:8
0)

        at
org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.jav
a:89)

        at
org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.jav
a:68)

                ...

 

Thanks, Hong

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090205/a095fcc1/attachment.html 


More information about the rules-users mailing list