[rules-dev] Custom PackageBuilder

Andreas Kinell andreas.kinell at bmpi.ch
Wed Aug 15 03:07:51 EDT 2007


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

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20070815/7b09ceae/attachment.html 


More information about the rules-dev mailing list