<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    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:<br>
    <br>
    <p class="MsoNormal" style=""><span lang="EN-US">rule "london_guys"</span></p>
    <p class="MsoNormal" style=""><span lang="EN-US">when</span></p>
    <p class="MsoNormal" style=""><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        customer:Customer(town=="London")</span></p>
    <p class="MsoNormal" style=""><span lang="EN-US">then</span></p>
    <p class="MsoNormal" style=""><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        System.out.println(customer.getLname() + " is inhabitant of
        London");</span></p>
    <p class="MsoNormal" style=""><span lang="EN-US">end<br>
        <br>
      </span></p>
    <p class="MsoNormal" style=""><span lang="EN-US">rule "london
        teachers" extends </span><span lang="EN-US">"london_guys"</span></p>
    <p class="MsoNormal" style=""><span lang="EN-US">when</span></p>
    <p class="MsoNormal" style=""><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        Customer(job=="TEACHER") from customer<br>
      </span></p>
    <p class="MsoNormal" style=""><span lang="EN-US">then</span></p>
    <span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      System.out.println(customer.getLname() + " is a teacher");</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 "tag" facts according to what your
    first rules concludes. <br>
    <br>
    <br>
    <br>
    Le 19/10/2010 16:29, Dominik H&uuml;ttner a &eacute;crit&nbsp;:
    <blockquote
      cite="mid:018801cb6f9a$0315acf0$094106d0$@huettner@tiq-solutions.de"
      type="cite">
      <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:"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;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        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;}
span.E-MailFormatvorlage17
        {mso-style-type:personal-reply;
        font-family:"Arial","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@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]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span style="font-size: 11pt; font-family:
            &quot;Arial&quot;,&quot;sans-serif&quot;; color: rgb(31, 73,
            125);" lang="EN-US">Hi Leonardo,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size: 11pt; font-family:
            &quot;Arial&quot;,&quot;sans-serif&quot;; color: rgb(31, 73,
            125);" lang="EN-US">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. <o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size: 11pt; font-family:
            &quot;Arial&quot;,&quot;sans-serif&quot;; color: rgb(31, 73,
            125);" lang="EN-US">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?<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size: 11pt; font-family:
            &quot;Arial&quot;,&quot;sans-serif&quot;; color: rgb(31, 73,
            125);" lang="EN-US"><o:p>&nbsp;</o:p></span></p>
        <p class="MsoNormal"><span style="font-size: 11pt; font-family:
            &quot;Arial&quot;,&quot;sans-serif&quot;; color: rgb(31, 73,
            125);" lang="EN-US">Kind regards,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size: 11pt; font-family:
            &quot;Arial&quot;,&quot;sans-serif&quot;; color: rgb(31, 73,
            125);" lang="EN-US"><o:p>&nbsp;</o:p></span></p>
        <p class="MsoNormal"><span style="font-size: 11pt; font-family:
            &quot;Arial&quot;,&quot;sans-serif&quot;; color: rgb(31, 73,
            125);" lang="EN-US">Dominik<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size: 11pt; font-family:
            &quot;Arial&quot;,&quot;sans-serif&quot;; color: rgb(31, 73,
            125);" lang="EN-US"><o:p>&nbsp;</o:p></span></p>
        <p class="MsoNormal"><span style="font-size: 11pt; font-family:
            &quot;Arial&quot;,&quot;sans-serif&quot;; color: rgb(31, 73,
            125);" lang="EN-US"><o:p>&nbsp;</o:p></span></p>
        <p class="MsoNormal"><span style="font-size: 11pt; font-family:
            &quot;Arial&quot;,&quot;sans-serif&quot;; color: rgb(31, 73,
            125);" lang="EN-US"><o:p>&nbsp;</o:p></span></p>
        <div style="border-right: medium none; border-width: 1pt medium
          medium; border-style: solid none none; border-color: rgb(181,
          196, 223) -moz-use-text-color -moz-use-text-color; padding:
          3pt 0cm 0cm;">
          <p class="MsoNormal"><b><span style="font-size: 10pt;
                font-family: &quot;Tahoma&quot;,&quot;sans-serif&quot;;">Von:</span></b><span
              style="font-size: 10pt; font-family:
              &quot;Tahoma&quot;,&quot;sans-serif&quot;;">
              <a class="moz-txt-link-abbreviated" href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>
              [<a class="moz-txt-link-freetext" 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.<o:p></o:p></span></p>
        </div>
        <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
        <p class="MsoNormal" style="margin-bottom: 12pt;">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
            moz-do-not-send="true"
            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" style=""><span lang="EN-US">Rule1:</span><o:p></o:p></p>
        <p class="MsoNormal" style=""><span lang="EN-US">when</span><o:p></o:p></p>
        <p class="MsoNormal" style=""><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            customer:Customer(town=="London")</span><o:p></o:p></p>
        <p class="MsoNormal" style=""><span lang="EN-US">then</span><o:p></o:p></p>
        <p class="MsoNormal" style=""><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" style=""><span lang="EN-US">&nbsp;</span><o:p></o:p></p>
        <p class="MsoNormal" style=""><span lang="EN-US">Rule2:</span><o:p></o:p></p>
        <p class="MsoNormal" style=""><span lang="EN-US">when</span><o:p></o:p></p>
        <p class="MsoNormal" style=""><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            london : LondonCustomer(customer.job=="TEACHER")</span><o:p></o:p></p>
        <p class="MsoNormal" style=""><span lang="EN-US">then</span><o:p></o:p></p>
        <p class="MsoNormal" style=""><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            System.out.println(london.customer.getLname() + " is a
            teacher");</span><o:p></o:p></p>
        <p class="MsoNormal" style="margin-bottom: 12pt;"><o:p>&nbsp;</o:p></p>
        <div>
          <p class="MsoNormal">2010/10/12 Dominik H&uuml;ttner &lt;<a
              moz-do-not-send="true"
              href="mailto:d.huettner@tiq-solutions.de">d.huettner@tiq-solutions.de</a>&gt;<o:p></o:p></p>
          <div>
            <div>
              <p class="MsoNormal" style=""><span lang="EN-US">Hello
                  everyone,</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><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" style=""><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" style=""><span lang="EN-US">&nbsp;</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><span lang="EN-US">Here is
                  an example for what I intend to do:</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><span lang="EN-US">&nbsp;</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><span lang="EN-US">Rule1:</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><span lang="EN-US">when</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  customer:Customer(town=="London")</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><span lang="EN-US">then</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
System.out.println(customer.getLname()
                  + " is inhabitant of London");</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><span lang="EN-US">&nbsp;</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><span lang="EN-US">Rule2:</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><span lang="EN-US">when</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  customer:Customer(town=="London",job=="TEACHER")</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><span lang="EN-US">then</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
System.out.println(customer.getLname()
                  + " is a teacher");</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><span lang="EN-US">&nbsp;</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><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" style=""><span lang="EN-US">&nbsp;</span><o:p></o:p></p>
              <p class="MsoNormal" style=""><span lang="EN-US">Greetings,
                  Dominik</span><o:p></o:p></p>
            </div>
          </div>
          <p class="MsoNormal" style="margin-bottom: 12pt;"><br>
            _______________________________________________<br>
            rules-users mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
            <a moz-do-not-send="true"
              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"><o:p>&nbsp;</o:p></p>
      </div>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
    </blockquote>
    <br>
    <br>
    <div class="moz-signature">-- <br>
      <span style="font-size: 13.5pt; font-family:
        &quot;Arial&quot;,&quot;sans-serif&quot;; color: rgb(21, 24,
        90);">Vincent LEGENDRE</span><br>
      <i><span style="font-size: 8.5pt; font-family:
          &quot;Arial&quot;,&quot;sans-serif&quot;; color: rgb(21, 24,
          90);">Consultant S&eacute;nior</span></i><br>
      <span style="font-size: 4.5pt;"> <br>
      </span>
      <span style="font-size: 9pt; font-family:
        &quot;Arial&quot;,&quot;sans-serif&quot;; color: rgb(21, 24,
        90);">EURODECISION</span><br>
      <span style="font-size: 9pt; font-family:
        &quot;Arial&quot;,&quot;sans-serif&quot;; color: rgb(21, 24,
        90);">9A rue de la Porte de Buc 78000 VERSAILLES<br>
        T&eacute;l. : +33 (0)1 39 07 12 40<br>
        Direct : +33 (0)1 39 07 26 16<br>
        <a>www.eurodecision.com</a></span><br>
      <a href="http://www.eurodecision.com/"><span style="font-size:
          12pt; font-family: &quot;Times New
          Roman&quot;,&quot;serif&quot;; color: windowtext;
          text-decoration: none;"> <img
            src="cid:part1.00020300.05060507@eurodecision.com"
            alt="EURODECISION" border="no"></span></a><a
        href="http://www.eurodecision.com/"><span style="font-size:
          12pt; font-family: &quot;Times New
          Roman&quot;,&quot;serif&quot;; color: windowtext;
          text-decoration: none;"> </span></a>
    </div>
  </body>
</html>