Hi all
I am trying to write a custom package builder in order to create rules
programmatically.
The most important feature are simple tests against object attributes like:
"if (position.getValue() > 100) then"
In Drools 3 I managed this the following way:
LiteralDescr literalDescr = new LiteralDescr("value", ">",
"100");
// define what class the rule refers to
ColumnDescr columnDescr = new ColumnDescr("com.sample.bl.Position",
"p");
columnDescr.addDescr(literalDescr);
// assemble condition
AndDescr andDescr = new AndDescr();
andDescr.addDescr(columnDescr);
ruleDescriptor.setLhs(andDescr);
packageDescriptor.addRule(ruleDescriptor);
Upgrading to Drools 4 the above code breaks and in search of a replacement
for ColumnDescr I stumbled across a FieldConstraintDescr which seems
appropriate according to the Pattern Entity Relationship Diagram (Figure
6.11) of paragraph 6.5 in the documentation.
Using it throws the following exception:
Exception in thread "main" org.drools.RuntimeDroolsException: BUG: no
builder found for descriptor class class
org.drools.lang.descr.FieldConstraintDescr
at
org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:7
7)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:53)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:420)
at
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:283)
What does that mean? Did I misunderstand the concept? Is there an easier way
to achieve what I want?
I appreciate any hints.
Thanks and regards,
Andreas