[rules-users] How to use global hashmap in drools

Wolfgang Laun wolfgang.laun at gmail.com
Thu Oct 31 03:40:17 EDT 2013


In your DRL (quote from the Expert manual):
   global java.util.List list
or a Map or a ...

In the Java code (another quote from the Expert manual):
   List list = new ArrayList();
   ksession.setGlobal("list", list);
or a Map or a...

In your DRL a function
   function setValue(Map map, String a, Integer b){
       ...
   }
I guess you can complete the function. Important: pass the global as a
parameter.

-W


On 30/10/2013, bbarani <bbarani at gmail.com> wrote:
> Sorry, I think I didn't explain my problem correctly.
>
> Consider I have to process 2 records.
>
> Each record will pass through the rule in drl file.
>
> Name Count<br>
> a       100<br>
> b       200<br>
> a       100<br>
>
> Now I want to store the above values in a global hash map as below (When I
> process the 3rd document).
>
> I will
>
> key  value
> a    200 <br>
> b    200<br>
>
> To achieve the above solution, I need a global hashmap which I can use as
> temp storage to store the values.
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/How-to-use-global-hashmap-in-drools-tp4026555p4026559.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list