<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<STYLE>.hmmessage P {
        PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px
}
BODY.hmmessage {
        FONT-SIZE: 10pt; FONT-FAMILY: Tahoma
}
</STYLE>

<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY class=hmmessage>
<DIV dir=ltr align=left><SPAN class=705370209-13032008><FONT face=Arial 
color=#0000ff>I think you misunderstand how rules work.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=705370209-13032008><FONT face=Arial 
color=#0000ff></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=705370209-13032008><FONT face=Arial 
color=#0000ff>All Facts inserted into working memory will be compared to all 
patterns in all rules; and where a match is found an activation recorded (i.e. 
LHS runs).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=705370209-13032008><FONT face=Arial 
color=#0000ff></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=705370209-13032008><FONT face=Arial 
color=#0000ff>So the following would group all products of type (if you insert 
DelieveryList's into WM and set the type for each list you only need the one 
rule):-</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=705370209-13032008></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=705370209-13032008><FONT face="Courier New" 
color=#0000ff>rule"group by type"<BR>when<BR></FONT></SPAN><SPAN 
class=705370209-13032008><FONT face="Courier New" 
color=#0000ff>&nbsp;&nbsp;&nbsp; $d : DelieveryList ( $t&nbsp;: 
productType&nbsp;)&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp; $p : Product( 
type ==&nbsp;$t )&nbsp;&nbsp; </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=705370209-13032008><FONT 
face="Courier New"><FONT color=#0000ff>then<BR>&nbsp;&nbsp;&nbsp; 
$d.add($p)<BR>end<BR></FONT></DIV></FONT></SPAN>
<DIV dir=ltr align=left><SPAN class=705370209-13032008><FONT face=Arial 
color=#0000ff>You don't need to "iterate" with rules; simply add all the objects 
to WM.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=705370209-13032008><FONT face=Arial 
color=#0000ff></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=705370209-13032008><FONT face=Arial 
color=#0000ff>Cheers,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=705370209-13032008><FONT face=Arial 
color=#0000ff></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=705370209-13032008><FONT face=Arial 
color=#0000ff>Mike</FONT></SPAN></DIV><FONT face=Arial 
color=#0000ff></FONT><FONT face=Arial color=#0000ff></FONT><BR>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
  <HR tabIndex=-1>
  <FONT face=Tahoma><B>From:</B> KinG CD [mailto:kingcd8@hotmail.com] 
  <BR><B>Sent:</B> 12 March 2008 19:07<BR><B>To:</B> Anstis, Michael 
  (M.)<BR><B>Subject:</B> RE: Can I use drools to solve my 
  problem?<BR></FONT><BR></DIV>
  <DIV></DIV>Actually I was able to get near to that, but thank you very much, 
  it cleared my mind.&nbsp;My problem still is to&nbsp;group things. So I 
  have&nbsp;a list of products and I want to group them by type. So I want to 
  create N lists for N types,&nbsp;each list with every product &nbsp;of a 
  certain 
  type.<BR>&nbsp;<BR>e.g<BR>&nbsp;<BR>Product<BR>-type<BR>-name<BR>-id<BR>&nbsp;<BR>=======<BR>&nbsp;<BR>productList{product1, 
  product2, product3,...,productN}<BR>&nbsp;<BR>I want a rule that 
  <BR>&nbsp;<BR>rule"group by type"<BR>&nbsp;&nbsp; 
  when<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iterate the List and generate a 
  productListbyType grouping all products of typeN<BR>&nbsp;&nbsp; 
  then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  deliveryList.add(productListbyType)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; remove 
  each product from the main List(i dont think i really nedd 
  that)<BR>end<BR>&nbsp;<BR>and loop in that rule until list is 'cleared'(all 
  products have been sent to their right lists.<BR>&nbsp;<BR>sorry for bothering 
  you, but i really searched for that and did not found. I could iterate the 
  list with the from collect bu i dont know how to use an "abstract" type, how 
  to iterate for all kind of types. we can have N types.<BR>&nbsp;<BR>thank you 
  very much.<BR>
  <BLOCKQUOTE>
    <HR>
    Subject: RE: Can I use drools to solve my problem?<BR>Date: Mon, 10 Mar 2008 
    10:21:45 +0000<BR>From: manstis1@ford.com<BR>To: 
    rules-users@lists.jboss.org<BR>CC: kingcd8@hotmail.com<BR><BR>
    <META content="Microsoft SafeHTML" name=Generator>
    <STYLE>.ExternalClass .EC_hmmessage P {
        PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px
}
.ExternalClass EC_BODY.hmmessage {
        FONT-SIZE: 10pt; FONT-FAMILY: Tahoma
}
</STYLE>

    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT face=Arial 
    color=#0000ff>In my opinion it will be much easier if you insert individual 
    Orders and Products</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT face=Arial 
    color=#0000ff></FONT></SPAN>&nbsp;</DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT face=Arial 
    color=#0000ff>Here's a hurriedly put together example to help you think in 
    terms of rules (I have no experience of your problem domain so this might be 
    laughably wrong):-</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT face=Arial 
    color=#0000ff></FONT></SPAN>&nbsp;</DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New" color=#0000ff>Global ArrayList 
    branch1;</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New" color=#0000ff></FONT></SPAN>&nbsp;</DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New" color=#0000ff>rule "Delievery split - Branch 
    1"</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New">&nbsp;&nbsp;&nbsp; <FONT 
    color=#0000ff>when</FONT></FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT 
    color=#0000ff>$p : Product( $b : branch =&nbsp;"Branch 
    1"&nbsp;)</FONT></FONT></SPAN></DIV><FONT 
    face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT 
    color=#0000ff>$o : Order( products contains $p )</FONT></FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New">&nbsp;&nbsp;&nbsp; <FONT 
    color=#0000ff>then</FONT></FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT 
    color=#0000ff>OrderDelievery od = new OrderDelievery($o, $p, 
    $b);</FONT></FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT 
    color=#0000ff>insert(od);</FONT></FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New">&nbsp;&nbsp;&nbsp; <FONT 
    color=#0000ff>end</FONT></FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New" color=#0000ff></FONT></SPAN>&nbsp;</DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New" color=#0000ff>rule "Consolidate 
    delieveries"</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New">&nbsp;&nbsp;&nbsp; <FONT 
    color=#0000ff>when</FONT></FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT 
    color=#0000ff>$od : OrderDelievery( branch = "Branch 1" 
    )</FONT></FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New">&nbsp;&nbsp;&nbsp; <FONT 
    color=#0000ff>then</FONT></FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT 
    color=#0000ff>branch1.add($od);</FONT></FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT 
    face="Courier New">&nbsp;&nbsp;&nbsp; <FONT 
    color=#0000ff>end</FONT></FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT face=Arial 
    color=#0000ff></FONT></SPAN>&nbsp;</DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT face=Arial 
    color=#0000ff>Or you could just retrieve the OrderDelievery objects from WM 
    at the end.</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT face=Arial 
    color=#0000ff></FONT></SPAN>&nbsp;</DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT face=Arial 
    color=#0000ff>Drools can definately achieve what you want. If you can solve 
    the problem with hard-coded rules you can solve it with 
    Drools.</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT face=Arial 
    color=#0000ff></FONT></SPAN>&nbsp;</DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT face=Arial 
    color=#0000ff>Good luck,</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT face=Arial 
    color=#0000ff></FONT></SPAN>&nbsp;</DIV>
    <DIV dir=ltr align=left><SPAN class=EC_487141210-10032008><FONT face=Arial 
    color=#0000ff>Mike</FONT></SPAN><SPAN 
    class=EC_487141210-10032008>&nbsp;&nbsp;&nbsp; </SPAN></DIV><BR>
    <BLOCKQUOTE style="MARGIN-RIGHT: 0px">
      <DIV class=EC_OutlookMessageHeader lang=en-us dir=ltr align=left>
      <HR>
      <FONT face=Tahoma><B>From:</B> KinG CD [mailto:kingcd8@hotmail.com] 
      <BR><B>Sent:</B> 07 March 2008 17:08<BR><B>To:</B> Anstis, Michael 
      (M.)<BR><B>Subject:</B> RE: Can I use drools to solve my 
      problem?<BR></FONT><BR></DIV>
      <DIV></DIV>alright. I was trying not to boder you.<BR>&nbsp;<BR>My 
      companie is developing a billing software for a e-commerce site. So we 
      have&nbsp;an Order and we have to transform it into deliveries. So each 
      Order has many products and I have to filter it and define X deliveries(i 
      call it 'delivery split'). There are filters like disponibility(in how 
      many days it will be ok), brach(in what city is the product), type(if it 
      is a kit, ticket...),...<BR>&nbsp;<BR>I tried many&nbsp;ways and i really 
      think that drools isn't the best tool for my problem. The point is that mi 
      boos dont want to use&nbsp;the hard code for define the deliveries. He 
      wats drolls to do everything. So i tried inserting the the order in the 
      WM, and using 'rom' chained with 'collect' i could iterate and set a list 
      based in some rules, but how can i create lists based on the branch. how 
      can i group in Y different lists the Z different products i 
      have.<BR>&nbsp;<BR>I also inserted each product manually&nbsp;and tried to 
      manipulate each one. But the point is that the rules should be 
      interdependent but i was not able to do it.<BR>&nbsp;<BR>the resume is 
      that i want to take the order and set N deliveries based on interdependent 
      rules. i would like to do almost everything with drools not using the hard 
      code.<BR>&nbsp;<BR>Sorry for the English, thanj you very much for the 
      help, i'm&nbsp;a little lost.<BR><BR>ect: FW: Can I use drools to solve my 
      problem?<BR>&gt; Date: Fri, 7 Mar 2008 15:45:22 +0000<BR>&gt; From: 
      manstis1@ford.com<BR>&gt; To: rules-users@lists.jboss.org<BR>&gt; CC: 
      kingcd8@hotmail.com<BR>&gt; <BR>&gt; Posted to forum for a wider 
      audience.<BR>&gt; <BR>&gt; I think you will need to be more specific with 
      your use case.<BR>&gt; <BR>&gt; With kind regards,<BR>&gt; <BR>&gt; 
      Mike<BR>&gt; <BR>&gt; -----Original Message-----<BR>&gt; From: 
      kingcd8@hotmail.com [mailto:kingcd8@hotmail.com] <BR>&gt; Sent: 07 March 
      2008 15:35<BR>&gt; To: Anstis, Michael (M.)<BR>&gt; Subject: Can I use 
      drools to solve my problem?<BR>&gt; <BR>&gt; I have a list of products and 
      want to divide this list in other lists<BR>&gt; applying the rules, than i 
      want to apply the same rules to this new lists.<BR>&gt; So I keep dividing 
      them until no rules are applicable anymore.<BR>&gt; <BR>&gt; Thank 
      you<BR><BR><BR>
      <HR>
      Encontre o que você procura com mais eficiência! Instale já a Barra de 
      Ferramentas com Windows Desktop Search! <A 
      href="http://www.windowslive.com.br/" target=_blank>É GRÁTIS!</A> 
    </BLOCKQUOTE></BLOCKQUOTE><BR>
  <HR>
  Encontre o que você procura com mais eficiência! Instale já a Barra de 
  Ferramentas com Windows Desktop Search! <A 
  href="http://www.windowslive.com.br" target=_new>É GRÁTIS!</A> 
</BLOCKQUOTE></BODY></HTML>