DROOLS pattern matching nested lists with complex objects -


i'm struggling pattern-matching routine in drools traverses lists of complex nested objects.

i have pojo structure this:

class myfact {     private list<a> listofa;     public list<a> getlistofa() { return listofa; } }  class {     private list<b> listofb;     private string stringfield;     public list<b> getlistofb() { return listofb; }     public string getstringfield() { return stringfield; } }  class b {     private string otherstringfield;     public string getotherstringfield() { return otherstringfield; } } 

i trying find correct syntax collect objects of type 'a' match set of criteria includes matching fields in objects contained within 'a's listofb.

i think rule needs this, pattern have won't compile while inside collect( ... )

import java.util.arraylist; rule "tricky syntax" when     $myfact: myfact()     $filteredlistofa: arraylist( size > 0 ) collect (          a( stringfield == "something", $listofb: listofb ) $myfact.listofa         b( otherstringfield == "somethingelse" ) $listofb     )     // neat $filteredlistofa end 

i know written in such way each element matched iteratively want fire action once , have single list of if there matches. thanks!

this isn't possible usind "collect" because multiple patterns aren't possible inside collect ce. (do mean collect a's or b's or both?) can change accumulate gives full control on accumulated:

$myfact: myfact() $filteredlistofa: list( size > 0 ) accumulate (      $a: a( stringfield == "something", $listofb: listofb ) $myfact.listofa     ,     b( otherstringfield == "somethingelse" ) $listofb;     collectlist( $a ) )  

later

if list elements should occur once when elements in listofa selected more once, use set , collectset.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -