Access of global variables ..
by Kiran Narasareddy
Hi,
I am a new drools user. how can I access global variable which is set in
one ruletable, in the next ruletable in the same decision table(excel
sheet) ? If I am directly using the variable , it is taking null, but i had
set its value in previous rule table... Is there any solution??
Kiran Narasareddy
Computers make very fast, very accurate mistakes.
15 years, 11 months
from collect (processed = true/false) always compute same result
by Trägenap
Hi,
in the beginning I inserted a couple of not processed customers in my
workingmemory (#total = #not processed, #processed = 0). During the
rules 1-9 a part ot these customers will be processed (call
$customer.setProcessed(true) and udpate($customer) the wm).
Rule 10 + 11 should sort the customers. The result of rule 10 looks
perfect, the list just contain the processes customers. The result of
rule 11 looks bad, all customers in the wm are in the result. (#total =
#not processed + #processed)
Rule 11 is activated as last one, in the insert process all customers
are not processed, then I try to change the customer objects in the
working memory (rule 1-9). The output produced in the for-loop shows
that already processed customers are in the list, which should only
contain not processed customers.
What is wrong, where I made my mistake?
best wishes+Thanks a lot.
Thorsten Trägenap
rule "#10"
salience 46
when
$kunden : ArrayList() from collect (Customer(processed == true))
then
System.err.println("customers already processed " +
$kunden.size() + " " + $kunden);
end
rule "#11"
salience 47
when
$cust : ArrayList() from collect (Customer(processed == false))
then
System.err.println("Customer to process " + $cust.size() + " "
+ $cust);
for (int i = 0; i < $cust.size(); i++) {
Customer c = (Customer)$cust.get(i);
if (c.getProcessed()) System.err.println("Why i am here: "
+ c);
}
end
15 years, 11 months
generics / for each loop / using Java 1.5++ features in Rules Definition
by Trägenap
Hi,
a) it is possible to use generics in function definition?
function doSomething(ArrayList<Customer> alCustomers) {
// do it
}
doesnt work, I always retrieve Function Compilation error.
"<" Character
b) it is possible to use for each loop in DRL?
for (Customer cust : alCustomers) {
// do something more
}
I´am using Janino to parse+compile.
Thanks for advice.
Thorsten
15 years, 11 months
from collect (processed = true/false) always compute same result
by Trägenap
Hi,
in the beginning I inserted a couple of not processed customers in my
workingmemory (#total = #not processed, #processed = 0). During the
rules 1-9 a part ot these customers will be processed (call
$customer.setProcessed(true) and udpate($customer) the wm).
Rule 10 + 11 should sort the customers. The result of rule 10 looks
perfect, the list just contain the processes customers. The result of
rule 11 looks bad, all customers in the wm are in the result. (#total =
#not processed + #processed)
Rule 11 is activated as last one, in the insert process all customers
are not processed, then I try to change the customer objects in the
working memory (rule 1-9). The output produced in the for-loop shows
that already processed customers are in the list, which should only
contain not processed customers.
What is wrong, where I made my mistake?
best wishes+Thanks a lot.
Thorsten Trägenap
rule "#10"
salience 46
when
$kunden : ArrayList() from collect (Customer(processed == true))
then
System.err.println("customers already processed " +
$kunden.size() + " " + $kunden);
end
rule "#11"
salience 47
when
$cust : ArrayList() from collect (Customer(processed == false))
then
System.err.println("Customer to process " + $cust.size() + " " +
$cust);
for (int i = 0; i < $cust.size(); i++) {
Customer c = (Customer)$cust.get(i);
if (c.getProcessed()) System.err.println("Why i am here: " +
c);
}
end
15 years, 11 months
Filtering with Null fields ? (Drools 3)
by Maxim Veksler
Hello List,
In my rules I have something like this :
// Locate age group(s) subscriber is categorized within.
eval ($f.getCampaign().getAgeRangeGroups() == null || $subscriberAge
!= null) and AgeRange(lowValue <= $subscriberAge, highValue >=
$subscriberAge, ageRangeCode : code)
This does not work!
What should have been written above is :
1. If Campaign has no AgeRangeGroups() then do not seek AgeRange groups and
simply continue to the next constraint, otherwise -> Campaign has age
groups, now make sure subscriber is not null and then follow on to find all
matching age groups for this subscriber.
How can the above be expressed in the drl file?
I'm having problems both with the NullPointerExceptions and with the logic
not working are requested.
Is using null as the default pass condition is wise? If not could you please
suggest the correct alternative?
Thank you,
Maxim.
--
Cheers,
Maxim Veksler
"Free as in Freedom" - Do u GNU ?
15 years, 11 months
Time Units Support - execution and repeating period
by Trägenap
Hi,
I want to realize a rulebased condition-monitoring. Rules should fire
only once a week, if a condition still is true. But they should
processed once per hour. So, first I have to realize a exceution period
(e.g. once per week) and a test/repeating period to check new conditions.
I just read something about time units support and timer nodes, but do
not find more detailled manuals.
Are addtional features in drools available, to support this requirement?
Where I can find more information, examples about time unit support?
Thanks a lot.
Thorsten Trägenap
15 years, 11 months
condition problem with multiple composite constraints connectives
by Trägenap
Hi,
I have Object of type Customer with int "field1, field2" and boolean
"processed". (Example values field1 = 10, field2 = 180, not processed )
First, the condition in rule #1 was something like that:
$customer : Customer (field1 ( ( > 0 && > field2) || < 0) && processed
== false)
... but it doesnt work properly. So I changed it to
rule "Rule #1"
salience 46
when
$customer: Customer ( ( ( field1 < 0 ) || ( (field1 > 0) &&
(field1 > field2) ) ) && processed == false)
then
// do it
// set customer to processed
end
rule "Rule #2"
salience 45
when
$customer : Customer (field1 ( > 0 && < field2) && processed ==
false)
then
// do it
// set customer to processed
end
The result is that both rules fired, both rules invokes "do it".
Maybe somebody can put some helpfull ideas under my christmas tree.
Thanks
Thorsten Trägenap
15 years, 11 months
Newbie API Question
by Bhamidi Krishna
Hi,
how can one access the logical inserts from my java code?
In my rules, I have a couple of logicalInserts. How can I access the logical inserts from my calling class after the ruleset execution has completed?
Thank you,
Krishna
_________________________________________________________________
See how Windows Mobile brings your life together—at home, work, or on the go.
http://clk.atdmt.com/MRT/go/msnnkwxp1020093182mrt/direct/01/
15 years, 11 months