So how can I access variables that I have populated from within that scope delimiter(accumulate)?  For instance if I did want to access the delayTime, what strategy should be used?

 

Thanks,


Chris


From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: Wednesday, June 17, 2009 11:49 AM
To: Rules Users List
Subject: Re: [rules-users] averages on different data types

 


   Chris,

   Remember that accumulate is a scope delimiter, meaning variables bound inside accumulate are not visible outside of it. The error message you see is the MVEL way of saying: non-existing variable (I guess you are using mvel as the dialect for the consequence).

   If you want to know what data objects are being inserted/expired from the working memory, use a working memory listener.

   []s
   Edson

2009/6/17 Chris Richmond <crichmond@referentia.com>

Hi guys,

 

Building from the stockticker sample, I have been running my own average aggregates over time and window length and I have the following rule…it simply runs a last 10 average and outputs the average(in theory).

 

rule "show averages"

when

 

            $n : Number( doubleValue > 0 ) from accumulate (

 

 

 

            $mdo : MyDataObject($tm: delayTime) over window:length(10) from entry-point "DataObject stream",

            average( $tm )

 

        )

 

 

then

 

    System.err.println($tm);

 

End

 

I have set the limit to 0 for the average because I simply want to have it fire every time, no matter the average(they are all positive)

 

 

However I get this error:

 

Unable to build expression for 'consequence': Failed to compile: 1 compilation error(s):

 - (1,3) unqualified type in strict mode for: $tm '

    System.err.println($tm);

' : [Rule name='show averages']

 

 

If I have the consequence

 

System.err.println($n);

 

Then it outputs the average no problem, but I am trying to simply output that indifidual value, delayTime which I have stored in $tm is an integer, so I cannot figure out why I cannot output this value.    Similarly if I simply try as a consequence:

 

System.err.println($ mdo.delayTime);

 

I get a similar error.

 

What am I doing wrong?

 

Thanks,


Chris


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




--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com