Isn't this a simple coding error:
releaseDate<= ( (ageInDays(current.releaseDate)<100) )
as is compares a Date with a boolean?
I think that the constraint should just be
eval( ageInDays(current.releaseDate) < 100 )
-W
On 20 June 2011 07:38, jarno niemelä <jargon(a)iki.fi> wrote:
>
> Hello.
>
> I am trying to set up guvnor environment for business users, and I am
> having a bit of trouble in getting functions to work.
>
> What I am trying to do is to make a function that would calculate age
> of product in days as comparison between release date and current
> date.
>
> I have following POJO:
>
> public class Product {
>
> private String name;
>
> private Date releaseDate;
>
> public Date getReleaseDate() {
> return releaseDate;
> }
>
> public void setReleaseDate(Date releaseDate) {
> this.releaseDate = releaseDate;
> }
> }
>
> My function:
>
> import java.util.Date;
> import java.util.Calendar;
>
> function int ageInDays(Date beginDate) {
>
> Date today = Calendar.getInstance().getTime();
> long age=today.getTime()-beginDate.getTime();
> return (int)((age/1000)/60/60/24);
> }
>
> My rule:
> 1. | rule "test2"
> 2. | dialect "mvel"
> 3. | when
> 4. | current : Product( supported != "supported" ,
> releaseDate
> <= ( (ageInDays(current.releaseDate)<100) ) )
> 5. | then
> 6. | current.setSupported( "supported" );
> 7. | update( current );
> 8. | end
>
> I am getting error when running test:
>
> Exception executing ReturnValue constraint
> org.drools.rule.ReturnValueRestriction@4219ae2e :
> java.lang.IllegalArgumentException: Unable to convert class
> java.lang.Boolean to a Date.
>
> What I am doing wrong here?
>
> Alternative solution would be to create getAge() function in my POJO,
> but are POJOs supposed to have executable code or are they supposed to
> be used only for storing fact values?
>
> Jarno
> _______________________________________________
> 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