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