<div>Thanks for your reply Greg.</div>
<div> </div>
<div>Actually I have 2 requirements:</div>
<div> </div>
<div>1) Define the data objects in the rule itself so that the business user can define\modify the data objects</div>
<div>2) have a rule that can evalaute the data objects against the criteria the user requests..</div>
<div> </div>
<div>It is my bad I started with the 2nd requirement :(</div>
<div> </div>
<div>Regards,</div>
<div>cabear<br></div>
<div class="gmail_quote">On Wed, Nov 11, 2009 at 1:50 PM, Greg Barton <span dir="ltr">&lt;<a href="mailto:greg_barton@yahoo.com">greg_barton@yahoo.com</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Funny you should bring that up, I was just having this debate with a co-worker. :)<br><br>A decision table is a means for defining rules, not working memory objects.  So no, out of the box a decision table as it&#39;s defined in drools (and other rule management systems) would not serve that purpose.  However, there&#39;s no reason why you couldn&#39;t parse a spreadsheet (or other tabular data format) to generate Data objects.<br>
<br>Now, are you sure it&#39;s Data objects you want to generate?  I&#39;m guessing from how your question was phrased that it&#39;s Query objects you&#39;d like to generate.  In that case the answer to the question is still no, but...if you use Wolfgang&#39;s approach to solve the problem (i.e. defining the queries in the rules themselves, and not in a working memory object) then using a decision table is appropriate.  In fact, it&#39;s probably the best way to define the rules. (It&#39;s most compact and readable when you have many rules with a repetitive structure.)<br>

<div class="im"><br>--- On Wed, 11/11/09, Wishing Carebear &lt;<a href="mailto:wishing.carebear@gmail.com">wishing.carebear@gmail.com</a>&gt; wrote:<br><br>&gt; From: Wishing Carebear &lt;<a href="mailto:wishing.carebear@gmail.com">wishing.carebear@gmail.com</a>&gt;<br>
</div>&gt; Subject: Re: [rules-users] some pointers for solution<br>&gt; To: &quot;Rules Users List&quot; &lt;<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>&gt;<br>&gt; Date: Wednesday, November 11, 2009, 3:38 PM<br>

<div>
<div></div>
<div class="h5">&gt; Hi Greg:<br>&gt; Is it possible to use decision table to populate the<br>&gt; Data object that contains the criteria list<br>&gt; information.<br>&gt;  <br>&gt; Thanks,<br>&gt; Ravi<br>&gt;<br>&gt;<br>
&gt; 2009/11/8 Greg Barton &lt;<a href="mailto:greg_barton@yahoo.com">greg_barton@yahoo.com</a>&gt;<br>&gt;<br>&gt; There<br>&gt; are a couple of ways to do this.  I&#39;m sure there&#39;s<br>&gt; a bit more clean way than the example I&#39;m providing, but<br>
&gt; this should get you in the right direction.  It&#39;s not<br>&gt; 100% rules, because it involves a bit of java collections<br>&gt; trickery. (See attached project,<br>&gt; collection_DroolsCriteriaMatch.tar.gz)<br>&gt;<br>
&gt;<br>&gt; The heart of it is a single rule:<br>&gt;<br>&gt; rule &quot;Match&quot;<br>&gt;  when<br>&gt;    d : Data()<br>&gt;    q : Query( size &lt;= d.size )<br>&gt;    Number( intValue == q.size )<br>&gt;    from accumulate(<br>
&gt;      Criteria( this memberOf d, this memberOf q ),<br>&gt;<br>&gt;      init( int total = 0; ),<br>&gt;      action( total ++; ),<br>&gt;      reverse( total --; ),<br>&gt;      result( total )<br>&gt;    )<br>&gt;  then<br>
&gt;    System.out.println(&quot;Match: &quot; + d + &quot;<br>&gt; and &quot; + q) ;<br>&gt; end<br>&gt;<br>&gt; The Data object holds data to be queried, Query objects are<br>&gt; asserted to match the Data, and Criteria objects can be<br>
&gt; contained in either. (With the aforementioned collections<br>&gt; trickery that if a Criteria is contained in a Query it can<br>&gt; be found in a Data object, but the reverse isn&#39;t true.<br>&gt;  See the Query.contains(Object) method for how that&#39;s<br>
&gt; implemented.)<br>&gt;<br>&gt;<br>&gt; So the rule above basically says &quot;There&#39;s a Data<br>&gt; object, and all of the Query objects Criteria are contained<br>&gt; in the Data object.&quot;<br>&gt;<br>&gt; There&#39;s an alternate way of doing this using eval and a<br>
&gt; bit more java fu.  See the eval_DroolsCriteriaMatch.tar.gz<br>&gt; project attached.  This one&#39;s probably not optimal,<br>&gt; though, as it&#39;s basically a brute force check of all<br>&gt; Data objects against the asserted Query.<br>
&gt;<br>&gt;<br>&gt; I tried for a while to get a solution working with<br>&gt; different criteria types from both Data and Query objects<br>&gt; being asserted into working memory, but I couldn&#39;t get<br>&gt; the accumulate syntax right.  Anyone know of a way to do<br>
&gt; that? (I figure that would get a &quot;pure rules&quot;<br>&gt; solution.)<br>&gt;<br>&gt;<br>&gt; --- On Sat, 11/7/09, Wishing Carebear &lt;<a href="mailto:wishing.carebear@gmail.com">wishing.carebear@gmail.com</a>&gt;<br>
&gt; wrote:<br>&gt;<br>&gt; &gt; From: Wishing Carebear &lt;<a href="mailto:wishing.carebear@gmail.com">wishing.carebear@gmail.com</a>&gt;<br>&gt;<br>&gt; &gt; Subject: [rules-users] some pointers for solution<br>&gt; &gt; To: <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; &gt; Date: Saturday, November 7, 2009, 10:19 PM<br>&gt;<br>&gt;<br>&gt;<br>&gt; &gt; Hello:<br>&gt; &gt; There are n selection criteria from s1 .. sn for each<br>&gt; &gt; item i1.. in. Each item can have a subset of criteria<br>
&gt; which<br>&gt; &gt; applies to them.<br>&gt; &gt;  <br>&gt; &gt; The end user, can choose a subset of criteria like c1<br>&gt;<br>&gt; &gt; and c5 and only the item that has c1 and c5 valid<br>&gt; should be<br>&gt; &gt; returned. For example: if item i1 and i2 have<br>
&gt; criterias<br>&gt; &gt; valid for c1, c2, c5, c6, c8 since the request is only<br>&gt; for<br>&gt; &gt; criteria c1 and c5, i1 and i2 must be returned.<br>&gt;<br>&gt; &gt;<br>&gt; &gt;  <br>&gt; &gt; Is it possible to write a rule using drools for this<br>
&gt; &gt; requirement.<br>&gt; &gt;  <br>&gt; &gt; Thanks for your help and time,<br>&gt; &gt; cabear<br>&gt; &gt;<br>&gt; &gt; -----Inline Attachment Follows-----<br>&gt;<br>&gt; &gt;<br>&gt; &gt; _______________________________________________<br>
&gt; &gt; rules-users mailing list<br>&gt; &gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>&gt; &gt;<br>&gt;<br>&gt;<br>&gt;      <br>&gt; _______________________________________________<br>&gt; rules-users mailing list<br>&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; -----Inline Attachment Follows-----<br>
&gt;<br>&gt; _______________________________________________<br>&gt; rules-users mailing list<br>&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br><br><br><br><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>
</div></div></blockquote></div><br>