<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Nonsense. <div><br></div><div>Rules engines can solve many problems much better than a monotonic programming. The primary area where this is the case are the "watch for given conditions, then act" problems: monitoring, command and control, models, and simulations. Rule engines are particularly well suited for tackling those problems, as with the "just do it in java" approach you usually end up first implementing a rules engine (badly) and getting stuck twiddling with your engine when you could be solving the problem at hand.</div><div><br></div><div>The business rules application of rules engines was just a way to get the technology adopted, but it is by no means the only use of the technology.<br><br>--- On <b>Mon, 2/6/12, Welsh, Armand <i><AWelsh@StateStreet.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16,
255); margin-left: 5px; padding-left: 5px;"><br>From: Welsh, Armand <AWelsh@StateStreet.com><br>Subject: Re: [rules-users] setting different value in consequence ( RHS part) based on a conditional check<br>To: "Rules Users List" <rules-users@lists.jboss.org><br>Date: Monday, February 6, 2012, 6:45 PM<br><br><div id="yiv1883041505">
<style><!--
#yiv1883041505
_filtered #yiv1883041505 {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}
_filtered #yiv1883041505 {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;}
#yiv1883041505
#yiv1883041505 p.yiv1883041505MsoNormal, #yiv1883041505 li.yiv1883041505MsoNormal, #yiv1883041505 div.yiv1883041505MsoNormal
        {margin:0in;margin-bottom:.0001pt;font-size:12.0pt;font-family:"serif";}
#yiv1883041505 a:link, #yiv1883041505 span.yiv1883041505MsoHyperlink
        {color:blue;text-decoration:underline;}
#yiv1883041505 a:visited, #yiv1883041505 span.yiv1883041505MsoHyperlinkFollowed
        {color:purple;text-decoration:underline;}
#yiv1883041505 p.yiv1883041505MsoAcetate, #yiv1883041505 li.yiv1883041505MsoAcetate, #yiv1883041505 div.yiv1883041505MsoAcetate
        {margin:0in;margin-bottom:.0001pt;font-size:8.0pt;font-family:"sans-serif";}
#yiv1883041505 span.yiv1883041505hoenzb
        {}
#yiv1883041505 span.yiv1883041505BalloonTextChar
        {font-family:"sans-serif";}
