File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes Question about Drools accessing a global HashMap and comparing it to an object value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Question about Drools accessing a global HashMap and comparing it to an object value" Watch "Question about Drools accessing a global HashMap and comparing it to an object value" New topic
Author

Question about Drools accessing a global HashMap and comparing it to an object value

Mike Viens
Greenhorn

Joined: Jan 24, 2011
Posts: 3
MyObj is a Java object that contains:

myObjList is an ArrayList<MyObj> containing from 2 to 20,000 objects

state2CodeMap is a HashMap<String, ArrayList<String>> containing an entry for each US state. The associated ArrayList contains a minimum of 1 entry, up to 200 entries.

I need to create a rule that checks all of the MyObj objects in myObjList, gets the appropriate ArrayList from state2CodeMap based on myObj.state and then if myObj.code not memberOf $codeList, run the "then" portion of the rule.

I have created about 60 fairly simple rules, that are working just fine, but this one is a little too complex for me to userstand how to write it in Drools. Looking at this page (http://blog.athico.com/2007/06/chained-from-accumulate-collect.html), I can see that nested "from" seems to be supported, but the page seems to be for Drools 4. Plus, I have had to teach myself Drools in the past week. I could really use some help with this. Any assistance is greatly appreciated!

Mike V.

uttam kumar
Ranch Hand

Joined: Jan 27, 2009
Posts: 128

Hi Mike,

This forum is solely for JBoss related queries. Please ask your question in the corresponding forum. For any JBoss related queries you are most welcome here.
Mike Viens
Greenhorn

Joined: Jan 24, 2011
Posts: 3
I apologize for using the wrong forum. Since Drools is owned by JBoss, and I found previous messages in that forum about Drools, I assumed it was a good place. I have posted in a different forum.

Mike V.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about Drools accessing a global HashMap and comparing it to an object value