facing issue to iterate list in drools -


facing problem list iteration in drools

goodsshipment has list of goodsitems , goodsitem has list of documents

my requirement is, need check atleast 1 document available or no.

iam tried failed

writen class checking purpose

public class checkdocument {      public boolean flag = false;     public checkpreviousdocument() {     }     public boolean getpreviousdocument(goodsshipment goodsshipment) {         list<goodsitem> list = goodsshipment.getgoodsitems();         iterator<goodsitem> itr = list.iterator();         while (itr.hasnext()) {             governmentagencygoodsitem document = itr.next();             if (document.getdocuments().size() > 0) {                 flag = true;                 break;             }         }         return flag;     } }     rule "previousdocuments minimum 1"      when         $o: goodsshipment()         %x: checkpreviousdocuments(previousdocuments($o) == false)             insert(-------------) end 

can please me.. in advance

your code unusual, rule should do. note have used document type elements in list returned governmentagencygoodsitem.getdocuments().

rule atleastone when     $gs: goodsshipment()     list( size > 0 )     accumulate ( $gi: goodsitem() $gs.getgoodsitems() ,                       $d: document() $gi.getdocuments();                       collectlist( $d ) )     // $gs contains @ least 1 document end 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -