<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:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<HEAD><!-- Template generated by Exclaimer Template Editor on 11:11:44 Thursday, 31 January 2013 -->
<STYLE type=text/css>P.ea4bc237-6ca4-4a5d-bf85-89ba30bee9d7 {
        MARGIN: 0cm 0cm 0pt
}
LI.ea4bc237-6ca4-4a5d-bf85-89ba30bee9d7 {
        MARGIN: 0cm 0cm 0pt
}
DIV.ea4bc237-6ca4-4a5d-bf85-89ba30bee9d7 {
        MARGIN: 0cm 0cm 0pt
}
TABLE.ea4bc237-6ca4-4a5d-bf85-89ba30bee9d7Table {
        MARGIN: 0cm 0cm 0pt
}
DIV.Section1 {
        page: Section1
}
</STYLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Generator" content="Microsoft Word 12 (filtered medium)" />
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@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;}
@font-face
        {font-family:"Lucida Console";
        panose-1:2 11 6 9 4 5 4 2 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";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.2ee1cc27-72fd-41ad-a721-72d082ea8444, li.2ee1cc27-72fd-41ad-a721-72d082ea8444, div.2ee1cc27-72fd-41ad-a721-72d082ea8444
        {mso-style-name:2ee1cc27-72fd-41ad-a721-72d082ea8444;
        mso-style-priority:99;
        margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
span.EmailStyle22
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle23
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:819007338;
        mso-list-type:hybrid;
        mso-list-template-ids:-1067698132 1451284158 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-start-at:16;
        mso-level-number-format:bullet;
        mso-level-text:\F0D8;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;
        mso-fareast-font-family:Calibri;
        mso-bidi-font-family:"Times New Roman";}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></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">
<P>
<div class="WordSection1">
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style=font-size:14.0pt;font-family:Wingdings;color:#1F497D><span style=mso-list:Ignore>Ø<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]>Between those, you should be able to knock up something which does an appropriate audit of what's going on in your rules without refactoring any of your DRL.<span style=font-size:14.0pt;font-family:"Calibri","sans-serif";color:#1F497D><o:p></o:p></span></p>
<p class="MsoNormal"><span style=font-size:14.0pt;font-family:"Calibri","sans-serif";color:#1F497D><o:p> </o:p></span></p>
<p class="MsoNormal"><span style=font-size:14.0pt;font-family:"Calibri","sans-serif";color:#1F497D>Ah. I think I get it.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style=font-size:14.0pt;font-family:"Calibri","sans-serif";color:#1F497D><o:p> </o:p></span></p>
<p class="MsoNormal"><span style=font-size:14.0pt;font-family:"Calibri","sans-serif";color:#1F497D>Based on my understanding of the code you provided, the Listener’s objectInserted() method gets a callback from the DROOLs runtime whenever a KS fact insert
event is processed. I could then use the ObjectInsertedEvent reference (passed by the callback) to do my own accounting/auditing of the fact, including the ability to establish “did this rule fail?” by providing the equivalent of the .DRL L-value logic in
the objectInserted() method’s implementation? If my understanding is correct, I could then get an *<b>exactly</b>* precise answer to “why did this rule fail?” by iterating on the equivalent of each of the .DRL L-value predicate participants and evaluating
“did this specific predicate participant fail to match?”. Very interesting. That would, indeed, effectively unburden the .DRL from any audit/accounting logic – moving the burden to the Listener.<o:p></o:p></span></p>
<p class="MsoNormal"><span style=font-size:14.0pt;font-family:"Calibri","sans-serif";color:#1F497D><o:p> </o:p></span></p>
<p class="MsoNormal"><span style=font-size:14.0pt;font-family:"Calibri","sans-serif";color:#1F497D>Is my understanding close to how you envisioned doing this?<o:p></o:p></span></p>
<p class="MsoNormal"><span style=font-size:14.0pt;font-family:"Calibri","sans-serif";color:#1F497D><o:p> </o:p></span></p>
<p class="MsoNormal"><span style=font-size:14.0pt;font-family:"Calibri","sans-serif";color:#1F497D>Very interesting. Thanks again!<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></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>Stephen Masters<br />
<b>Sent:</b> Thursday, January 31, 2013 4:49 AM<br />
<b>To:</b> Rules Users List<br />
<b>Subject:</b> Re: [rules-users] Non short circuit ANDing<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">fyi - if you're just learning your way around working memory event listeners and the like, here's some example code. It's an extended version of something I found in the Drools docs.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">A tracking working memory event listener:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="https://github.com/gratiartis/sctrcd-fx-web/blob/master/src/main/java/uk/co/scattercode/drools/util/TrackingWorkingMemoryEventListener.java">https://github.com/gratiartis/sctrcd-fx-web/blob/master/src/main/java/uk/co/scattercode/drools/util/TrackingWorkingMemoryEventListener.java</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Attach it to your session to keep track of all facts as they are inserted/updated/retracted. It also supports filtering for fact classes or handles so that you can pick out which ones are relevant.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">A tracking agenda event listener:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="https://github.com/gratiartis/sctrcd-fx-web/blob/master/src/main/java/uk/co/scattercode/drools/util/TrackingAgendaEventListener.java">https://github.com/gratiartis/sctrcd-fx-web/blob/master/src/main/java/uk/co/scattercode/drools/util/TrackingAgendaEventListener.java</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Keeps track of and logs every rule which fires.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I use them in this test helper class, which enables me to create unit tests which assert that specific rules have fired or that specific facts are in working memory.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="https://github.com/gratiartis/sctrcd-fx-web/blob/master/src/main/java/uk/co/scattercode/drools/util/DroolsTestUtil.java">https://github.com/gratiartis/sctrcd-fx-web/blob/master/src/main/java/uk/co/scattercode/drools/util/DroolsTestUtil.java</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Between those, you should be able to knock up something which does an appropriate audit of what's going on in your rules without refactoring any of your DRL. I prefer using listeners like this to monitor what's going on, as they don't intrude
on your code. I tend to think that the rules should be simple and specific to the decision being made, rather than needing them to be written in a specific way in order to achieve some side effects.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Steve<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On 31 Jan 2013, at 00:53, Davide Sottara <<a href="mailto:dsotty@gmail.com">dsotty@gmail.com</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><br />
<br />
<o:p></o:p></p>
<div>
<p class="MsoNormal">Gents, <br />
this is a really interesting discussion and I wish I had more time to participate.. I agree with Stephen that some constraints are really worthy monitoring,
<br />
while others are simply "filters".. Wolfgang's mention of "near misses" is potentially a hot topic, I have been experimenting with "imperfect" rules which<br />
are more robust in that sense and provide better traceability, but that is not yet implemented in the core engine.
<br />
I would also point out that one thing is monitor constraints for "logging" or "auditing" purposes, another is the ability to specify different behaviours<br />
(i.e. consequences) according to the success vs failure of an evaluation. <br />
To this end, and following on the "extending" rule thread, it has actually been planned and partially implemented.. it's only an experimental feature<br />
(@Mario, any update/clarification?), so it's probably not well documented. But I would point you to these links:<br />
<br />
<a href="http://blog.athico.com/2012/09/conditional-branches-with-sub-blocks.html">http://blog.athico.com/2012/09/conditional-branches-with-sub-blocks.html</a><br />
<br />
<a href="https://community.jboss.org/wiki/BranchCEs">https://community.jboss.org/wiki/BranchCEs</a><br />
<br />
with the warning that it's still experimental and, while adopting "familiar" keywords (if, then, else, switch), their semantics is different from the
<br />
usual imperative language one, and in fact could enable some of the "extend" capabilities that have been invoked in the last couple of posts.<br />
<br />
Best<br />
Davide<br />
<br />
<br />
On 01/30/2013 02:25 PM, Cotton, Ben wrote: <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoListParagraph" style=text-indent:-.25in><span style="font-family:"Lucida Console"">automatically rename each rule "part" (being a single-condition rule derived from the original) to some derivation of the original rule name, and need the consequence
only in the fully-extended rule, thereby giving the same effect, but with rule "parts" that would reflect failure at the individual condition level</span><o:p></o:p></p>
<p class="MsoNormal"><span style=font-size:14.0pt;font-family:"Calibri","sans-serif"><br />
<br />
</span><o:p></o:p></p>
<p class="MsoNormal"><span style=font-size:14.0pt;font-family:"Calibri","sans-serif">This is *<b>exactly</b>* the ambition we are hoping that some Drools .DRL enrichment tool (or other Drools capability) can provide.
</span><o:p></o:p></p>
<p class="MsoNormal"><span style=font-size:14.0pt;font-family:"Calibri","sans-serif"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style=font-size:14.0pt;font-family:"Calibri","sans-serif">Wish I had sufficient competency to comment on the merits of your different suggested approaches. Hopeful that the Drools gurus will comment explicitly on all these approaches
(and/or the approach suggested by another of using Working Memory listeners).</span><o:p></o:p></p>
<p class="MsoNormal"><span style=font-size:14.0pt> </span><o:p></o:p></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal">_______________________________________________<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">https://lists.jboss.org/mailman/listinfo/rules-users</a><o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<BR /><BR />
<HR id=HR1 />
<BR /><SPAN style="FONT-FAMILY: Arial; COLOR: #808080; FONT-SIZE: 7.5pt">NOTICE:
Morgan Stanley is not acting as a municipal advisor and the opinions or views
contained herein are not intended to be, and do not constitute, advice within
the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer
Protection Act. If you have received this communication in error, please destroy
all electronic and paper copies and notify the sender immediately.
Mistransmission is not intended to waive confidentiality or privilege. Morgan
Stanley reserves the right, to the extent permitted under applicable law, to
monitor electronic communications. This message is subject to terms available at
the following link: <A style="FONT-FAMILY: Arial; COLOR: #808080; FONT-SIZE: 7.5pt" href="http://www.morganstanley.com/disclaimers">http://www.morganstanley.com/disclaimers</A>
If you cannot access these links, please notify us by reply message and we will
send the contents to you. By messaging with Morgan Stanley you consent to the
foregoing.</SPAN><BR />
<P></P>
<P></P></P></BODY>
</HTML>