Arun Chandrasekaran
Arun Chandrasekaran

Reputation: 2549

Modify a drools rule to set rule attributes programmatically

I see classes like org.drools.lang.api.PackageDescrBuilder and org.drools.lang.api.impl.RuleDescrBuilderImpl to create rules programmatically, but I don't see any examples of that.

Basically user will create a rule and upload the file to a location. I have read these rule files and set rule attributes like date-effective, date-expires, enabled etc.

As per org.drools.rule.Rule api, there are methods to set, but I don't get any idea on how to read the rule.drl file and convert it to object of type org.drools.rule.Rule.

Any idea on this or how to modify a drools rule using drools api will be useful.

Note: I don't want to do string replacement for modifying a rule.

Upvotes: 0

Views: 2093

Answers (1)

Steve
Steve

Reputation: 9480

You could take a look at the tests for the PackageBuilder:

https://github.com/droolsjbpm/drools/blob/5.6.x/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderTest.java

... which has examples of doing this.

Upvotes: 1

Related Questions