[rules-users] Need help 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:39:43 EST 2009


Hi All,

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;

.

 

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

 

Are following exceptions related to the org.drools.decisiontable.model
changes (V2.1 Parameter, Ruleset, Variable vs V4.0.7 DRLOutput, Global,
Package)?

 

Above coding using v4.0.7 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/65e4f0d0/attachment.html 


More information about the rules-users mailing list