<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<title>Help with syntax for detecting when an object exists, none of whose
children match a pattern</title>
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I am a bit of a newbie myself, but I assume the following would
work:<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>When <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>&nbsp;$p: ParentFactObject()<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>$c: childFactObject(TestMe==false) from $p.ChildFactObjectList <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Then<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>//do something<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>End<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Another way is to simply assert the ChildFactObjectList as
separate facts into the working memory and then pattern match just them.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Cheers,<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Vikrant <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b>On Behalf Of </b>Tom.E.Murphy@wellsfargo.com<br>
<b>Sent:</b> Saturday, September 06, 2008 2:49 AM<br>
<b>To:</b> rules-users@lists.jboss.org<br>
<b>Subject:</b> [rules-users] Help with syntax for detecting when an object
exists, none of whose children match a pattern<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p><span style='font-family:"Calibri","sans-serif"'>As a newbie to Drools
(using v4.0.7), I&#8217;m struggling a bit with the right</span> <span
style='font-family:"Calibri","sans-serif"'>way to express</span> <span
style='font-family:"Calibri","sans-serif"'>the</span> <span style='font-family:
"Calibri","sans-serif"'>following concept</span><o:p></o:p></p>

<p><span style='font-family:"Calibri","sans-serif"'>I have a ParentFactObject
with an array of ChildFactObjects. </span><o:p></o:p></p>

<p><span style='font-family:"Calibri","sans-serif"'>The ChildFactObjects have a
boolean attribute</span> <span style='font-family:"Calibri","sans-serif"'>&#8220;TestMe&#8221;</span>
<o:p></o:p></p>

<p><span style='font-family:"Calibri","sans-serif"'>I want to pattern match all
ParentFactObjects for whom all ChildFactObjects have false for TestMe</span><o:p></o:p></p>

<p><span style='font-family:"Calibri","sans-serif"'>Here&#8217;s what I&#8217;ve tried:</span><o:p></o:p></p>

<p><b><span style='font-size:10.0pt;font-family:"Courier New";color:#960000'>rule</span></b>
<span style='font-size:10.0pt;font-family:"Courier New"'>&quot;NoTestChildren&quot;</span><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b> </b><b><span style='font-size:
10.0pt;font-family:"Courier New";color:#960000'>when</span></b><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-size:10.0pt;
font-family:"Courier New";color:black'>$parentFactObject : ParentFactObject //
parent exists</span><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-size:10.0pt;
font-family:"Courier New";color:black'>(</span><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-size:10.0pt;
font-family:"Courier New";color:black'>)</span><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b> </b><b><span style='font-size:
10.0pt;font-family:"Courier New";color:#960000'>not</span></b><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>
ChildFactObject&nbsp;&nbsp;&nbsp;&nbsp; // no child exists that has TestMe true</span><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-size:10.0pt;
font-family:"Courier New";color:black'>(</span><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-size:10.0pt;
font-family:"Courier New";color:black'>TestMe ==</span><b> </b><b><span
style='font-size:10.0pt;font-family:"Courier New";color:#960000'>true</span></b><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-size:10.0pt;
font-family:"Courier New";color:black'>)</span><b> </b><b><span
style='font-size:10.0pt;font-family:"Courier New";color:#960000'>from</span></b><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> $parentFactObject.childFactObjects</span><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b> </b><b><span style='font-size:
10.0pt;font-family:"Courier New";color:#960000'>then</span></b><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-size:10.0pt;
font-family:"Courier New";color:black'>log(</span><span style='font-size:10.0pt;
font-family:"Courier New";color:green'>&quot;Rule</span> <span
style='font-size:10.0pt;font-family:"Courier New";color:green'>NoTestChildren</span>
<span style='font-size:10.0pt;font-family:"Courier New";color:green'>fired.&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><o:p></o:p></p>

<p><b><span style='font-size:10.0pt;font-family:"Courier New";color:#960000'>end</span></b><o:p></o:p></p>

