[rules-users] Check if a pattern binding exists in the RHS

2008-08-19 Thread hatzlj

Hello everybody,

on the LHS of my rule i connect several Conditions with OR and have
different variable bindings for this Condition. Now - if any of this
conditions does not fire, i assume that the binding variable is not created,
so I can't access it in the RHS. This results in an null pointer exception
when I call the fireAllRules-Command in my Java Application.

A simple rule example:
rule "Rule 1"
   when
  HKT: Parameter(parameterCode = "HKT", value < normalFloor) or
  GGT: Parameter(parameterCode = "GGT", value < normalFloor) or
  HSR: Parameter(parameterCode = "HSR", value < normalFloor) and
  GOT: Parameter(parameterCode = "GOT", value > normalFloor)

   then
  System.out.println(HKT.toString();

end

So my Question is: Is there any way to check in the RHS wheter the pattern
binding has been created or not or do i have to change the way of writing my
rules (which i do not want to)?

thanks,
hatzlj
-- 
View this message in context: 
http://www.nabble.com/Check-if-a-pattern-binding-exists-in-the-RHS-tp19032260p19032260.html
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] some basic questions to grouping

2008-08-19 Thread hatzlj

Hi, 

ad 1)
my understanding of the term "a rule fires" is: if the LHS of a rule is true
the rule fires (that means roughly: the RHS of the rule is added to the
agenda and executed in a given order).

ad 2)
i  have no detailed knowledge of drools but i assume ruleflow could be the
right thing for you. i would make some ruleflow-groups, for example one for
each gender. in the ruleflow definition you can make a split depending on
the gender of the person, after that you can join again and split depending
on the age of the person and execute the corresponding ruleflow-groups.
you can look up details for creating ruleflows at:
http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/html_single/index.html#d0e4418

regards,
jakob


psentosa wrote:
> 
> Hi,
> 
> I'm having some difficulty to understand the concept of grouping, but
> maybe it's only because of my understanding of the terms, so please
> apologize for the silly question
> 1. when you are saying "rules fire", does this mean: matching/checking the
> LHS of rule, or executing the RHS of rule
> 
> 2. I plan to use the grouping features of drools, but still not sure
> whether(and how) to use the agenda or activation group (or even the
> rule-flow). My problem domain is actually quite simple:
> - rules are applied based on e.g age of a person. Now, there are some
> rules for 17-year-or older, and some for 30-year-old person, if I'm to use
> the agenda group, I'd define the following:
> 
> rule1
> agenda-group "17 years-old or older"
> when
>  p:Person (Age > 17)
> 
> 
> rule2
> agenda-group "17 years-old or older"
> when
>  p:Person (Age > 17)
> .
> 
> rule3
> agenda-group "30 years-old or older"
> when
>  p:Person (Age > 30)
> ..
> 
> rule4
> agenda-group "30 years-old or older"
> when
>  p:Person (Age > 30)
> ..
> 
> If I assert a person into the WM to check his/her age, I want that only
> the rules in 30-years-old agenda are CHECKED (and eventually executed when
> the other constraints are fulfilled), bcs they are surely older than 17 as
> well. 
> And this is not only for comparing ages. Another example, some rules are
> only for Gender.MALE, and some only for Gender.FEMALE. So if a person is
> asserted, only the rules with corresponding gender will be checked and no
> need of checking/matching the other group
> The main purpose is just to skip checking unrelevant rules (imagine if
> there is only 1 rule for MALE and 1000 rules for FEMALE with 1000 times
> WHEN person (gender == FEMALE) checking for an asserted male-object).
> How can I do this effectively? Or will ALL rules checked and only the
> order of checking (and eventually exection of their RHS) is defined by the
> grouping?
> 
> I hope I've described my problem clearly and I'll try to explain this
> again in case of difficulty :)
> Thanks in advance
> 
> Regards
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/some-basic-questions-to-grouping-tp19048066p19048073.html
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users