#yiv1883041505 span.yiv1883041505EmailStyle20
        {font-family:"sans-serif";color:#1F497D;}
#yiv1883041505 .yiv1883041505MsoChpDefault
        {font-family:"sans-serif";}
_filtered #yiv1883041505 {margin:1.0in 1.0in 1.0in 1.0in;}
#yiv1883041505 div.yiv1883041505WordSection1
        {}
--></style>
<div>
<div class="yiv1883041505WordSection1">
<p class="yiv1883041505MsoNormal"><span style="font-size:11.0pt;color:#1F497D;">As I suggested, if you wish to put conditional logic in the RHS of a rule, you would use a function. I didn’t provide an example using the function, because
it did not appear to warrant the need for one, and because I consider this to be a very simplified version of the actual rule.</span></p>
<p class="yiv1883041505MsoNormal"><span style="font-size:11.0pt;color:#1F497D;"> </span></p>
<p class="yiv1883041505MsoNormal"><span style="font-size:11.0pt;color:#1F497D;">Again, the decision on how to solve the challenge is up to the developer. Rules engines are not really designed to solve programmer’s problems, they are designed
to solve business problems. And the use of functions to apply business logic obfuscates the code, making it less readable by a business analyst, and complicates the development of the code. Placing the decision logic in the LHS keeps the rules simple, and
thus more maintainable by a business analyst. </span></p>
<p class="yiv1883041505MsoNormal"><span style="font-size:11.0pt;color:#1F497D;"> </span></p>
<p class="yiv1883041505MsoNormal"><span style="font-size:11.0pt;color:#1F497D;">If only developers will ever look at the code, then I would question the use of drools at all, since many of the challenges we solve with drools can be coded
more efficiently in straight JAVA code. But again, the decision is always on the developers.</span></p>
<p class="yiv1883041505MsoNormal"><span style="font-size:11.0pt;color:#1F497D;"> </span></p>
<p class="yiv1883041505MsoNormal"><b><span style="font-size:10.0pt;">From:</span></b><span style="font-size:10.0pt;"> rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org]
<b>On Behalf Of </b>Wolfgang Laun<br>
<b>Sent:</b> Thursday, January 26, 2012 10:52 AM<br>
<b>To:</b> Rules Users List<br>
<b>Subject:</b> Re: [rules-users] setting different value in consequence ( RHS part) based on a conditional check</span></p>
<p class="yiv1883041505MsoNormal"> </p>
<p class="yiv1883041505MsoNormal" style="margin-bottom:12.0pt;">Oh my, aren't we a wee bit too dogmatic? I've certainly been known as being a stickler to style and best practice and what not, but in this particular case I'd use a single rule and offload the earth-shaking
decision between 'Y' and 'N' into a function:<br>
<br>
rule x<br>
when<br>
samplefact1( $status: status, state == "CA" )<br>
then<br>
fact0.setField1( yn( $status) );<br>
end<br>
<br>
Cheers<br>
-W<br>
<br>
</p>
<div>
<p class="yiv1883041505MsoNormal">On 26 January 2012 18:25, Welsh, Armand <<a rel="nofollow" ymailto="mailto:AWelsh@statestreet.com" target="_blank" href="/mc/compose?to=AWelsh@statestreet.com">AWelsh@statestreet.com</a>> wrote:</p>
<p class="yiv1883041505MsoNormal">You cannot, under normal circumstances, place conditional login in the RHS. This is by design. Any conditional logic belongs in the LHS. If you need to perform conditional logic in the RHS, this is usually an indicator that they rule
is not written correctly.<br>
<br>
Now, with that said, there are times when you specifically want to put a decision component in the RHS. I would do this using a function.<br>
<br>
In your case, it really would make sense to use two rules, to represent your one case, like this:<br>
<br>
<br>
Rule 1<br>
when<br>
samplefact1( status == "active", state == "CA" )</p>
<div>
<p class="yiv1883041505MsoNormal" style="margin-bottom:12.0pt;"><br>
then<br>
Response fact0= new Response();<br>
fact0.setField1( "Y" );<br>
fact0.setName( "something " );<br>
<br>
insert(fact0 );<br>
end</p>
</div>
<p class="yiv1883041505MsoNormal">Rule 2<br>
when<br>
samplefact1( status != "active", state == "CA" )</p>
<div>
<p class="yiv1883041505MsoNormal" style="margin-bottom:12.0pt;"><br>
then<br>
Response fact0= new Response();<br>
fact0.setField1( "N" );<br>
fact0.setName( "something " );<br>
<br>
insert(fact0 );<br>
end<br>
<br>
</p>
</div>
<p class="yiv1883041505MsoNormal">These two rules are mutually exclusive, only one will fire, and you get the result you want. It's really about changing the way you think about decision factors. You can also achieve the same result like this:<br>
<br>
<br>
Rule 1<br>
when<br>
samplefact1(state == "CA" )</p>
<div>
<p class="yiv1883041505MsoNormal"><br>
then<br>
Response fact0= new Response();</p>
</div>
<div>
<p class="yiv1883041505MsoNormal" style="margin-bottom:12.0pt;"> fact0.setName( "something " );<br>
<br>
insert(fact0 );<br>
end<br>
<br>
</p>
</div>
<p class="yiv1883041505MsoNormal">Rule 2a<br>
when<br>
samplefact1( status == "active", state == "CA" )<br>
$resp : Response ( field1 != "Y")<br>
<br>
Then<br>
modify( $resp ) { setField1( "Y" ) };end<br>
<br>
Rule 2b<br>
when<br>
samplefact1( status != "active", state == "CA" )<br>
$resp : Response ( field1 == "Y")<br>
then<br>
modify( $resp ) { setField1( "N" ) };<br>
end<br>
<br>
In this scenario, you are changing from hard data mapping to an event oriented rule. Rule1 creates the basic Response fact, and Rules 2a&2b enrich the response fact based on conditions that may arise throughout the processing of the rules, independent of the
initial creation step. Just whenever you have a response fact that is not Y, set it to Y, and of course the inverse rule... This requires more processing for the rules, but in a large rules based system this may be more in-line with what you really want.<br>
<span style="color:#888888;"><br>
<span class="yiv1883041505hoenzb">Armand</span></span></p>
<div>
<div>
<p class="yiv1883041505MsoNormal"><br>
-----Original Message-----<br>
From: <a rel="nofollow" ymailto="mailto:rules-users-bounces@lists.jboss.org" target="_blank" href="/mc/compose?to=rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a> [mailto:<a rel="nofollow" ymailto="mailto:rules-users-bounces@lists.jboss.org" target="_blank" href="/mc/compose?to=rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>] On Behalf Of vadlam<br>
Sent: Thursday, January 26, 2012 8:11 AM<br>
To: <a rel="nofollow" ymailto="mailto:rules-users@lists.jboss.org" target="_blank" href="/mc/compose?to=rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
Subject: [rules-users] setting different value in consequence ( RHS part) based on a conditional check<br>
<br>
Hi,<br>
<br>
we have an existing BRL rule in Guvnor whereby we set the value of some<br>
fields in RHS based on some value checks in the condition part. we have<br>
created several of these rules already in a previous release.<br>
<br>
In the next release, we have new requirements to set the value of an<br>
existing field in consequence to be of 2 different values based on a<br>
specific conditional evaluation. the rest of the rule remains the same.<br>
<br>
to clarify,<br>
<br>
when<br>
samplefact1( status== "active" , state=="CA" )<br>
<br>
then<br>
<br>
Response fact0= new Response();<br>
fact0.setField1( "Y" );<br>
fact0.setName( "something " );<br>
<br>
insert(fact0 );<br>
end<br>
<br>
we now have to change this to set Field1 value to Y or N based on some<br>
updated condition for status field.<br>
<br>
lets say if status=="active" , Field1 has to be Y, but when status=closed,<br>
then Field1 has to be N<br>
<br>
Please keep in mind that the rest of the rule remains the same.<br>
<br>
is there a way to set the value of Field1 to be Y or N within the<br>
consequence part of same rule without having to create another rule .<br>
<br>
will the use of functions or variables be of any help in this case?<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a rel="nofollow" target="_blank" href="http://drools.46999.n3.nabble.com/setting-different-value-in-consequence-RHS-part-based-on-a-conditional-check-tp3690826p3690826.html">
http://drools.46999.n3.nabble.com/setting-different-value-in-consequence-RHS-part-based-on-a-conditional-check-tp3690826p3690826.html</a><br>
Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a rel="nofollow" ymailto="mailto:rules-users@lists.jboss.org" target="_blank" href="/mc/compose?to=rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a rel="nofollow" target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a rel="nofollow" ymailto="mailto:rules-users@lists.jboss.org" target="_blank" href="/mc/compose?to=rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a rel="nofollow" target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a></p>
</div>
</div>
</div>
<p class="yiv1883041505MsoNormal"> </p>
</div>
</div>
</div><br>-----Inline Attachment Follows-----<br><br><div class="plainMail">_______________________________________________<br>rules-users mailing list<br><a ymailto="mailto:rules-users@lists.jboss.org" href="/mc/compose?to=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></blockquote></div></td></tr></table>