Thanks Greg.<br><br>
<div class="gmail_quote">On Fri, Nov 13, 2009 at 7:56 AM, 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">It should be possible to define rules in a decision table that have &quot;true&quot; as their condition, though since I don&#39;t use decision tables I can&#39;t say for sure.  Then in the action just insert the data.<br>

<div class="im"><br>--- On Thu, 11/12/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>
&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></div>&gt; Date: Thursday, November 12, 2009, 12:05 AM<br>

<div>
<div></div>
<div class="h5">&gt; Hi Greg:<br>&gt; Looks like Excel may hep to pppulate the data objects<br>&gt; but running into only problem. Don&#39;t know how to insert<br>&gt; and update the dataobject in the same excel file.<br>
&gt;  <br>&gt; In other words, want to write the following rule in<br>&gt; Excel:<br>&gt;  <br>&gt; if<br>&gt;     eval(true)<br>&gt; then<br>&gt;      Data d = new Data();<br>&gt;      d.setAttr1(&quot;attr1&quot;);<br>&gt;      d.setAttr2(&quot;attr1&quot;);<br>
&gt;      insert(d);<br>&gt;  <br>&gt; Thanks,<br>&gt; cabear<br>&gt;<br>&gt;<br>&gt; On Wed, Nov 11, 2009 at 3:42 PM,<br>&gt; Wishing Carebear &lt;<a href="mailto:wishing.carebear@gmail.com">wishing.carebear@gmail.com</a>&gt;<br>
&gt; wrote:<br>&gt;<br>&gt;<br>&gt; Thanks for your reply Greg.<br>&gt;  <br>&gt; Actually I have 2 requirements:<br>&gt;  <br>&gt; 1) Define the data objects in the rule itself so that<br>&gt; the business user can define\modify the data<br>
&gt; objects<br>&gt; 2) have a rule that can evalaute the data objects<br>&gt; against the criteria the user requests..<br>&gt;  <br>&gt; It is my bad I started with the 2nd requirement<br>&gt; :(<br>&gt;  <br>&gt; Regards,<br>
&gt; cabear<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; On Wed, Nov 11, 2009 at 1:50 PM,<br>&gt; Greg Barton &lt;<a href="mailto:greg_barton@yahoo.com">greg_barton@yahoo.com</a>&gt;<br>&gt; wrote:<br>&gt;<br>&gt; Funny you should bring<br>
&gt; that up, I was just having this debate with a co-worker. :)<br>&gt;<br>&gt; A decision table is a means for defining rules, not working<br>&gt; memory objects.  So no, out of the box a decision table as<br>&gt; it&#39;s defined in drools (and other rule management<br>
&gt; systems) would not serve that purpose.  However,<br>&gt; there&#39;s no reason why you couldn&#39;t parse a<br>&gt; spreadsheet (or other tabular data format) to generate Data<br>&gt; objects.<br>&gt;<br>&gt;<br>&gt; Now, are you sure it&#39;s Data objects you want to<br>
&gt; generate?  I&#39;m guessing from how your question was<br>&gt; phrased that it&#39;s Query objects you&#39;d like to<br>&gt; generate.  In that case the answer to the question is still<br>&gt; no, but...if you use Wolfgang&#39;s approach to solve the<br>
&gt; problem (i.e. defining the queries in the rules themselves,<br>&gt; and not in a working memory object) then using a decision<br>&gt; table is appropriate.  In fact, it&#39;s probably the best<br>&gt; way to define the rules. (It&#39;s most compact and readable<br>
&gt; when you have many rules with a repetitive structure.)<br>&gt;<br>&gt;<br>&gt;<br>&gt; --- On Wed, 11/11/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: Re: [rules-users] some pointers for<br>&gt; solution<br>&gt; &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; &gt; Date: Wednesday, November 11, 2009, 3:38 PM<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; &gt; Hi Greg:<br>&gt; &gt; Is it possible to use decision table to populate the<br>&gt; &gt; Data object that contains the criteria list<br>
&gt; &gt; information.<br>&gt; &gt;  <br>&gt; &gt; Thanks,<br>&gt; &gt; Ravi<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; 2009/11/8 Greg Barton &lt;<a href="mailto:greg_barton@yahoo.com">greg_barton@yahoo.com</a>&gt;<br>&gt;<br>
&gt; &gt;<br>&gt; &gt; There<br>&gt; &gt; are a couple of ways to do this.  I&#39;m sure<br>&gt; there&#39;s<br>&gt; &gt; a bit more clean way than the example I&#39;m<br>&gt; providing, but<br>&gt; &gt; this should get you in the right direction.  It&#39;s<br>
&gt; not<br>&gt;<br>&gt; &gt; 100% rules, because it involves a bit of java<br>&gt; collections<br>&gt; &gt; trickery. (See attached project,<br>&gt; &gt; collection_DroolsCriteriaMatch.tar.gz)<br>&gt; &gt;<br>&gt; &gt;<br>
&gt; &gt; The heart of it is a single rule:<br>&gt; &gt;<br>&gt; &gt; rule &quot;Match&quot;<br>&gt;<br>&gt; &gt;  when<br>&gt; &gt;    d : Data()<br>&gt; &gt;    q : Query( size &lt;= d.size )<br>&gt; &gt;    Number( intValue == q.size )<br>
&gt; &gt;    from accumulate(<br>&gt; &gt;      Criteria( this memberOf d, this memberOf q ),<br>&gt; &gt;<br>&gt; &gt;      init( int total = 0; ),<br>&gt;<br>&gt; &gt;      action( total ++; ),<br>&gt; &gt;      reverse( total --; ),<br>
&gt; &gt;      result( total )<br>&gt; &gt;    )<br>&gt; &gt;  then<br>&gt; &gt;    System.out.println(&quot;Match: &quot; + d +<br>&gt; &quot;<br>&gt; &gt; and &quot; + q) ;<br>&gt; &gt; end<br>&gt;<br>&gt; &gt;<br>&gt; &gt; The Data object holds data to be queried, Query<br>
&gt; objects are<br>&gt; &gt; asserted to match the Data, and Criteria objects can<br>&gt; be<br>&gt; &gt; contained in either. (With the aforementioned<br>&gt; collections<br>&gt; &gt; trickery that if a Criteria is contained in a Query it<br>
&gt; can<br>&gt;<br>&gt; &gt; be found in a Data object, but the reverse isn&#39;t<br>&gt; true.<br>&gt; &gt;  See the Query.contains(Object) method for how<br>&gt; that&#39;s<br>&gt; &gt; implemented.)<br>&gt; &gt;<br>&gt; &gt;<br>
&gt; &gt; So the rule above basically says &quot;There&#39;s a<br>&gt; Data<br>&gt;<br>&gt; &gt; object, and all of the Query objects Criteria are<br>&gt; contained<br>&gt; &gt; in the Data object.&quot;<br>&gt; &gt;<br>&gt; &gt; There&#39;s an alternate way of doing this using eval<br>
&gt; and a<br>&gt; &gt; bit more java fu.  See the<br>&gt; eval_DroolsCriteriaMatch.tar.gz<br>&gt;<br>&gt; &gt; project attached.  This one&#39;s probably not<br>&gt; optimal,<br>&gt; &gt; though, as it&#39;s basically a brute force check of<br>
&gt; all<br>&gt; &gt; Data objects against the asserted Query.<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; I tried for a while to get a solution working with<br>&gt;<br>&gt; &gt; different criteria types from both Data and Query<br>
&gt; objects<br>&gt; &gt; being asserted into working memory, but I couldn&#39;t<br>&gt; get<br>&gt; &gt; the accumulate syntax right.  Anyone know of a way to<br>&gt; do<br>&gt; &gt; that? (I figure that would get a &quot;pure<br>
&gt; rules&quot;<br>&gt;<br>&gt; &gt; solution.)<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; --- On Sat, 11/7/09, Wishing Carebear &lt;<a href="mailto:wishing.carebear@gmail.com">wishing.carebear@gmail.com</a>&gt;<br>&gt; &gt; wrote:<br>
&gt; &gt;<br>&gt; &gt; &gt; From: Wishing Carebear &lt;<a href="mailto:wishing.carebear@gmail.com">wishing.carebear@gmail.com</a>&gt;<br>&gt;<br>&gt; &gt;<br>&gt; &gt; &gt; Subject: [rules-users] some pointers for<br>&gt; solution<br>
&gt; &gt; &gt; To: <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>&gt; &gt; &gt; Date: Saturday, November 7, 2009, 10:19 PM<br>&gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; &gt; Hello:<br>
&gt; &gt; &gt; There are n selection criteria from s1 .. sn for<br>&gt; each<br>&gt; &gt; &gt; item i1.. in. Each item can have a subset of<br>&gt; criteria<br>&gt; &gt; which<br>&gt; &gt; &gt; applies to them.<br>&gt;<br>
&gt; &gt; &gt;  <br>&gt; &gt; &gt; The end user, can choose a subset of criteria<br>&gt; like c1<br>&gt; &gt;<br>&gt; &gt; &gt; and c5 and only the item that has c1 and c5<br>&gt; valid<br>&gt; &gt; should be<br>&gt; &gt; &gt; returned. For example: if item i1 and i2 have<br>
&gt;<br>&gt; &gt; criterias<br>&gt; &gt; &gt; valid for c1, c2, c5, c6, c8 since the request is<br>&gt; only<br>&gt; &gt; for<br>&gt; &gt; &gt; criteria c1 and c5, i1 and i2 must be returned.<br>&gt; &gt;<br>&gt; &gt; &gt;<br>
&gt; &gt; &gt;  <br>&gt; &gt; &gt; Is it possible to write a rule using drools for<br>&gt; this<br>&gt;<br>&gt; &gt; &gt; requirement.<br>&gt; &gt; &gt;  <br>&gt; &gt; &gt; Thanks for your help and time,<br>&gt; &gt; &gt; cabear<br>
&gt; &gt; &gt;<br>&gt; &gt; &gt; -----Inline Attachment Follows-----<br>&gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; _______________________________________________<br>&gt;<br>&gt; &gt; &gt; rules-users mailing list<br>&gt; &gt; &gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; &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; &gt; &gt;<br>&gt; &gt;<br>&gt; &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;<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; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<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; _______________________________________________<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>