For cases like this, there are several ways of doing. I think the
simplest one is to assert the values you want to reason over as facts.
So, pretent the user is supposed to enter a "threshold" value for
your rule. Assert the threshold the user entered as a Threshold fact:
Threshold( $threshold : value )
foo : Foo ( level > $threshold )
// do something
So, in this case you don't need to generate any rule on the fly
(that is much heavier than simply asserting/modifying/retracting facts).
Just keep managing the user parameters as facts. This parameters can
come from user interface, databases, configuration files, etc...
There are other ways, but they require a lot more care (using
globals for instance). So, I strongly recomend the above for the case
How can I create a rule on the fly ?
I have some rules working, and I want the user let chance some values in the
Say I have somthing like
foo : Foo ( a : level -> ( a.floatValue() > 20.0) )
I want change the "20.0" afterwards to some other value. Is this possible ?
What do I have to do for that?
The drools javadocs are not that much helpful on that matter.
Do I have to remove the rule, create a new one and insert it into the
agendagroup ? Or can I modify a rule?
What other things does somthing like this imply? (Do I have to reassert all
facts or something?)
The worst what I can think of is writing all rules including the modified
one into a new file and start reading the rules-file, creating the
workingmemory and building my facts once again.
IS there another way?
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3124-6000
Mobile: +55 11 9218-4151
JBoss, a division of Red Hat @ www.jboss.com