<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2>Hi Richard,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2>Glad I can be of help (this forum as a whole is actually 
very helpful).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2>Reading your email you understand me correctly (you even 
picked up on the implicit AND between pattern matches).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2>With a bit of imagination complex problems can be solved 
with Drools; just like programming you need to adjust your mindset sometimes and 
try a different tact.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2>Personally, if your rules are not user-facing, I wouldn't 
worry about DSL - even if they do don't worry for the time 
being!</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2>Make sure to read the excellent manual, many people have 
put a lot of work into this and it is invaluable.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2>Read about "dialect" to answer your question about rule 
language, to save me copy and pasting.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2>Good luck,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=571424310-02052008><FONT face=Arial 
color=#0000ff size=2>Mike</FONT></SPAN></DIV>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
  <HR tabIndex=-1>
  <FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org 
  [mailto:rules-users-bounces@lists.jboss.org] <B>On Behalf Of </B>Richard 
  Bremner<BR><B>Sent:</B> 02 May 2008 11:38<BR><B>To:</B> Rules Users 
  List<BR><B>Subject:</B> Re: [rules-users] newbie question on "when" condition 
  syntax<BR></FONT><BR></DIV>
  <DIV></DIV>Hi Mike,<BR><BR>Thanks very much, after a few minutes of staring I 
  think I have understood your very well put answer!<BR><BR>If I understand you 
  right, what is happening is:<BR><BR><SPAN><FONT face="Courier New" 
  color=#0000ff size=2>Test(&nbsp;$y : y )<BR><BR 
  style="COLOR: rgb(0,0,0)"><SPAN style="COLOR: rgb(0,0,0)">This means, WHEN 
  there is an instance of Test, assign the value of its "y" property to 
  $y</SPAN><BR style="COLOR: rgb(0,0,0)"><BR style="COLOR: rgb(0,0,0)"><SPAN 
  style="COLOR: rgb(0,0,0)">AND</SPAN><BR style="COLOR: rgb(0,0,0)"><BR 
  style="COLOR: rgb(0,0,0)"><SPAN style="COLOR: rgb(0,0,0)">WHEN there is an 
  instance of Test where it's "x" property is equal to $y + 1</SPAN><BR 
  style="COLOR: rgb(0,0,0)"><BR style="COLOR: rgb(0,0,0)"><SPAN 
  style="COLOR: rgb(0,0,0)">THEN fire.</SPAN><BR></FONT></SPAN><BR><BR>I think I 
  understand that. I am going to need to do this with some pretty complicated 
  formulae, containing up to 8 different variables. I have a fixed data set and 
  need to find certain patterns in them based on the formulae. I have most of 
  the program figured out, my only trouble is expressing my formulae in the 
  correct syntax. I will try to extend this principle you have explained to me 
  and hope it can cope with the extra complication... unless there would be a 
  better way to achieve this?<BR><BR>I am really sorry but I am totally new to 
  drools - but am committed to using it on a project so I guess I'm going to get 
  to know it pretty well :-)<BR><BR>I read briefly that one can define a DSL, I 
  might look at this eventually to build an easier mechanism for expressing my 
  formulae - if that can be achieved using a DSL.<BR><BR>Can the whole rule be 
  defined in Groovy/Java - if so I might be easier doing that. I have so much 
  work to do!<BR><BR><BR>many thanks<BR><BR>Richard<BR><BR><BR><BR>
  <DIV class=gmail_quote>2008/5/2 Anstis, Michael (M.) &lt;<A 
  href="mailto:manstis1@ford.com">manstis1@ford.com</A>&gt;:<BR>
  <BLOCKQUOTE class=gmail_quote 
  style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
    <DIV>
    <DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>Hi 
    Richard,</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 
    size=2></FONT></SPAN>&nbsp;</DIV>
    <DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>The 
    "when" section matches fact (object) patterns, so your requirement could be 
    written as:-</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 
    size=2></FONT></SPAN>&nbsp;</DIV>
    <DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff 
    size=2>when there is a Test Fact 'A' and another Test Fact 'B' where "the 
    'x' property of&nbsp;'A'" equals "the 'y' property of&nbsp;fact 'B' plus 
    1"&nbsp;then.....</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff 
    size=2></FONT></SPAN>&nbsp;</DIV>
    <DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>This 
    would become:-</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 
    size=2></FONT></SPAN>&nbsp;</DIV>
    <DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff 
    size=2>rule "Rule 1"</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff 
    size=2>when</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff 
    size=2>&nbsp;&nbsp;&nbsp;&nbsp;Test(&nbsp;$y : y )</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff 
    size=2>&nbsp;&nbsp;&nbsp;&nbsp;Test(&nbsp;x == ($y + 1) 
)</FONT></SPAN></DIV>
    <DIV class=Ih2E3d>
    <DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff 
    size=2>then</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN><FONT face="Courier New">&nbsp;&nbsp;&nbsp; 
    <FONT color=#0000ff size=2>System.out.println("Rule 1 
    matches");</FONT></FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff 
    size=2>end</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 
    size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT></SPAN></DIV></DIV>
    <DIV><SPAN></SPAN><FONT face=Arial><FONT color=#0000ff><FONT 
    size=2>By&nbsp;default&nbsp;both&nbsp;patterns&nbsp;can&nbsp;match&nbsp;the&nbsp;same&nbsp;object,&nbsp;so&nbsp;test&nbsp;data:-</FONT></FONT></FONT></DIV>
    <DIV><FONT face=Arial><FONT color=#0000ff><FONT 
    size=2></FONT></FONT></FONT>&nbsp;</DIV>
    <DIV><FONT size=+0><FONT size=+0><FONT face="Courier New" color=#0000ff 
    size=2><SPAN>A : x = 1, y = 1</SPAN></FONT></FONT></FONT></DIV>
    <DIV><FONT size=+0><FONT size=+0><FONT face="Courier New" color=#0000ff 
    size=2><SPAN>B : x = 2, y = 1</SPAN></FONT></FONT></FONT></DIV>
    <DIV><FONT size=+0><FONT size=+0><FONT face=Arial color=#0000ff 
    size=2><SPAN></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
    <DIV><FONT size=+0><FONT size=+0><FONT face=Arial color=#0000ff 
    size=2><SPAN>Will cause the rule to activate 
    twice:-</SPAN></FONT></FONT></FONT></DIV>
    <DIV><FONT size=+0><FONT size=+0><FONT face=Arial color=#0000ff 
    size=2><SPAN></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
    <DIV><FONT size=+0><FONT size=+0><FONT face="Courier New" color=#0000ff 
    size=2><SPAN>A and B</SPAN></FONT></FONT></FONT></DIV>
    <DIV><FONT size=+0><FONT size=+0><FONT face="Courier New" color=#0000ff 
    size=2><SPAN>B and B</SPAN></FONT></FONT></FONT></DIV>
    <DIV><FONT size=+0><FONT size=+0><FONT face=Arial color=#0000ff 
    size=2><SPAN></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
    <DIV><FONT size=+0><FONT size=+0><FONT face=Arial color=#0000ff 
    size=2><SPAN>With kind regards,</SPAN></FONT></FONT></FONT></DIV>
    <DIV><FONT size=+0><FONT size=+0><FONT face=Arial color=#0000ff 
    size=2><SPAN></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
    <DIV><FONT size=+0><FONT size=+0><FONT face=Arial color=#0000ff 
    size=2><SPAN>Mike</SPAN></FONT></FONT></FONT></DIV>
    <DIV><FONT face=Arial color=#0000ff size=2></FONT><BR></DIV>
    <BLOCKQUOTE style="MARGIN-RIGHT: 0px">
      <DIV lang=en-us dir=ltr align=left>
      <HR>
      <FONT face=Tahoma size=2><B>From:</B> <A 
      href="mailto:rules-users-bounces@lists.jboss.org" 
      target=_blank>rules-users-bounces@lists.jboss.org</A> [mailto:<A 
      href="mailto:rules-users-bounces@lists.jboss.org" 
      target=_blank>rules-users-bounces@lists.jboss.org</A>] <B>On Behalf Of 
      </B>Richard Bremner<BR><B>Sent:</B> 02 May 2008 08:53<BR><B>To:</B> <A 
      href="mailto:rules-users@lists.jboss.org" 
      target=_blank>rules-users@lists.jboss.org</A><BR><B>Subject:</B> 
      [rules-users] newbie question on "when" condition 
      syntax<BR></FONT><BR></DIV>
      <DIV>
      <DIV></DIV>
      <DIV class=Wj3C7c>
      <DIV></DIV>Hi, <BR><BR>say I have a class with two fields, x and y: 
      <BR><BR>public class Test { <BR>&nbsp; &nbsp; int x = 1; <BR>&nbsp; &nbsp; 
      int y = 2; <BR><BR>&nbsp; &nbsp; getters/setters... <BR>} <BR><BR><BR>I 
      would like a rule which fires when y = x + 1 <BR><BR>my initial thought 
      would be something like: <BR><BR>rule "Rule 1" <BR>&nbsp; &nbsp; &nbsp; 
      &nbsp; <BR>&nbsp; &nbsp; &nbsp; &nbsp; when <BR>&nbsp; &nbsp; &nbsp; 
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; test : Test (y == x + 1) <BR>&nbsp; 
      &nbsp; &nbsp; &nbsp; then <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
      &nbsp; &nbsp; System.out.println("Rule 1 matches."); <BR>&nbsp; &nbsp; 
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR>end <BR><BR><BR>but this is 
      invalid syntax and I can not find any examples of such a rule. I'm doing 
      my best but reading the manual etc. I'm struggling with the syntax here 
      and can't figure it out.<BR><BR>any help really appreciated! 
    </DIV></DIV></BLOCKQUOTE></DIV><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><BR><BR></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>