[rules-users] Guvnor and drools implementation - questions

ioda100 eddyhautot at gmail.com
Fri Mar 4 12:26:46 EST 2011


You make me hesitating  :-).

I just tried to make a pojo. But i will have to do a single Pojo called
"Map" with all the properties? Right now i had 4 Enum. Here i will have to
have all in the same POJO with name "Map".

The advantage i suppose is that with the Pojo, we can directly tell this
attribute is a String, this one is a Integer, this one a Double and this one
a Long and in the rules all will be done automatically without casting?

I can still assign $m1 for example to a Map found with "set variable name".

But in my example of 2 mails ago, to verify that it's not the same Map with
verifying $m1["id"]!=$m2["id"] i have to write it by hand with adding a Map
and choose formula then adding "$m1["id"]!=$m2["id"]"? Same for testing
timestamp of $m1 is before timestamp of $m2? Or is there a way to add it in
Pojo? I tried adding methods in the Pojo but i cannot call them.



I can have a look for taking the compiled package but this will mean change
a lot of code. I had to implement something that watch if the drl file was
change before creating the Knoledge base otherwise we keep the old knowledge
base. Because i do it in a multi threaded environement and it was crashing.

If i take th ecompiled one, can i easily split this in 4 compiled package
with each its rules? using Category?

The solution to do it with drl is a little too complicated.

Thanks again.


On Fri, Mar 4, 2011 at 4:42 PM, Vincent Legendre [via Drools - Java Rules
Engine] <ml-node+2634103-727164287-237284 at n3.nabble.com> wrote:

> <html> <head> </head> <body text="#000000" bgcolor="#ffffff">
>
> I will rethink of POJO but i think, it will be more ennoying to update any
> change. I will need a reference to these maps in almost every case in the
> THEN clause so not a big problem finally.
>
> It's up to you. With a POJO you can implement Comparable using your time
> slots, and all other common behaviour that you will need later ... and don't
> be forced to set a tricky DSL ... and have validation/compilation telling
> you that you are using a non-existent field instead of getting NPE at
> runtime ... but it's up to you :)
>
>
> For the second question :
>
> In fact i have to make rules using these Enum and DSL and put rules in
> their specific files.
> For example now i am working with 4 different drl files :
>
> Files ?
> According to your DSL questions, I guess that you are working with Guvnor,
> so you are getting your file via the package URL for the generated DRL file
> ?
> You should create compiled package, because :
>    - rules are compiled so the KB loading is faster
>    - Guvnor (since 5.1) ca generate compiled package with only a subset of
> the rules, filtering them by category and/or status (or by a custom
> selection using rules :) ).
>
> But if you can't,or don't want to create binaries, and still want to store
> all rules inthe same package (to avoid duplicating DSL and enums), may be
> you can
>    - assign your rules a 'ruleflow-group' and create a ruleflow that branch
> on the suitable group.
>    - use 'agenda-group'.
>    - With no rule flow, you can add to all your rules a condition that
> match a fact telling which group is executing
>         rule r1
>         when
>           Exec(task == "task1")
>           $m1 : ...
>         then
>             ...
>         end
>
> It depends on how you group your rules in files.
>
>  These files have to have this specific name and the name cannot change
> because the java code use this name to load the drl file in the session.
>
> You can also access compiled binary package by a snapshot name.
> Or if you have one single set of rules, create a single KB and provide
> methods that create new session ans add the specific control fact (not sure
> of the exact syntax, just to show the idea) :
>     task1() {
>         session = getKb().newStatelessSession();
>         session.insert(new Exec("task1")
>         ...
>         session.execute(...)
>     }
>     task2() {
>         session = getKb().newStatelessSession();
>         session.insert(new Exec("task2")
>         ...
>         session.execute(...)
>     }
> and you can obviously make that generic ...
>
>
>
> To put each rule in its specific file, do i have to create a package per
> file and name the package with the name of the file i want? And copy Enum
> and DSL in each package or can i put this in global?
>
> Don't know if global can contains Enum and DSL. I think it can only contain
> rules
>
>
> To use the Test Scenario, do you know if we have to do special things? I
> tried to add Maps in the Given part and run the scenario but i get an error
> ; "unable to find constructor for java.util.Map" and the same if i put a
> boolean, string...   Is the Guvnor Test Scenario not able to find java class
> and how to make it reachable?
> I have already tried Test Scenario with adding object for which i gave a
> Pojo but never with basic java type.
>
> Don't known, sorry.
>
> </body> </html>
> _______________________________________________
> rules-users mailing list
> [hidden email]<http://user/SendEmail.jtp?type=node&node=2634103&i=0&by-user=t>
> 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-tp2602641p2634103.html
>  To unsubscribe from Guvnor and drools implementation - questions, click
> here<http://drools-java-rules-engine.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2602641&code=ZWRkeWhhdXRvdEBnbWFpbC5jb218MjYwMjY0MXwtMTEzMzMwMzAxNA==>.
>
>


--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Guvnor-and-drools-implementation-questions-tp2602641p2634675.html
Sent from the Drools - User mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110304/26337779/attachment.html 


More information about the rules-users mailing list