[rules-users] bug in "accumulate"

Edson Tirelli tirelli at post.com
Thu Aug 16 17:59:54 EDT 2007


    Sorry, this message just came to my attention.

    A variable bound in the source pattern can only be used in the action()
and reverse() blocks. This makes sense because the init() and result()
blocks are executed only once for all matches, while the action() and
reverse() blocks are executed once FOR EACH match. So, in your example:

Number( ) from accumulate(
              Parent( $h : height ),
              init(),
              action(),
              reverse(),
              result())

Pretend you have more than one matching Parent, if it was allowed to use $h
in init() or result() blocks, what Parent height would $h correspond to?

   Not sure if it is clear, but maybe someone can help explaining that...

   []s
   Edson


2007/8/9, Manukyan, Sergey <SManukyan at lear.com>:
>
>  Actually there is a $h in the code… sorry for the omission in the email.
>
>
>
> Just checked it again today – it gives me same result as yesterday :
>
>
>
> rule …
>
>     when
>
>             o : Date from accumulate (
>
> Parent( $h : height  ) ,
>
> init(;),
>
> action(;),
>
> reverse(),
>
> result( $h )
>
> )
>
>             then …
>
> end
>
>
>
>
>
> -Sergey
>
>
>
>
>  ------------------------------
>
> *From:* rules-users-bounces at lists.jboss.org [mailto:
> rules-users-bounces at lists.jboss.org] *On Behalf Of *Mark Proctor
> *Sent:* Wednesday, August 08, 2007 4:51 PM
> *To:* Rules Users List
> *Subject:* Re: [rules-users] bug in "accumulate"
>
>
>
> you didn't have a dollar on the field binding:
> Parent( h : height  )
>
> $ is optional, but you must use the same in all places.
>
> Mark
> Manukyan, Sergey wrote:
>
> Folks,
>
>
>
> Using 4.0. Think I found a bug in accumulate. The variables defined inside
> *<source pattern>* cannot be recognized inside of other parts of
> accumulate (action, result)
>
>
>
> f.e.
>
>
>
> rule …
>
>     when
>
>             o : Date from accumulate (
>
> Parent( h : height  ) ,
>
> init(;),
>
> action(;),
>
> reverse(),
>
> result( $h )
>
> )
>
>             then …
>
> end
>
>
>
>
>
> Produces : $h cannot be resolved
>
>
>
>
>
> Stack trace:
>
>
>
>
>
>       at org.drools.rule.Package.checkValidity(*Package.java:408*)
>
>       at org.drools.common.AbstractRuleBase.addPackage(*
> AbstractRuleBase.java:288*)
>
>       at com.lear.rules.RuleBaseFacade.getRuleBase(*RuleBaseFacade.java:46
> *)
>
>
>
>
>
>
>
> -Sergey
>
>
>
>
>
>
>
> **********************
> ** LEGAL DISCLAIMER **
> **********************
>
> This E-mail message and any attachments may contain
> legally privileged, confidential or proprietary
> information. If you are not the intended recipient(s),
> or the employee or agent responsible for delivery of
> this message to the intended recipient(s), you are
> hereby notified that any dissemination, distribution
> or copying of this E-mail message is strictly
> prohibited. If you have received this message in
> error, please immediately notify the sender and
> delete this E-mail message from your computer.
>
>
>
>
> ------------------------------
>
>
>
> _______________________________________________
>
> rules-users mailing list
>
> rules-users at lists.jboss.org
>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
>
> _______________________________________________
> 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/20070816/0071c128/attachment.html 


More information about the rules-users mailing list