[rules-users] working with arraylist in drools application jboss

Esteban Aliverti esteban.aliverti at gmail.com
Wed Dec 29 08:21:53 EST 2010


You can insert each Item as a fact. Or you can use the from keyword:

       rule 'some rule'
       when
         $D:Data()
         $R:Item(item =="I1") from $D.items  //items should be populated at
this point.
       then
         System.out.println("hello");
       end

Please note that Data class will need a getter for items. Also note that
items should be populated before insert Data as Fact.

Best Regards,

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


On Wed, Dec 29, 2010 at 10:07 AM, wasim.khan318 <khanwasim07 at yahoo.co.in>wrote:

>
> public static class Item
>        {
> private String CustomerId;
> private String Item;
> }
>
> public static class Data
> {
>        public ArrayList<Item> items = new ArrayList<Item>();
>
>        public ArrayList<Item>  GetData()
>        {Item item1 = new Item();
> // some code
> from database
> item1.CustomerId=rs.getString("CustomerId");
>  item1.Price=rs.getString("item");
>                   items.add(item);
> return item1
> }
> 1.how to write rule how to find customer of a perticular Item
> 2. what i have written
>  $D:Data();
>                $I:Item();
>
>
>          $R:Item(item =="I1"  )from $D.GetData() ;
>
>
>        then
>        System.out.println("hello");
>
>
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/working-with-arraylist-in-drools-application-jboss-tp2162690p2162690.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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101229/8bc54a9c/attachment.html 


More information about the rules-users mailing list