<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>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 12 (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]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@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:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
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;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Vorformatiert Zchn";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.E-MailFormatvorlage17
        {mso-style-type:personal;
        font-family:"Arial","sans-serif";
        color:#1F497D;}
span.HTMLVorformatiertZchn
        {mso-style-name:"HTML Vorformatiert Zchn";
        mso-style-priority:99;
        mso-style-link:"HTML Vorformatiert";
        font-family:Consolas;
        color:black;}
span.E-MailFormatvorlage20
        {mso-style-type:personal-reply;
        font-family:"Arial","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
-->
</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 bgcolor=white lang=DE link=blue vlink=purple>

<div class=WordSection1>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Arial","sans-serif";
color:#1F497D'>Thanks for this advice, that&#8217;s exactly what I&#8217;m looking
for, and if I want to use it in the guvnor, is it planned to realize this also
there or can it be done unde Other meta data -&gt; type? I use guvnor version
5.0.<o:p></o:p></span></p>

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

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Arial","sans-serif";
color:#1F497D'>Regards,<o:p></o:p></span></p>

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

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Arial","sans-serif";
color:#1F497D'>Dominik<o:p></o:p></span></p>

<div>

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

</div>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Arial","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 0cm 0cm 0cm'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";
color:windowtext'>Von:</span></b><span style='font-size:10.0pt;font-family:
"Tahoma","sans-serif";color:windowtext'> Vincent Legendre
[mailto:vincent.legendre@eurodecision.com] <br>
<b>Gesendet:</b> Dienstag, 19. Oktober 2010 17:27<br>
<b>An:</b> Rules Users List<br>
<b>Cc:</b> Dominik Hüttner; leonardo.f.gomes@gmail.com<br>
<b>Betreff:</b> Re: [rules-users] Get rid of redundant conditions in combined
rules.<o:p></o:p></span></p>

</div>

</div>

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

<p class=MsoNormal style='margin-bottom:12.0pt'>There is something in 5.x which
allow a rule to inherit from another. Inheritance is on parent rule conditions.<br>
<br>
May be you could write something like this:<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US>rule &quot;london_guys&quot;</span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US>when</span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
customer:Customer(town==&quot;London&quot;)</span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US>then</span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
System.out.println(customer.getLname() + &quot; is inhabitant of London&quot;);</span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'><span
lang=EN-US>end</span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US>rule &quot;london teachers&quot; extends &quot;london_guys&quot;</span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US>when</span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Customer(job==&quot;TEACHER&quot;) from customer</span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US>then</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
System.out.println(customer.getLname() + &quot; is a teacher&quot;);</span><br>
end<br>
<br>
BUT ... <br>
&nbsp;&nbsp;&nbsp; 1 - As you can see you cannot inject a new contraint in a
'parent' pattern. So you have to use first variable as a source for the second
pattern ...<br>
&nbsp;&nbsp;&nbsp; 2 - Bindings in parent rule only works in 5.1 version (may
be only in trunk), so be careful<br>
<br>
<br>
To conclude, try to check (<a href="https://jira.jboss.org/browse/JBRULES-1812">here</a>,
for a sample, that may not work, this functionnality is not documented yet),
but I think leonardo's solution is best. May be you can adapt it to avoid
create new classes, but you could use an additional field in your actual class
to &quot;tag&quot; facts according to what your first rules concludes. <br>
<br>
<br>
<br>
Le 19/10/2010 16:29, Dominik Hüttner a écrit&nbsp;: <o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Arial","sans-serif"'>Hi
Leonardo,</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Arial","sans-serif"'>the
performance problem I thought of meant removing and inserting the facts again
and again, if I would remove the facts, that don&#8217;t fit the first rule and
execute the second rule only on the remaining facts. </span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Arial","sans-serif"'>The
solution you offered, does, what I intend, but the problem is, that I have to
create a new class for every rule-pair and I want to use it flexible, without
having to create a new class / model for every rule. Is there maybe another way
to solve this problem?</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Arial","sans-serif"'>&nbsp;</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Arial","sans-serif"'>Kind
regards,</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Arial","sans-serif"'>&nbsp;</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Arial","sans-serif"'>Dominik</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Arial","sans-serif"'>&nbsp;</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Arial","sans-serif"'>&nbsp;</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Arial","sans-serif"'>&nbsp;</span><o:p></o:p></p>

<div style='border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0cm 0cm 0cm;
border-color:rgb(181,&#13;&#10;          196, 223) -moz-use-text-color -moz-use-text-color'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>Von:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> <a
href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>
[<a href="mailto:rules-users-bounces@lists.jboss.org">mailto:rules-users-bounces@lists.jboss.org</a>]
<b>Im Auftrag von </b>Leonardo Gomes<br>
<b>Gesendet:</b> Dienstag, 12. Oktober 2010 16:37<br>
<b>An:</b> Rules Users List<br>
<b>Betreff:</b> Re: [rules-users] Get rid of redundant conditions in combined
rules.</span><o:p></o:p></p>

</div>

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

<p class=MsoNormal style='margin-bottom:12.0pt'>If your problem is performance,
don't worry. Conditions evaluation is shared, so in the second rule you won't
re-evaluate the entire working memory (to know more:<a
href="http://www.drdobbs.com/184405218">http://www.drdobbs.com/184405218</a>).<br>
<br>
If you're worried about not having to repeat the conditions on the second rule,
I would create inferred facts when the first rule matches and use then in the
second rule + the additional conditions.<br>
<br>
Something like:<o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>Rule1:</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>when</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
customer:Customer(town==&quot;London&quot;)</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>then</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
insert new LondonCustomer( customer );</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>Rule2:</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>when</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
london : LondonCustomer(customer.job==&quot;TEACHER&quot;)</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>then</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
System.out.println(london.customer.getLname() + &quot; is a teacher&quot;);</span><o:p></o:p></p>

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

<div>

<p class=MsoNormal>2010/10/12 Dominik Hüttner &lt;<a
href="mailto:d.huettner@tiq-solutions.de">d.huettner@tiq-solutions.de</a>&gt;<o:p></o:p></p>

<div>

<div>

<p class=MsoNormal><span lang=EN-US>Hello everyone,</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>I&#8217;ve got a question. I&#8217;m using
drools-guvnor to execute some rule-scenarios. I have to solve the following
problem: I have an amount of objects in my working memory and can&#8217;t
remove objects from the working memory in the then-part of the rule. I want to combine
two rules, the first rule selects some objects and the second rule checks only
these selected objects for additional criteria. I have to use two rules,
because I want to report the objects selected in the first rule, too. Now I
have implemented this with two rules and in the second rule, the criterias of
the first rule are copied to the second rule, my question is, is there a way to
get rid of this redundandance?</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>I have tried this with a rule flow, but the
problem is, this always works on the whole working memory, but I can&#8217;t
remove the not used objects from working memory for performance reasons. Is
there another way to solve this problem?</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>Here is an example for what I intend to do:</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>Rule1:</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>when</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
customer:Customer(town==&quot;London&quot;)</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>then</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
System.out.println(customer.getLname() + &quot; is inhabitant of London&quot;);</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>Rule2:</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>when</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
customer:Customer(town==&quot;London&quot;,job==&quot;TEACHER&quot;)</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>then</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
System.out.println(customer.getLname() + &quot; is a teacher&quot;);</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>This example illustrates, with the first
rule I want to get to know, how many customers are from London and in the
second rule I want to know, how many of the London customers are teachers. I
want to create a kind of statistics. I have quite a lot of conditions for the
first rule, so I don&#8217;t want to have them redundantly.</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>Greetings, Dominik</span><o:p></o:p></p>

</div>

</div>

<p class=MsoNormal style='margin-bottom:12.0pt'><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><o:p></o:p></p>

</div>

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

<pre><o:p>&nbsp;</o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre>_______________________________________________<o:p></o:p></pre><pre>rules-users mailing list<o:p></o:p></pre><pre><a
href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><o:p></o:p></pre><pre><a
href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><o:p></o:p></pre>

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

<div>

<p class=MsoNormal>-- <br>
<span style='font-size:13.5pt;font-family:"Arial","sans-serif"'>Vincent LEGENDRE</span><br>
<i><span style='font-size:8.5pt;font-family:"Arial","sans-serif"'>Consultant
Sénior</span></i><br>
<span style='font-size:4.5pt'><br>
</span><span style='font-size:9.0pt;font-family:"Arial","sans-serif"'>EURODECISION</span><br>
<span style='font-size:9.0pt;font-family:"Arial","sans-serif"'>9A rue de la
Porte de Buc 78000 VERSAILLES<br>
Tél. : +33 (0)1 39 07 12 40<br>
Direct : +33 (0)1 39 07 26 16<br>
www.eurodecision.com</span><br>
<a href="http://www.eurodecision.com/"><span style='text-decoration:none'><img
border=0 width=206 height=66 id="_x0000_i1025"
src="cid:image001.gif@01CB7042.9672F5E0" alt=EURODECISION></span></a><o:p></o:p></p>

</div>

</div>

</body>

</html>