Hello,
I'm having trouble using sliding length windows. Either I'm implementing
them wrong or I have misunderstood how they're supposed to work.
I have a class named Notif:
*public class Notif implements Serializable{
...
private String specificProblem;
...
public String getSpecificProblem() {
return specificProblem;
}
public void setSpecificProblem(String specificProblem) {
this.specificProblem = specificProblem;
}
}*
These Notif's represent my events. I want to know how many Notifs with
specificProblem "New ONT" are there in the last 2 received events.
My .drl file looks like this:
*declare Notif
@role( event )
end
rule "Rule1"
when
$event : Notif()
$nNewONT : Number() from accumulate (
Notif( specificProblem == "New ONT" ) over window:length(2), count() )
then
System.out.println("In the last 2 events there were "+$nNewONT+" events
'New ONT'");
end*
My test file:
*...
session.insert(ONTIsInactive1);
session.insert(newONT1);
session.insert(ONTIsInactive2);
session.insert(newONT2);
session.insert(LOKS1);
session.insert(LOKS2);
session.insert(LOKS3);
session.insert(newONT3);
session.fireAllRules(); *
As you probably can tell by the names, the events I'm looking for are the
2nd, the 4th and the last one.
But the output I get is:
In the last 2 events there were 2 events 'New ONT'
In the last 2 events there were 2 events 'New ONT'
In the last 2 events there were 2 events 'New ONT'
In the last 2 events there were 2 events 'New ONT'
In the last 2 events there were 2 events 'New ONT'
In the last 2 events there were 2 events 'New ONT'
In the last 2 events there were 2 events 'New ONT'
In the last 2 events there were 2 events 'New ONT'
The output I'm looking for is:
In the last 2 events there were 0 events 'New ONT' (because the received
event is "ONTIsInactive")
In the last 2 events there were 1 events 'New ONT' (because the last 2
received events are "ONTIsInactive" and "New ONT")
In the last 2 events there were 1 events 'New ONT' (because the last 2
received events are "New ONT" and "ONTIsInactive")
...
and so on...
What am I doing wrong? Any help would be appreciated!
Thanks in advance,
Diana
--
View this message in context:
http://drools.46999.n3.nabble.com/Sliding-Length-Windows-tp3438408p343840...
Sent from the Drools: User forum mailing list archive at
Nabble.com.