Reputation: 11
To simplify my usecase. I have temperature points t1-t4 whose values are being measured. Users can specify different condition and values for a rule to fire. For example
t1+ ( 2* t2) LESS-THAN 100 or t3 EQUAL 5.
So the condition and comparator are dynamic, the compared value and measured values too will be dynamic. Is this a candidate for Drools or any other rule engine. It seems to me that Drools is a template-oriented rule-engines, so one can do
rule "engine_is_hot"
no-loop
when
$t1 : Temp( id =="1", $v1 : value)
$t2 : Temp( id =="2", $v2 : value)
eval ( $v1>=50 || $v1 + $v2<=100)
then
System.out.println( $t1.getId()+""+$t2.getId());
end
So is possible to Generate the rules dynamically and by that I mean, the logical comparator, comparedvalues and present values are dynamic. And I tried using PackageDescr , it wasn't flexible ; I can't specify I want a < or >= logical comparator.
Upvotes: 1
Views: 806
Reputation: 3901
Have you tried the PackageDescrBuilder API?
https://github.com/droolsjbpm/drools/tree/master/drools-compiler/src/main/java/org/drools/lang/api
Examples:
Upvotes: 1