Have u considered using DSLs? They can hide the object model from the users quite well.<br><br><div class="gmail_quote">On Wed, Feb 25, 2009 at 2:02 PM, David Boaz <span dir="ltr"><<a href="mailto:davidb@dbmotion.com">davidb@dbmotion.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Thanks,<br>
These Quantity and Duration objects are commonly used in our application. My<br>
concern is from the software-engineering prespective. Now, the rule author<br>
(which is supposed to be a "domain expert") has to maintain the information<br>
twice: once when inserting these objects to the working memory (at the<br>
initialization), and then when writing the concrete rules.<br>
Im looking for a trick to make the rule-aurhor life more convienient...<br>
<br>
Greg Barton wrote:<br>
><br>
> I'd second this idea, and to get around the inconcenience of inserting the<br>
> Quantity objects from the calling application, use a rule that fires once<br>
> on initialization.<br>
><br>
> rule<br>
> no-loop true<br>
> when<br>
> //No condition<br>
> then<br>
> insert(new Quantity("m", 2));<br>
> end<br>
><br>
> This rule should fire first. You could also put it in it's own<br>
> agenda-group (call it "initialization" or some such) and set focus to that<br>
> group when starting.<br>
><br>
> rule<br>
> agenda-group "initialization"<br>
> no-loop true<br>
> when<br>
> //No condition<br>
> then<br>
> insert(new Quantity("m", 2));<br>
> drools.setFocus("whatever_your_next_group_is");<br>
> end<br>
><br>
> --- On Wed, 2/25/09, Mauricio Salatino <<a href="mailto:salaboy@gmail.com">salaboy@gmail.com</a>> wrote:<br>
><br>
>> From: Mauricio Salatino <<a href="mailto:salaboy@gmail.com">salaboy@gmail.com</a>><br>
>> Subject: Re: [rules-users] Creating objects in WHEN clause<br>
>> To: "Rules Users List" <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
>> Date: Wednesday, February 25, 2009, 11:40 AM<br>
>> How about :<br>
>> WHEN<br>
>> $quantity: Quantity(value == 2, unit == "m")<br>
>> $Person($height == $quantity:)<br>
>> then<br>
>> ...<br>
>><br>
>><br>
>><br>
>> On Wed, Feb 25, 2009 at 2:27 PM, David Boaz<br>
>> <<a href="mailto:davidb@dbmotion.com">davidb@dbmotion.com</a>> wrote:<br>
>> ><br>
>> > In my application, we often compare the fact's<br>
>> field values against a known<br>
>> > object. For example:<br>
>> > WHEN person(height> new Quantity(2, "m"))<br>
>> // the height is greater than 2<br>
>> > meters.<br>
>> > will DROOLS create a "singleton" Quantity<br>
>> object, or will it create one<br>
>> > object for each fact evaluation?<br>
>> ><br>
>> > We consider using anoter approach, using GLOBALS.<br>
>> Then, the Quantity object<br>
>> > will be created applicatively, and passed by the API<br>
>> to the engine.<br>
>> > something like:<br>
>> > GLOBAL Quantity 2meters<br>
>> > WHEN person(height > 2meters)<br>
>> > But this approach is combersom, because the rule<br>
>> author has to define part<br>
>> > of the information in the calling application, and<br>
>> part in the rule.<br>
>> ><br>
>> > Do you have a good practice how to handle these<br>
>> situations?<br>
>> ><br>
>> > Thanks, David<br>
>> > --<br>
>> > View this message in context:<br>
>> <a href="http://www.nabble.com/Creating-objects-in-WHEN-clause-tp22207616p22207616.html" target="_blank">http://www.nabble.com/Creating-objects-in-WHEN-clause-tp22207616p22207616.html</a><br>
>> > Sent from the drools - user mailing list archive at<br>
>> Nabble.com.<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>
>> - Salatino Mauricio -<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>
> 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>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://www.nabble.com/Creating-objects-in-WHEN-clause-tp22207616p22209417.html" target="_blank">http://www.nabble.com/Creating-objects-in-WHEN-clause-tp22207616p22209417.html</a><br>
Sent from the drools - user mailing list archive at Nabble.com.<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>
</font></blockquote></div><br>