2011/3/1 ioda100 <eddyhautot@gmail.com>
Thanks for your quick answer Esteban.

1) Ok i will have a look at DSL. In fact in my map i know all the properties (about 200). It would be cool to be able to have a drop down list with all these attributes as when we do it with objects for which we gave Pojo to Guvnor.


2) Yes i set the global constant i my application and put it in the session. But when a rule fire, it has to send back a value "OK" for example to the application. So i use the global consatnt to do that. As you say guvnor don't create a working memory (needed to change the global constant), i have to write by hand the lines : WorkingMemory wm = drools.getWorkingMemory();
wm.setGlobal("resultValue", "OK"); ?


I would not change the entire global object; I would just change a field:
   global Result result;
   ...
   then
       result.setValue( "OK ");

 
i use version 5.1 of drools and guvnor.

3) ok i will stay with this solution. yes i only need to stop after the end of the rule that has successfully fired. I have tried other things like workingMemory.stop() or something like this but it was not working.


Calling fireUntilHalt() and calling halt() from an ActivationEventListener would be a technique that doesn't require any messing with the rules. (Except, to be on the safe side, the addition of a very low-salience rule acting as a sentinel if nothing else fires.)

-W
 
Thank you again



On Tue, Mar 1, 2011 at 1:55 PM, Esteban [via Drools - Java Rules Engine] <[hidden email]> wrote:
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 <[hidden email]> 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
[hidden email]


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users



If you reply to this email, your message will be added to the discussion below:
http://drools-java-rules-engine.46999.n3.nabble.com/Guvnor-and-drools-implementation-questions-tp2602641p2602877.html



View this message in context: Re: Guvnor and drools implementation - questions
Sent from the Drools - User mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users