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