<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:st1="urn:schemas-microsoft-com:office:smarttags" 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 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="country-region"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="place"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="Street"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="address"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:Calibri;
        color:navy;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
 /* List Definitions */
 @list l0
        {mso-list-id:217590752;
        mso-list-type:hybrid;
        mso-list-template-ids:-628298830 -2091994846 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-tab-stop:.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:11.0pt;
        font-family:Calibri;
        color:navy;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
-->
</style>

</head>

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

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>Hi,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>Thanks for the reply..<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>--The sequential option is set to <b><i><span
style='font-weight:bold;font-style:italic'>false</span></i><o:p></o:p></b></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>--Using&nbsp; <i><span style='font-style:
italic'>StatelessKnowledgeSession<o:p></o:p></span></i></span></font></p>

<p class=MsoNormal><i><font size=2 color=navy face=Calibri><span
style='font-size:11.0pt;font-family:Calibri;color:navy;font-style:italic'><o:p>&nbsp;</o:p></span></font></i></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>Summary what I intend to achieve,<o:p></o:p></span></font></p>

<ol style='margin-top:0in' start=1 type=1>
 <li class=MsoNormal style='mso-list:l0 level1 lfo1'><font size=2 color=navy
     face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>In
     first rule, I am doing calculation on three different columns and putting it
     in </span></font><b><i><span style='font-weight:bold;font-style:italic'>sumOfThree</span></i>
     </b>property of ActualSum and inserting it in WM. Let say I have four
     facts.<o:p></o:p></li>
 <li class=MsoNormal style='color:navy;mso-list:l0 level1 lfo1'><font size=2
     color=navy face=Calibri><span style='font-size:11.0pt;font-family:Calibri'>In
     Second Rule, I am inserting distinct audit trail in DistinctAT. Lets say I
     have two distinct AT.<o:p></o:p></span></font></li>
 <li class=MsoNormal style='color:navy;mso-list:l0 level1 lfo1'><font size=2
     color=navy face=Calibri><span style='font-size:11.0pt;font-family:Calibri'>In
     Third Rule, I am assuming 4 Facts of ActualSum and 2 Facts of DistinctAT
     already available in WM. Now I want to get sum of sumOfThree group by AT,
     which I am trying to get using Accumulate function.<o:p></o:p></span></font></li>
</ol>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><b><i><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy;
font-weight:bold;font-style:italic'>OutPut I am getting:<o:p></o:p></span></font></i></b></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>AT
:1001<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>Done!<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>Done
Main Rule, total :-40.0<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>AT
:1000<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>Done!<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>Done
Main Rule, total :210.0<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>AT
:1000<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>Done
Main Rule, total :160.0<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>AT
:1000<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>Done
Main Rule, total :260.0<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>INFO:
Number of generated exceptions &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>Here I see the last rule is getting
fired every time ActualSum fact is inserted in first rule. And as the facts are
available one by one, these are available to Accumulate function used in third
Rule. Actually I am expecting only two exceptions one for AT:1001 and AT:1000
with total of -40 and 260 resp.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>Please advise.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>P.S.&nbsp; Please ignore &#8220;</span></font>$lfna_SEI
and $r_SE<font size=2 color=navy face=Calibri><span style='font-size:11.0pt;
font-family:Calibri;color:navy'>&#8221;. And I am not modifying any facts in
any of the rules consequence (just insertion).<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>Thanks,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>Ritesh<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div>

<div>

<p class=MsoNormal><st1:PersonName w:st="on"><font size=3 color=navy
 face=Calibri><span style='font-size:12.0pt;font-family:Calibri;color:navy'>Ritesh
 Khot</span></font></st1:PersonName><font color=navy face=Calibri><span
style='font-family:Calibri;color:navy'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=navy face=Calibri><span style='font-size:
12.0pt;font-family:Calibri;color:navy'>SunGard Technology Services, Lohia Jain,
<st1:Street w:st="on"><st1:address w:st="on">S.B.&nbsp;Road</st1:address></st1:Street>,
Pune &#8211; 411016, <st1:country-region w:st="on"><st1:place w:st="on">India</st1:place></st1:country-region>
<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=navy face=Calibri><span style='font-size:
12.0pt;font-family:Calibri;color:navy'>Direct Tel: +91-20-3021&nbsp;6084&nbsp;*
Cell: +91- 9850960259 *&nbsp;</span></font><font color=navy><span
style='color:navy'><a href="mailto:ritesh.khot@sungard.com"><font face=Calibri><span
style='font-family:Calibri'>ritesh.khot@sungard.com</span></font></a></span></font><font
color=navy face=Calibri><span style='font-family:Calibri;color:navy'> * </span></font><font
color=navy><span style='color:navy'><a href="http://www.sungard.com/sts"
title="http://www.sungard.com/sts&#10;http://www.sungard.com/"><font
face=Calibri><span style='font-family:Calibri'>www.sungard.com/sts</span></font></a><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
10.0pt;font-family:Calibri;color:navy'>______________________________________________________________________<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
10.0pt;font-family:Calibri;color:navy'>CONFIDENTIALITY: This email (including
any attachments) may contain confidential, proprietary and privileged
information, and unauthorized disclosure or use is prohibited. If you received
this email in error, please notify the sender and delete this email from your
system. Thank you.</span></font><font size=2 face=Calibri><span
style='font-size:10.0pt;font-family:Calibri'><o:p></o:p></span></font></p>

