[rules-users] How to get value of global variable from one rule to another

Edson Tirelli tirelli at post.com
Fri Jun 15 12:19:14 EDT 2007


   Alexander,

   We can't suggest you a complete solution without knowing the problem you
are trying to solve... maybe you can state your business scenario?

   []s
   Edson


2007/6/15, Alexander Komissarov <aleks.komissarov at gmail.com>:
>
>
>
> From: "Edson Tirelli" < tirelli at post.com>
> > To: "Rules Users List" <rules-users at lists.jboss.org>
> > Date: Fri, 15 Jun 2007 11:33:52 -0300
> > Subject: Re: [rules-users] How to get value of global variable from one
> > rule to another
> >
> >    Alexander,
> >
> >    Remember that the LHS is always evaluated at assert time and RHS is
> > always executed at rule firing time. So, when you change something at rule
> > firing time that you want to cause a reevaluation of the LHS, you must
> > notify the engine calling "modify":
> >
> >
> > map.put("result",res);
> > map.put("result2",res2);
> >
> > modify( map );
> >
> >
> >     []s
> >
> >     Edson
> >
> >
> >
> >
> > Also, I've tried to map these values in the
> > >
> > > rule "AmountsAreNotNull" salience 20
> > >     when
> > >        ...
> > >     then
> > >
> > > ...
> > >
> > > <res, res2 initialization>
> > >
> > > map.put("result",res);
> > > map.put("result2",res2);
> > > ...
> > >
> > > and check it in the next rule:
> > >
> > > rule "CompareValues" salience 10
> > >
> > > when
> > > map : Map( keySet contains "result" )
> > >
> > > ...
> > >
> > > "keyset" couldn't found "result" and "result2" mapping
> > >
> > > but! when I've checked "keyset" in RHS part of this rule "keyset" HAS
> > > proper values of "result" and "result2":
> > >
> > > ...
> > >
> > > then
> > >
> > > Iterator k = map.keySet().iterator();
> > >         while (k.hasNext())
> > >         {
> > >             String key = k.next().toString();
> > >             LOGGER.info("Key: " + key + "; Value: " + map.get
> > > (key).toString());
> > >         }
> > >
> > > ...
> > >
> > > end
> > >
> > > How I can check values of "result" and "result2" in LHS part of rule
> > > "CompareValues"?
> > > Thanks,
> > > ____________________
> > > Regards,
> > > Komissarov Alexander
> > > mail: aleks.komissarov at gmail.com
> > > icq: 239128267
> > >
> > > _______________________________________________
> > > rules-users mailing list
> > > rules-users at lists.jboss.org
> > > https://lists.jboss.org/mailman/listinfo/rules-users
> > >
> > >
> >
> >
> > --
> >   Edson Tirelli
> >   Software Engineer - JBoss Rules Core Developer
> >   Office: +55 11 3529-6000
> >   Mobile: +55 11 9287-5646
> >   JBoss, a division of Red Hat @ www.jboss.com
> >
>
> Thank you for advice, but unfortunately,
>
> using modify(map) in the rule "AmountsAreNotNull" cause difficulties like
> infinite loop execution all previous rules INCLUDING this rule and EXCLUDING
> final compare rule.
>
> ____________________
> Regards,
> Komissarov Alexander
> mail: aleks.komissarov at gmail.com
> icq: 239128267
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070615/22eba14b/attachment.html 


More information about the rules-users mailing list