[rules-users] Guvnor and drools implementation - questions

Esteban Aliverti esteban.aliverti at gmail.com
Tue Mar 1 07:51:04 EST 2011


Hi,

1) my facts are in fact java Maps, is there an easy way to deal with them in
guvnor? it's not like in the example where facts are objects and we give
guvnor the Pojo model to know what we can do with it

for example i have :
$m  : Map((this["attribute1_of_the_map"] == "test1"))

How to deal with the map and have a prepopulated list of properties of the
map? And to store it in the variable $m. Without using the "free from drl"
where we have to write it by hand.

I think you could use DSL for achieve this. You could define your own DSL
saying for example *There is a Test=Map((this["attribute1_of_the_map"] ==
"test1" *I would leave the variable binding to the editor. So when you add
this particular pattern to a rule, you can bind it it you want to.

2) how to deal with global constant with guvnor?

i have something like :
WorkingMemory wm = drools.getWorkingMemory();
wm.setGlobal("resultValue", "OK");

Is it a direct way to play with global constant in Guvnor? Without using the
"free from drl" where we have to write it by hand.

The values of the globals are set in runtime. Guvnor doesn't create any
ksession (or working memory) for rules authoring. There is no need to do
that. So, you can declare your globals in Guvnor's package area  and then
use them in your rules. When an application uses these rules, and creates a
ksession from them, it must provide the value for these globals.
By the way, which version of Drools are you using?

3) for stopping firing rules after one rule fire successfully, do you know
if there is an option to do that?
For now i insert a boolean in the session and the first condition in all my
rules is that this boolean is there. When a rule fires successfully, i
retract it. I suppose there is a bettre way to do it?

I think the approach you have chosen is elegant enough. Of course that it
will only prevents new activations to happen but it will not prevent current
activations to be executed. For a cleaner implementation, you can make a
super-rule with that condition and then make all your rules to inherit from
it.
There is actually a way to force the engine to stop (I don't remember it,
but I'm pretty sure it is documented), but I don't know if that would be the
best solution since I don't know if it has any collateral effect.

Best Regards,


XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


On Tue, Mar 1, 2011 at 9:27 AM, ioda100 <eddyhautot at gmail.com> wrote:

> Hi,
>
> i have a few questions :
>
> 1) my facts are in fact java Maps, is there an easy way to deal with them
> in
> guvnor? it's not like in the example where facts are objects and we give
> guvnor the Pojo model to know what we can do with it
>
> for example i have :
> $m  : Map((this["attribute1_of_the_map"] == "test1"))
>
> How to deal with the map and have a prepopulated list of properties of the
> map? And to store it in the variable $m. Without using the "free from drl"
> where we have to write it by hand.
>
> 2) how to deal with global constant with guvnor?
>
> i have something like :
> WorkingMemory wm = drools.getWorkingMemory();
> wm.setGlobal("resultValue", "OK");
>
> Is it a direct way to play with global constant in Guvnor? Without using
> the
> "free from drl" where we have to write it by hand.
>
> 3) for stopping firing rules after one rule fire successfully, do you know
> if there is an option to do that?
> For now i insert a boolean in the session and the first condition in all my
> rules is that this boolean is there. When a rule fires successfully, i
> retract it. I suppose there is a bettre way to do it?
>
> Thanks in advance for your help
>
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/Guvnor-and-drools-implementation-questions-tp2602641p2602641.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110301/bf5c0c8a/attachment.html 


More information about the rules-users mailing list