Re: [rules-users] Need help with setFocus

2009-06-24 Thread Wolfgang Laun
It's impossible to diagnose exactly what goes on without seeing the LHS
patterns in detail. One possible reason for the rules rule[234] in groupX
not firing the second time that group is given focus is that none of the
objects participating in the LHS of the three rules has changed since the
first time.

Mixing condition evaluation by pattern matching with explicit control via
a-groups and the like is tricky and apt to create surprises galore. Try to
write the LHS so that they fully express the condition for firing; use
groups only as a last resort.

Hint: duplication of RHS code can be avoided by defining and calling
functions.

-W


On Wed, Jun 24, 2009 at 4:42 AM, new2drools rkbe...@gmail.com wrote:


 Hi All,

 Need some help with understanding setFocus.

 I have the following use case:

 if (condition1) {

  if (condition2) {

  } else if (condition3) {

  } else if (condition 4) {

  }

 }

 if (condition5) {

  if (condition2) {

  } else if (condition3) {

  } else if (condition 4) {

  }

 }

 I created 3 rules (rule2, rule3, rule4) for checking condition2,
 condition3,
 condition4 and
 created 1 agenda group (groupX) for them.

 I created 2 rules (rule1, rule5) for checking condition1, condition5 and
 created 1 agenda group(groupY) for them.

 rule rule1
  agenda-group groupY

  when
//
  then
   drools.setFocus(groupX);
 end

 rule rule3
  agenda-group groupX
  activation-group someActiveGroup

  when
//
  then
   //
 end

 From the java code:

 ksession.getAgenda().getAgendaGroup(groupY).setFocus();

 Problem: The first time, drools.setFocus(groupX) is invoked, I see that
 it's working fine. rule2 or rule3 or rule4 get triggered. But, the SECOND
 time that drools.setFocus(groupX) is invoked, I don't see that any rule
 in
 agenda-group groupX is being invoked...even though one of the rule's LHS
 explicitly matches...thinking that the activation-group is cancelling all
 the activation's (after one rule in that activation group is fired), I even
 removed the activation-group statement. But, it didn't help...ideally, I
 would like to bunch rule2, rule3, rule4 in one activation group.

 Can you please let me know as to why the second invocation of setFocus is
 not working? I even tried to remove everything in LHS of rule2/3/4, to see
 if the second invocation would work...it doesn't...

 Thanks!!
 --
 View this message in context:
 http://www.nabble.com/Need-help-with-setFocus-tp24177742p24177742.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

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


Re: [rules-users] Need help with setFocus

2009-06-24 Thread new2drools


Your HINT certainly helped...really really appreciate your help!!


Wolfgang Laun-2 wrote:
 
 It's impossible to diagnose exactly what goes on without seeing the LHS
 patterns in detail. One possible reason for the rules rule[234] in groupX
 not firing the second time that group is given focus is that none of the
 objects participating in the LHS of the three rules has changed since the
 first time.
 
 Mixing condition evaluation by pattern matching with explicit control via
 a-groups and the like is tricky and apt to create surprises galore. Try to
 write the LHS so that they fully express the condition for firing; use
 groups only as a last resort.
 
 Hint: duplication of RHS code can be avoided by defining and calling
 functions.
 
 -W
 
 
 On Wed, Jun 24, 2009 at 4:42 AM, new2drools rkbe...@gmail.com wrote:
 

 Hi All,

 Need some help with understanding setFocus.

 I have the following use case:

 if (condition1) {

  if (condition2) {

  } else if (condition3) {

  } else if (condition 4) {

  }

 }

 if (condition5) {

  if (condition2) {

  } else if (condition3) {

  } else if (condition 4) {

  }

 }

 I created 3 rules (rule2, rule3, rule4) for checking condition2,
 condition3,
 condition4 and
 created 1 agenda group (groupX) for them.

 I created 2 rules (rule1, rule5) for checking condition1, condition5 and
 created 1 agenda group(groupY) for them.

 rule rule1
  agenda-group groupY

  when
//
  then
   drools.setFocus(groupX);
 end

 rule rule3
  agenda-group groupX
  activation-group someActiveGroup

  when
//
  then
   //
 end

 From the java code:

 ksession.getAgenda().getAgendaGroup(groupY).setFocus();

 Problem: The first time, drools.setFocus(groupX) is invoked, I see that
 it's working fine. rule2 or rule3 or rule4 get triggered. But, the SECOND
 time that drools.setFocus(groupX) is invoked, I don't see that any rule
 in
 agenda-group groupX is being invoked...even though one of the rule's LHS
 explicitly matches...thinking that the activation-group is cancelling all
 the activation's (after one rule in that activation group is fired), I
 even
 removed the activation-group statement. But, it didn't help...ideally, I
 would like to bunch rule2, rule3, rule4 in one activation group.

 Can you please let me know as to why the second invocation of setFocus is
 not working? I even tried to remove everything in LHS of rule2/3/4, to
 see
 if the second invocation would work...it doesn't...

 Thanks!!
 --
 View this message in context:
 http://www.nabble.com/Need-help-with-setFocus-tp24177742p24177742.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

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

-- 
View this message in context: 
http://www.nabble.com/Need-help-with-setFocus-tp24177742p24185906.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


[rules-users] Need help with setFocus

2009-06-23 Thread new2drools

Hi All,

Need some help with understanding setFocus.

I have the following use case:

if (condition1) { 

  if (condition2) { 

  } else if (condition3) { 

  } else if (condition 4) { 

  } 

} 

if (condition5) { 

  if (condition2) { 

  } else if (condition3) { 

  } else if (condition 4) { 

  } 

} 

I created 3 rules (rule2, rule3, rule4) for checking condition2, condition3,
condition4 and 
created 1 agenda group (groupX) for them.

I created 2 rules (rule1, rule5) for checking condition1, condition5 and
created 1 agenda group(groupY) for them.

rule rule1
  agenda-group groupY

  when
//
  then
   drools.setFocus(groupX);
end

rule rule3
  agenda-group groupX
  activation-group someActiveGroup
  
  when
//
  then
   //
end

From the java code:

ksession.getAgenda().getAgendaGroup(groupY).setFocus();

Problem: The first time, drools.setFocus(groupX) is invoked, I see that
it's working fine. rule2 or rule3 or rule4 get triggered. But, the SECOND
time that drools.setFocus(groupX) is invoked, I don't see that any rule in
agenda-group groupX is being invoked...even though one of the rule's LHS
explicitly matches...thinking that the activation-group is cancelling all
the activation's (after one rule in that activation group is fired), I even
removed the activation-group statement. But, it didn't help...ideally, I
would like to bunch rule2, rule3, rule4 in one activation group.

Can you please let me know as to why the second invocation of setFocus is
not working? I even tried to remove everything in LHS of rule2/3/4, to see
if the second invocation would work...it doesn't...

Thanks!!
-- 
View this message in context: 
http://www.nabble.com/Need-help-with-setFocus-tp24177742p24177742.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