[rules-users] Drools Bug: Custom Operator with Maps results in Mvel Error

Edson Tirelli tirelli at post.com
Fri Oct 29 13:06:25 EDT 2010


   Uday,

   You don't need a new type:

Number( this daycompare[gt] 1 ) from profile.pageFreq["internet"]

   I used the Number interface above, but you can use the Integer
class directly if you want. Also, you can use the field names like
"intValue" instead of using "this" if you want.

   Now, I have no idea why your expression is not compiling. Can you
create a test case that we can reproduce?

   Edson


2010/10/29 Uday Kodukula <ukodukula at synacor.com>:
>
> Edison,
>
> Thanks for your prompt reply!
>
> I'm trying to incorporate the workaround that you've suggested but I keep
> getting an error with the use of the from clause. I based this off of the
> documentation provided on drools.org for drools expert on how to use the
> from clause.
>
> So I declared a custom type called FreqValue, who has an attribute called
> freqCount that is an in.
>
> I store that FreqValue type in my hashMap and set it's value to 2 in my
> TestDriver.
>
> The following is my rule:
>
> ---
>
> declare FreqValue
>        freqCount: int
> end
>
> rule "Testing out UdayCompare Operator"
>        ruleflow-group "udaytesting"
>        when
>                profile : Profile()
>                FreqValue( freqCount udaycompare[gt] 1 ) from
> profile.pageFreq["internet"]
>        then
>                System.out.println("Yippie it works!!");
> end
>
> Note that the profile.pageFreq["internet"] value contains an instance of the
> FreqValue object. So, the types match. I was hoping that I didn't have to
> create a separate type, since the hashMap pageFreq just contains Integers.
> But I can't say Integer( "internal attribute for Integer to store value?"
> udaycompare[gt] 1)...
>
> Anyways, when running this I get the following error about an error in the
> from clause:
>
>    Unable to build expression for 'from' : 1 'profile.pageFreq["internet"]'
> : [Rule name='Testing out UdayCompare Operator']
>
> Any idea what is wrong? It's a pretty ambiguous error message...
> --
> View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Bug-Custom-Operator-with-Maps-results-in-Mvel-Error-tp1790252p1793445.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com




More information about the rules-users mailing list