<p><span style='font-family:"Calibri","sans-serif"'>I get the following:</span><o:p></o:p></p>

<p><span style='font-size:10.0pt;font-family:"Courier New";color:red'>org.drools.rule.InvalidRulePackage:
[66,4]: unknown:66:4 mismatched token:
[@1085,4469:4472='from',&lt;38&gt;,66:4]; expecting type THEN</span><o:p></o:p></p>

<p><span style='font-family:"Calibri","sans-serif"'>Also tried this:</span><o:p></o:p></p>

<p><b><span style='font-size:10.0pt;font-family:"Courier New";color:#960000'>rule</span></b>
<span style='font-size:10.0pt;font-family:"Courier New"'>&quot;</span> <span
style='font-size:10.0pt;font-family:"Courier New"'>NoTestChildren</span> <span
style='font-size:10.0pt;font-family:"Courier New"'>&quot;</span><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b> </b><b><span style='font-size:
10.0pt;font-family:"Courier New";color:#960000'>when</span></b><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-size:10.0pt;
font-family:"Courier New";color:black'>$parentFactObject : Borrower</span> <span
style='font-size:10.0pt;font-family:"Courier New"'>// parent exists</span><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-size:10.0pt;
font-family:"Courier New";color:black'>(</span><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-size:10.0pt;
font-family:"Courier New";color:black'>)</span><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b> </b><b><span style='font-size:
10.0pt;font-family:"Courier New";color:#960000'>forall</span></b><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>
($childFactObject :</span> <span style='font-size:10.0pt;font-family:"Courier New";
color:black'>ChildFactObject</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
style='font-size:10.0pt;font-family:"Courier New"'>// no child exists that has
TestMe true</span><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-size:10.0pt;
font-family:"Courier New";color:black'>(</span><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-size:10.0pt;
font-family:"Courier New";color:black'>TestMe</span> <span style='font-size:
10.0pt;font-family:"Courier New";color:black'>==</span><b> </b><b><span
style='font-size:10.0pt;font-family:"Courier New";color:#960000'>true</span></b><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-size:10.0pt;
font-family:"Courier New";color:black'>) )</span><b><span style='font-size:
10.0pt;font-family:"Courier New";color:#960000'>from</span></b><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>
$parentFactObject.</span> <span style='font-size:10.0pt;font-family:"Courier New";
color:black'>childFactObjects</span><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b> </b><b><span style='font-size:
10.0pt;font-family:"Courier New";color:#960000'>then</span></b><o:p></o:p></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-size:10.0pt;
font-family:"Courier New";color:black'>log(</span><span style='font-size:10.0pt;
font-family:"Courier New";color:green'>&quot;Rule</span> <span
style='font-size:10.0pt;font-family:"Courier New";color:green'>NoTestChildren
fired.&quot;</span><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>);</span><o:p></o:p></p>

<p><b><span style='font-size:10.0pt;font-family:"Courier New";color:#960000'>end</span></b><o:p></o:p></p>

<p><span style='font-family:"Calibri","sans-serif"'>I&#8217;ve</span> <span
style='font-family:"Calibri","sans-serif"'>tried a series of variations with
similar results.</span><o:p></o:p></p>

<p><span style='font-family:"Calibri","sans-serif"'>Can anyone provide any</span>
<span style='font-family:"Calibri","sans-serif"'>guidance on how to do this?</span><o:p></o:p></p>

<p><span style='font-family:"Calibri","sans-serif"'>Thanks in advance.</span><o:p></o:p></p>

<p><b><span style='font-family:"Arial","sans-serif";color:blue'>Tom Murphy</span></b><br>
<b><br>
</b><i><span style='font-size:7.5pt;font-family:"Arial","sans-serif";
color:gray'>This message may contain confidential and/or privileged
information.&nbsp; If you are not the addressee or authorized to receive this
for the addressee, you must not use, copy, disclose, or take any action based
on this message or any information herein.&nbsp; If you have received this
message in error, please advise the sender immediately by reply e-mail and
delete this message.&nbsp; Thank you for your cooperation.</span></i><o:p></o:p></p>

