Hello everyone,
Ive got a question. Im using drools-guvnor to execute some rule-scenarios.
I have to solve the following problem: I have an amount of objects in my
working memory and cant remove objects from the working memory in the
then-part of the rule. I want to combine two rules, the first rule selects
some objects and the second rule checks only these selected objects for
additional criteria. I have to use two rules, because I want to report the
objects selected in the first rule, too. Now I have implemented this with
two rules and in the second rule, the criterias of the first rule are copied
to the second rule, my question is, is there a way to get rid of this
redundandance?
I have tried this with a rule flow, but the problem is, this always works on
the whole working memory, but I cant remove the not used objects from
working memory for performance reasons. Is there another way to solve this
problem?
Here is an example for what I intend to do:
Rule1:
when
customer:Customer(town=="London")
then
System.out.println(customer.getLname() + " is inhabitant of
London");
Rule2:
when
customer:Customer(town=="London",job=="TEACHER")
then
System.out.println(customer.getLname() + " is a teacher");
This example illustrates, with the first rule I want to get to know, how
many customers are from London and in the second rule I want to know, how
many of the London customers are teachers. I want to create a kind of
statistics. I have quite a lot of conditions for the first rule, so I dont
want to have them redundantly.
Greetings, Dominik
Show replies by date