<div dir="ltr">Thanks a lot, this helps alot. now all the errors gone.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 25, 2013 at 1:24 AM, Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">@Mark: There's really no need to claim additional bugs ;-)<br>
<br>
@Jeetendra: Within a pattern (such as "ProposalLight(...)") you may<br>
write bindings and constraints, which are boolean expressions. Older<br>
versions had a much more restricted syntax for constraints, and<br>
general (Java-style) expressions were only peremitted by enclosing<br>
them in "eval(...)". In 5.5.0, as soon as you open a parenthesis, you<br>
have to stick to plain old Java (or MVEL) syntax, and "eval" is a name<br>
like any other. Recognizing "eval(...)" as the legacy marker for<br>
introducing an expression has to be kept, but only at the outermost<br>
parenthesis nesting level of constraint expressions. See example #1<br>
below:<br>
<br>
### 1 ###<br>
function boolean positive(int a){ return a > 0; }<br>
<br>
// legacy style constraint, use eval() to wrap boolean expression<br>
$msg: Message( eval(positive($msg.getText().length())) )<br>
<br>
// modern style: boolean expression<br>
$msg: Message( positive($msg.getText().length()) )<br>
<br>
// modern style: boolean expression with redundant parentheses<br>
$msg: Message( ( positive($msg.getText().length()) ) )<br>
<br>
The next example demostrates that eval is a "soft" keyword, with<br>
recognition restricted to certain places:<br>
<br>
### 2 ###<br>
function boolean eval(int a){ return a > 0; } // Why not call a<br>
function "eval"?<br>
<br>
// modern style: boolean expression, parentheses required to bypass<br>
soft "eval" recognition<br>
$msg: Message( ( eval($msg.getText().length()) ) )<br>
<br>
So, the answer to your question "How can I make it work?" is quite<br>
simple: add a declaration of a boolean function eval, like this:<br>
<br>
function boolean eval( boolean b ){ return b; }<br>
<br>
<br>
And, please, do not use terms like "throws an exception" when a simple<br>
syntax error is reported.<br>
<span class="HOEnZb"><font color="#888888"><br>
-W<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On 25/07/2013, Mark Proctor <<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>> wrote:<br>
> It shouldn't do, and could be a bug. Can you try 5.6.0.SNAPSOT and see if it<br>
> is still a problem.<br>
><br>
> Mark<br>
> On 24 Jul 2013, at 18:22, Jeet Singh <<a href="mailto:jeetcyb@gmail.com">jeetcyb@gmail.com</a>> wrote:<br>
><br>
>> Alright, I kinda found out the cause of the exception I am getting,<br>
>> however I am still struggling the reason behind the exception.<br>
>><br>
>> So DRL_1, this works perfectly fine.<br>
>> package drools;<br>
>> import drools.ProposalLight;<br>
>> import function drools.DateUtil.compareDatesWithTime;<br>
>> rule "Date Rule"<br>
>> when<br>
>> $obj : ProposalLight(eval(compareDatesWithTime(endDateTime, -2, 6,<br>
>> \"<\")))<br>
>> then<br>
>> $obj.addFailedRule("Date Rule");<br>
>> end;<br>
>><br>
>> DRL_2, this doesn't work. and throws [Error: unable to resolve method<br>
>> using strict-mode: myObject.eval(boolean)] [Near : {...<br>
>> (eval(compareDatesWithTime(star ....}] ...<br>
>><br>
>> package drools;<br>
>> import drools.ProposalLight;<br>
>> import function drools.DateUtil.compareDatesWithTime;<br>
>> rule "Date Rule"<br>
>> when<br>
>> $obj : ProposalLight((eval(compareDatesWithTime(endDateTime, -2, 6,<br>
>> \"<\"))))<br>
>> then<br>
>> $obj.addFailedRule("Date Rule");<br>
>> end;<br>
>><br>
>> Notice that extra paranthesis around eval(). This is where Drools 5.5<br>
>> throws exception. Can someone please explain why this extra paranthesis<br>
>> throws exception and how can I make it work.<br>
>><br>
>> Thanks,<br>
>> Jeetendra.<br>
>><br>
>><br>
>> On Wed, Jun 5, 2013 at 1:27 AM, Wolfgang Laun <<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>><br>
>> wrote:<br>
>> The error message suggests that you have made a syntactic error in a<br>
>> rule which is not the one you have posted, or you have modified the<br>
>> rule too much to be of any help. Post again, taking great care not to<br>
>> omit anything or to change the cause of the problem. Also, indicate<br>
>> precisely the declaration of the function compareDatesWithTime().<br>
>><br>
>> -W<br>
>><br>
>><br>
>> On 04/06/2013, jeetendray <<a href="mailto:jeetcyb@gmail.com">jeetcyb@gmail.com</a>> wrote:<br>
>> > Hi,<br>
>> ><br>
>> > Snippet of my DRL .<br>
>> ><br>
>> > rule "Rev: Start Time < 2 Hours in Future"<br>
>> > when<br>
>> > $obj : eval(compareDatesWithTime(startDateTime, -2, 2,<br>
>> > "<"))<br>
>> > then<br>
>> > $obj.addFailedRule("Rev: Start Time < 2 Hours in<br>
>> > Future");<br>
>> > end<br>
>> ><br>
>> > This fails during compilation and throws error:<br>
>> ><br>
>> > org.drools.rule.InvalidRulePackage: Unable to Analyse Expression<br>
>> > (eval(compareDatesWithTime(startDateTime, -2, 2, "<")) ):<br>
>> > [Error: unable to resolve method using strict-mode:<br>
>> > myObject.eval(boolean)]<br>
>> > [Near : {... (eval(compareDatesWithTime(star ....}]<br>
>> > ^<br>
>> > [Line: 6, Column: 2] : [Rule name='Proposal - Start time is after<br>
>> > current +<br>
>> > 2 hour']<br>
>> ><br>
>> ><br>
>> > I am using Drools 5.5 and I found the cause that my code runs in strict<br>
>> > mode.. so If I set strict mode to false then this would work. Now I am<br>
>> > not<br>
>> > sure how to make it to false.<br>
>> ><br>
>> > Here's the code I am using:<br>
>> ><br>
>> > PackageBuilderConfiguration packageBuilderConfiguration = new<br>
>> > PackageBuilderConfiguration();<br>
>> > PackageBuilder packageBuilder = new<br>
>> > PackageBuilder(packageBuilderConfiguration);<br>
>> > packageBuilder.addPackageFromDrl(drl.getCharacterStream());<br>
>> ><br>
>> > Can someone please suggest me how to do that??<br>
>> ><br>
>> > Thanks!!!<br>
>> ><br>
>> ><br>
>> ><br>
>> > --<br>
>> > View this message in context:<br>
>> > <a href="http://drools.46999.n3.nabble.com/How-to-set-drools-dialect-mvel-strict-false-tp4024122.html" target="_blank">http://drools.46999.n3.nabble.com/How-to-set-drools-dialect-mvel-strict-false-tp4024122.html</a><br>
>> > Sent from the Drools: User forum mailing list archive at Nabble.com.<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>
>> 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>
>> 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>
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></div>