[rules-users] Guvnor and drools implementation - questions
Vincent Legendre
vincent.legendre at eurodecision.com
Fri Mar 4 10:37:02 EST 2011
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110304/0d4e5638/attachment.html
More information about the rules-users
mailing list