<div>Thanks Vikrant.</div>
<div> </div>
<div>I have one more qurey on 'OR' logical operator for the following scenario:</div>
<div> </div>
<div>I want the the boolen result from parent object which satisfies two different condition sets with child objects. I made the rule which is generated duplicated</div>
<div> </div>
<div>results if both conditions are satisfied. </div>
<div> </div>
<div>rule "test"</div>
<div>when</div>
<div>order: Order</div>
<p>(<br> <br> exists ( condition-1 with child objects)<br> <br> or <br> <br> exists (condition-2 with child objects)</p>
<p>)</p>
<p>then </p>
<p> SOP("order id "+order.getId());</p>
<p>result : </p>
<p> order id 1000</p>
<p> order id 1000</p>
<p> </p>
<p>return the results in twice if both the conditions (cond-1 & cond-2) are satisfied. It just combine <br>both results and behaves like 'union all' instead of 'union' function.</p>
<div><br>Can you help on this?</div>
<div> </div>
<div> </div>
<div>regards,riyaz<br> </div>
<div><span class="gmail_quote">On 9/8/08, <b class="gmail_sendername">Vikrant Yagnick</b> <<a href="mailto:VikrantY@mastek.com">VikrantY@mastek.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div lang="EN-US" vlink="purple" link="blue">
<div>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">My feeling after reading this post is that you need to execute a rule, if some child object exists.</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">I suggest using the Exists Feature in Drools for doing something like that.</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d"> </span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">It would be the same thing if you are writing SQL. If you join a Master Table with child tables you will get as many records as there are child records for each master record.</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d"> </span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">However, if you only want one master record if there are child record, you would need to use the exists statement.</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d"> </span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">Example:</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d"> </span></p>
<p><span class="q">rule "Multiple results set"<br>when <br> <br> order: Order<br></span> exists ( Invoice from order.invoices)</p><span class="q">
<p> then <br> <br> System.out.println("Rule Example (Multiple results set)"+order.getId());<br>end;</p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d"> </span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d"> </span></p></span>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">Cheers,</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">Vikrant </span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d"> </span></p>
<div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; BORDER-LEFT: medium none; PADDING-TOP: 3pt; BORDER-BOTTOM: medium none">
<p><b><span style="FONT-SIZE: 10pt">From:</span></b><span style="FONT-SIZE: 10pt"> <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a> [mailto:<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>] <b>On Behalf Of </b>Mohamed Riyaz<br>
<b>Sent:</b> Monday, September 08, 2008 12:05 PM<br><b>To:</b> <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br><b>Subject:</b> [rules-users] Drools ruturn multiple results based on child objects data length</span></p>
</div>
<div><span class="e" id="q_11c40cf16db6497f_5">
<p> </p>
<div>
<p> </p></div>
<div>
<p>Hi,</p></div>
<div>
<p> </p></div>
<div>
<p>In one-to-many relationship object type, Drools generate multiple results based on child objects data length. ie. No of child records<br>belongs to parent object. I wanted the RHS part should be executed only if conditions imposed<br>
on child object satisfies.</p></div>
<p>I have two facts with 1-* relationship defined in object mapping.</p>
<p>class Invoice{}</p>
<p>class Order{</p>
<p>private Set<Invoice> invoices;</p>
<p>}</p>
<p><strong>I wanted RHS should be executed with only one result irrespective of child records length.</strong></p>
<p>rule "Multiple results set"<br>when <br> <br> order: Order() <br> invoice : Invoice() from order.invoices<br> </p>
<p> then <br> <br> System.out.println("Rule Example (Multiple results set)"+order.getId());<br>end;</p>
<p>Result: <br> Rule Example (Multiple results set)1000<br> Rule Example (Multiple results set)1000</p>
<p><br>Please help me in resolving this issue.</p>
<p>Regards,<br>Riyaz</p>
<p style="MARGIN-BOTTOM: 12pt"> </p>
<table style="BACKGROUND: white" cellpadding="0" border="0">
<tbody>
<tr>
<td style="PADDING-RIGHT: 0.75pt; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; PADDING-TOP: 0.75pt"></td></tr></tbody></table>
<p> </p></span></div></div><br><br>
<table style="COLOR: black" bgcolor="white">
<tbody>
<tr>
<td><br>MASTEK LTD.<br>Mastek in NASSCOM's 'India Top 20' Software Service Exporters List.<br>In the US, we're called MAJESCOMASTEK<br><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br></td></tr></tbody></table></div><br>_______________________________________________<br>rules-users mailing list<br>
<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>