Thank you for your help. I tried the solution you proposed but encountered the following
error message:
[10,27]: [ERR 101] Line 10:27 no viable alternative at input 'new' in rule
"Prix premier semestre" in pattern Produit
[10,36]: [ERR 102] Line 10:36 mismatched input '2010' expecting ')' in
rule "Prix premier semestre" in pattern Date
Eventually, I had to adapt the rule in the following way:
rule "Prix premier semestre"
when
$p1 : Produit(id == 1)
eval ($p1.dDeb.before(new Date(2010,3,1) ) )
then
$p1.setId(2) ;
$p1.setPrix(10) ;
update( $p1 );
end
The test on the id shouldn't be necessary but I can't make it work without.
So, the current version is not very clean. Have you got an idea ?
Regards,
Benoît
Date: Mon, 8 Mar 2010 10:09:20 +0000
From: ejdiggins(a)gmail.com
To: rules-users(a)lists.jboss.org
Subject: Re: [rules-users] Problem with date
Maybe something like:
rule "Prix premier semestre"
when
p1 : Produit( eval(dDeb.isBefore(new Date(2010,1,1) ) ) )
then
p1.setPrix( 10 );
update( p1 );
end
Obviously you'll have to import whatever type of date you're using and change the
call to the constructor to match.
I may be wrong but I think you need to use eval here because you want to create the
comparison date within the rule. If you had already created the date using
"<" would be fine:
rule "Prix premier semestre"
when
p1 : Produit( dateProperty1 < dateProperty2 )
then
p1.setPrix( 10 );
update( p1 );
end
2010/3/8 Bertrand Grottier <b_grottier(a)hotmail.com>
Hello,
Ok, I understand the problem. dDeb is indeed a Date type.
What is the proper/simplest way to achieve such a comparison ?
Thank you in advance for your help.
Regards,
Benoît
Date: Thu, 4 Mar 2010 10:01:23 +0000
From: ejdiggins(a)gmail.com
To: rules-users(a)lists.jboss.org
Subject: Re: [rules-users] Problem with date
Hi,
What is the type of the dDeb field? It looks like you're trying to check if a date is
less than a string.
Enda
2010/3/3 Bertrand Grottier <b_grottier(a)hotmail.com>
Dear all,
I am a newbie with Drools (Drools 5). I just want to make a date comparison but failed
until now. Here is my drl file :
package com.sample
import com.sample.DroolsTest.Produit;
rule "Prix premier semestre"
when
p1 : Produit( dDeb < "01-Jan-2010" )
then
p1.setPrix( 10 );
update( p1 );
end
I get a build error in Eclipse : Unable to create restriction.
This must be an obvious problem but I am struggling for a while now.
Any help would be appreciated.
Benoit
Commander un cadeau en ligne discrètement? Voir la solution offerte par Internet
Explorer8
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Enda J Diggins
Envie de naviguer sur Internet sans laisser de trace? La solution avec Internet Explorer
8
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Enda J Diggins
_________________________________________________________________
Découvrez comment SURFER DISCRETEMENT sur un site de rencontres !
http://clk.atdmt.com/FRM/go/206608211/direct/01/