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

Edson Tirelli tirelli at post.com
Fri Oct 29 16:18:50 EDT 2010


   Hi Uday,

   Thanks for the report bellow. I was able to isolate this to an MVEL
regression that I submitted to Mike to fix:

http://github.com/etirelli/mvel/commit/55347b578f23184935c6d224323ff031805f1afe

   This will be in MVEL 2.0.19, so as soon as Mike releases it you can
update your mvel jar and it will work.

   Meanwhile, you can work around the issue by binding the map directly:

                Profile( $map : pageFreq )
                Integer( this udaycompare[gt] 1 ) from $map["internet"]

   Thanks,

    []s
    Edson

2010/10/29 Uday Kodukula <ukodukula at synacor.com>:
>
> Hi Edison,
>
> Thanks for the tip, I realize how I can use Integer type now.
>
> The following should hopefully be sufficient to reproduce the error that I
> am experiencing. Please me know if you need further clarity. I'm continuing
> to search through posts to and debug. I'll post back if I find the solution.
>
> -- Model DRL ---
> package com.uday.targeting
>
> declare Profile
>    pageFreq: Map
> end
> --
>
> // In a driver, create a fact type for Profile, given that it is defined via
> a declarative model.
> FactType profileType = kbase.getFactType("com.uday.targeting", "Profile");
>
> // Define a HashMap for pageFreq, and set the number of times a user visited
> page tagged as "internet" to 2.
> Map<String,Integer> pageFreq = new HashMap<String,Integer>();
> pageFreq.put("internet", Integer.valueOf(2));
>
> // Associated the pageFreq Map with the Profile fact.
> profileType.set(profile, "pageFreq", pageFreq);
>
> // insert the profile into working memory
> wm.insert(profile);
>
> --- UdayRule DRL ---
>
> package com.uday.targeting
>
> rule "Testing out UdayCompare Custom Operator"
>        ruleflow-group "udaytesting"
>        when
>                profile : Profile()
>                Integer( this udaycompare[gt] 1 ) from profile.pageFreq["internet"]
>        then
>                System.out.println("Yippie it works!!");
> end
>
> ---
>
> Error thrown:
>
>  Unable to build expression for 'from' : 1 'profile.pageFreq["internet"]' :
> [Rule name='Testing out UdayCompare Custom Operator']
>
> --
> View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Bug-Custom-Operator-with-Maps-results-in-Mvel-Error-tp1790252p1808277.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