0

I'm trying to have the following working:

rule "userCount"
    when
        $user : User()
        $minutes : Integer()
            from accumulate(
                            MinutesPerUser( user == $user, $time : time) 
                            and Time(this == $time),
                            sum(1)
                           )
    then
        System.out.println( $minutes );
end

but it seems the and Time(this == $user) part is never true. If I remove that part I get some println output.

What's wrong with the above code?

Dean
  • 6,610
  • 6
  • 40
  • 90

1 Answers1

0

Not knowing the relation of the Java classes, it's a little difficult to state definite facts. But from

 $user : User()
 //...
 and Time(this == $user),

it is quite evident that Time must be a superclass of User or vice versa: otherwise there's no way this constraint can be fulfilled.

I don't know what you should write instead, as there's no specification of what should be done.

BTW, sum(1) looks rather fishy, because that would be better expressed by count(1), producing the same result.

laune
  • 31,114
  • 3
  • 29
  • 42
  • Argh, forgive me laune, I had a typo in my code. $time is what I had in my production code, I just left a "debug" typo in there :( – Dean Nov 10 '14 at 18:53
  • Now we're going to need a set of facts - i.e., the code inserting it into working memory - that should produce a match. You should add this code to your Q. – laune Nov 10 '14 at 19:29