[rules-users] AgendaFilter not working as expected

Brian Enderle brianke at gmail.com
Wed Aug 22 22:55:42 EDT 2007


I have many rules in which I have named the various rules by the level at 
which the rules are to be fired, for instance:

rule "LevelOne: Name cannot be null"
   when
      Person(firstNm == null)
   then
      <log an error>
end

rule "LevelTwo: Street cannot be null"
   when
      Person(street== null)
   then
      <log an error>
end

Within my Java code I first insert all objects into a statefulSession, then 
add all my globals.  I then use a switch statement to call different methods 
to perform the various levels of validation (ie: performLevelOneValidation(), 
performLevelTwoValidation(), etc.).  Each of these methods calls a common 
method, performValidation(String validationLevel) which I want to use to fire 
the rules of just the validation level supplied.  I am doing this with:

statefulSession.fireAllRules(new RuleNameStartsWithAgendaFilter
(validationLevel));

In some cases I need to perform multiple levels of validation (if anything 
over Level One validation is called, all preceding levels also need to be 
validated) and need to perform them in order for reporting purposes.  My code 
correctly calls my performaValidation() method with the correct 
validationLevel but the only rules that fire are those with "LevelOne" in the 
rule name.  

I know the data, the rules, the globals, etc are all present for firing rules 
in a level other than level one and that I should get some mathces to my rules 
but I am not getting anything to match outside of Level One.

I can only assume that the rules other than Level One are not firing and that 
I am missing something within my code that fires the rules for other levels.  
Am I misunderstanding how the AgendaFilter works?  Should I be using something 
else like agenda-group to accomplish this segregation of rules?

Also, my rules and data objects do not change as the rules are run.  I simply 
display a list of errors found.  Would it benefit me to use sequential mode 
and would this help me in trying to segerate the rules into various levels?

Thanks in advance,
Brian Enderle




More information about the rules-users mailing list