<p><span style='font-size:7.5pt;font-family:"Calibri","sans-serif";color:gray'>&nbsp;</span><span
style='font-family:"Calibri","sans-serif"'> </span><o:p></o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><o:p>&nbsp;</o:p></p>

<table class=MsoNormalTable border=0 cellpadding=0 style='background:white'>
 <tr>
  <td style='padding:.75pt .75pt .75pt .75pt'></td>
 </tr>
</table>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<br><br><table bgcolor=white style="color:black"><tr><td><br>MASTEK&nbsp;LTD.<br>
Mastek&nbsp;in&nbsp;NASSCOM&#39;s&nbsp;&#39;India&nbsp;Top&nbsp;20&#39;&nbsp;Software&nbsp;Service&nbsp;Exporters&nbsp;List.<br>
In&nbsp;the&nbsp;US,&nbsp;we&#39;re&nbsp;called&nbsp;MAJESCOMASTEK<br>
<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
Opinions&nbsp;expressed&nbsp;in&nbsp;this&nbsp;e-mail&nbsp;are&nbsp;those&nbsp;of&nbsp;the&nbsp;individual&nbsp;and&nbsp;not&nbsp;that&nbsp;of&nbsp;Mastek&nbsp;Limited,&nbsp;unless&nbsp;specifically&nbsp;indicated&nbsp;to&nbsp;that&nbsp;effect.&nbsp;Mastek&nbsp;Limited&nbsp;does&nbsp;not&nbsp;accept&nbsp;any&nbsp;responsibility&nbsp;or&nbsp;liability&nbsp;for&nbsp;it.&nbsp;This&nbsp;e-mail&nbsp;and&nbsp;attachments&nbsp;(if&nbsp;any)&nbsp;transmitted&nbsp;with&nbsp;it&nbsp;are&nbsp;confidential&nbsp;and/or&nbsp;privileged&nbsp;and&nbsp;solely&nbsp;for&nbsp;the&nbsp;use&nbsp;of&nbsp;the&nbsp;intended&nbsp;person&nbsp;or&nbsp;entity&nbsp;to&nbsp;which&nbsp;it&nbsp;is&nbsp;addressed.&nbsp;Any&nbsp;review,&nbsp;re-transmission,&nbsp;dissemination&nbsp;or&nbsp;other&nbsp;use&nbsp;of&nbsp;or&nbsp;taking&nbsp;of&nbsp;any&nbsp;action&nbsp;in&nbsp;reliance&nbsp;upon&nbsp;this&nbsp;information&nbsp;by&nbsp;persons&nbsp;or&nbsp;entities&nbsp;other&nbsp;than&nbsp;the&nbsp;intended&nbsp;recipient&nbsp;is&nbsp;prohibited.&nbsp;This&nbsp;e-mail&nbsp;and&nbsp;its&nbsp;attachments&nbsp;have&nbsp;been&nbsp;scanned&nbsp;for&nbsp;the&nbsp;presence&nbsp;of&nbsp;computer&nbsp;viruses.&nbsp;It&nbsp;is&nbsp;the&nbsp;responsibility&nbsp;of&nbsp;the&nbsp;recipient&nbsp;to&nbsp;run&nbsp;the&nbsp;virus&nbsp;check&nbsp;on&nbsp;e-mails&nbsp;and&nbsp;attachments&nbsp;before&nbsp;opening&nbsp;them.&nbsp;If&nbsp;you&nbsp;have&nbsp;received&nbsp;this&nbsp;e-mail&nbsp;in&nbsp;error,&nbsp;kindly&nbsp;delete&nbsp;this&nbsp;e-mail&nbsp;from&nbsp;desktop&nbsp;and&nbsp;server.<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
</td></tr></table></body>

</html>