[rules-users] Guvnor and drools implementation - questions

Vincent Legendre vincent.legendre at eurodecision.com
Mon Mar 7 13:38:43 EST 2011


> I've just created 2 class like you show me with some changes to fit 
> and test all (timestamp are long in fact, i have put int, double and 
> string as well)
In the second class you don't need the attributes as members, because 
Drools uses get / set methods to deduce them, and anyway you never use 
them as they are stored in the map.

> Then i have imported this in Guvnor.
>
> I have made 2 categories. I have put the model (jar) in the 2 categories.
That is non-sense. Jars are not linked to a category but to a package.

> I have created 2 simple rules playing with the attributes id, timestamp...
With Guided editor ?

>
> 1) For the condition Map $m1 different then Map $m2. I suppose i have 
> to use the function define in MapPojo? I have to write it by hand 
> using "free from drl" : eval($m1 != $m2) ? or is there a better way?
>
Its a way.
You can also test the id directly in conditions (in Guided editor, bind 
the id of the first instance to a var, then compare it in the second 
condition.
>
> The same for testing that $m1 timestamp (Long) is befor $m2. I have to 
> write it by hand : eval($m1.isBefore($m2))? So they have to know it 
> exist a method isBefore if not said by the gui?
>
Same. Add the test directly in the condition.
Another solution is to use a custom operator (search this mailing list 
for samples).

> 2) In the code It's written MapTest1(..) instead of Map(...) so i 
> suppose drools has to do it with the precompiled package  .pkg to know 
> about the MapPojo and MapTest1.. If i take only the .drl, drools won't 
> know about class MapTest1.
>
It is MapTest1, because this is the class used .... and drools knows it 
because it uses it ... You don't use Map directly anymore
>
> Yes i can set a category to each of my rule.
Yes you can !
> Do you mean create 4 categories (cat1, cat2, cat3, cat4) and for rules 
> of file1.drl, put them it cat1, for file2.drl, put them in cat2... ?
Yes
> Set a first condition in the rules?
Choose between categories and first condition. Don't use both
> Am i obliged to create a package per file and filter by category or is 
> it possible to make a package with all and filtering when creating the 
> knowledgeBase or something like that?
You certainly can filter your KB afterwards, but this is not really an 
out-of-the-box function. To me you have two options. For both options, 
you have only one Guvnor package :*

First option* : categories
set categories for your rules as you said
compile by filtering one category, do a snapshot. Redo the same for 
other categories (in other snapshots).
Use these 4 snapshots in your code

*Second option *: First filtering condition
create a new POJO having only one field to handle the task asked (or 
category or group or file or whatever you call that) add a condition to 
all your rules testing this fact according to their group (as described 
in one of my previous mail)
create a single package (or use DRL) for all your rules.
when calling your rules, insert the suitable POJO according to tehexec 
you want.

The second is my favorite because it is less work to deploy, and your 
number of rules are quite small. The second option can be change to use 
a RuleFlow instead of a control fact.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110307/cf6c5a09/attachment.html 


More information about the rules-users mailing list