RE: [rules-users] Date arithmetic in “when” session

Joe White Joe.White at recondotech.com
Wed May 7 10:41:17 EDT 2008


I'm not enough of an expert to say why, but if you change your condition to put the variable on the left of the comparison and the numeric operation on the right then it will work. For example:

   	flight : Flight( $reqTime>(departure.time - 2 * 3600000),$reqTime>(departure.time + 4 * 360000))

-----Original Message-----
From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of sridhar123
Sent: Wednesday, May 07, 2008 7:51 AM
To: rules-users at lists.jboss.org
Subject: Re: [rules-users] Date arithmetic in “when” session


I tried this approach, but I get compilation errors for tokens '-' and '+'  I
get similar errors for any arithmetic symbols (*, + or -) 

What is the right way to add or subtract or multiply with in "when" session?


Errors:

unknown:26:27 Unexpected token '-'	DroolsEval/src/main/rules
TravelPolicy.drl	line 26	1210167094487	1018
unknown:28:27 Unexpected token '+'	DroolsEval/src/main/rules
TravelPolicy.drl	line 28	1210167094487	1019




Christine-27 wrote:
> 
> Hi,
> you shouldn't put part of the "if" or "when" part after the "then". Put
> all conditions after the "when" so the rule engine will evaluate them.
> 
> I guess you mean to write something like (although I haven't tested this):
> 
> rule "ITR Discard"
>    when
>      	req : LowFareRequest(
>              $reqTime : requestedDeparture.time)
>      	itr : AirItinerary( discarded == false )
>       	flight : Flight(
>             departure.time - 2 * 3600000 <
>                    $reqTime,
>             departure.time + 4 * 3600000 >
>                    $reqTime)
>    then
>              System.out.println("discard true");
>    end
> 
> 
> Christine
> 
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Date-arithmetic-in--%C3%A2%C2%80%C2%9Cwhen%C3%A2%C2%80%C2%9D-session-tp17103754p17105416.html
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




More information about the rules-users mailing list