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

Uday Kodukula ukodukula at synacor.com
Fri Oct 29 14:01:14 EDT 2010


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.



More information about the rules-users mailing list