</div>

</div>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b><span style='font-weight:bold'>On
Behalf Of </span></b>Wolfgang Laun<br>
<b><span style='font-weight:bold'>Sent:</span></b> Friday, September 17, 2010
1:00 PM<br>
<b><span style='font-weight:bold'>To:</span></b> Rules Users List<br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [rules-users] How to
activate/deactivate a rule.</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>I think this overly
complex (unless other things have to be considered as well.<br>
<br>
As I interpret these three rules, it is required to compute the sum<br>
of all values ABC.C with equal ABC.A<br>
<br>
declare DistinctAT<br>
&nbsp; &nbsp; d_auditT : String<br>
&nbsp;&nbsp;&nbsp; d_sum: Double<br>
end<br>
<br>
rule &quot;create DistinctAT on first ABC&quot;<br>
when<br>
&nbsp;&nbsp;&nbsp; ABC( $a:A )<br>
&nbsp;&nbsp;&nbsp; not DistinctAT( d_auditT == $a )<br>
then<br>
&nbsp;&nbsp;&nbsp; DistinctAT $disAT = new DistinctAT();<br>
&nbsp; &nbsp; $disAT.setD_auditT($AT);<br>
&nbsp;&nbsp;&nbsp; insert( $disAT );<br>
end<br>
<br>
rule &quot;update d_sum in DistinctAT&quot;<br>
when<br>
&nbsp;&nbsp;&nbsp; $disAT: DistinctAT( $a: d_auditT )<br>
&nbsp;&nbsp;&nbsp; ABC( A == $a, $c:C )<br>
then<br>
&nbsp;&nbsp;&nbsp; $disAT.setD_sum( $disAT.getD_sum() + $c*0.13 );<br>
end<br>
<br>
Notice that I do not update/modify $disAT in the second rule since this would
cause a loop.<br>
If you need the update to fire other rules, add &quot;no-loop true&quot;.<br>
<br>
To get all results, you can use a query; run it after all ABCs have been
inserted.<br>
<br>
-W<br>
<br>
<o:p></o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>On 17 September 2010 08:35, Ritesh &lt;<a
href="mailto:ritesh.khot@sungard.com">ritesh.khot@sungard.com</a>&gt; wrote:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br>
Hi,<br>
<br>
I have 3 rules in my drl file and want the last one should get fired only<br>
after all the facts in rule1 and rule2 gets inserted in working memory.<br>
Please see below code for more understanding. Please suggest.<br>
<br>
Thanks<br>
<br>
declare DistinctAT<br>
&nbsp; &nbsp; d_auditT : String<br>
end<br>
<br>
declare ActualSum<br>
&nbsp; &nbsp; auditT : String<br>
&nbsp; &nbsp; sumOfThree : BigDecimal<br>
end<br>
<br>
rule &quot;insert combined sum&quot;<br>
&nbsp; &nbsp; &nbsp; &nbsp;dialect 'java'<br>
when<br>
&nbsp; &nbsp;ABC( $a:A, $b:B, $c:C )<br>
<br>
then<br>
&nbsp; &nbsp; &nbsp; &nbsp;BigDecimal actSum = $c.multiply(0.13);<br>
&nbsp; &nbsp; &nbsp; &nbsp;ActualSum $as = new ActualSum();<br>
&nbsp; &nbsp; &nbsp; &nbsp;$as.setAuditT($a);<br>
&nbsp; &nbsp; &nbsp; &nbsp;$as.setSumOfThree(actSum);<br>
&nbsp; &nbsp; &nbsp; &nbsp;insert($as);<br>
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;AT :&quot; + $movAuditT);<br>
end<br>
<br>
rule &quot;insert distinct AT&quot;<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp;dialect 'java'<br>
when<br>
&nbsp; &nbsp;$a : ActualSum( $AT : auditT )<br>
&nbsp; &nbsp; &nbsp; &nbsp;not DistinctAT( d_auditT == $AT )<br>
then<br>
&nbsp; &nbsp; &nbsp; &nbsp;DistinctAT $disAT = new DistinctAT();<br>
&nbsp; &nbsp; &nbsp; &nbsp;$disAT.setD_auditT($AT);<br>
&nbsp; &nbsp; &nbsp; &nbsp;insert($disAT);<br>
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;Done!&quot;);<br>
end<br>
<br>
rule &quot;Get Sum Group by AT&quot;<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp;dialect 'java'<br>
when<br>
<br>
DistinctAT( $dAT: d_auditT )<br>
<br>
$total : Double()<br>
from accumulate( ActualSum( auditT == $dAT, $actSum_Main : sumOfThree ),<br>
sum( $actSum_Main ) )<br>
<br>
eval(<br>
&nbsp; &nbsp; &nbsp; &nbsp;chkRuleExpre( $total,$lfna_SEI,$r_SEI )<br>
)<br>
<br>
then<br>
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;Done Main Rule, total
:&quot; + $total);<br>
end<br>
<font color="#888888"><span style='color:#888888'><br>
--<br>
View this message in context: <a
href="http://drools-java-rules-engine.46999.n3.nabble.com/How-to-activate-deactivate-a-rule-tp1516088p1516088.html"
target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/How-to-activate-deactivate-a-rule-tp1516088p1516088.html</a><br>
Sent from the Drools - User mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a></span></font><o:p></o:p></span></font></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

</body>

</html>