[rules-users] Problem with FROM and temporal operators

Harris harrisx at gmx.de
Tue Dec 14 04:32:26 EST 2010


Hi, 

I'm trying to get the following rule running: 

import foo.bar.Device; 
import foo.bar.Signal; 

declare Signal 
    @role( event ) 
    @timestamp( time ) 
end 

rule "No red signal within the last 3 days before job start for type=4
devices .." 
    salience 1000 
    when 
        $p : Device( type == "4" ) 
        $e : Signal( status == "red", this before[24h,0s] $p.jobTime) from
$p.getSignalBuffer() 
    then 
        // do something ... 
end 

For a special kind of device it should be checked whether there have been
alarms raised within a certain time interval. 
A couple of "devices" are inserted as facts. Each device has a buffer with
its n past "signals". 


public class Device { 
        String type; 
        List<Signal> signalBuffer = new ArrayList<Signal>(); 
        Date jobTime = new Date(); 
        // Getters and Setters 
} 

public class Signal { 
        Date time; 
        String status; 
        // Getters and Setters 
} 

These classes are generate by JAXB/xjc according to a given XML Schema. 

Although the rule looks OK to me, I'm getting the exception: 

java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot be
cast to org.drools.common.EventFactHandle 

I assume that "From" doesn't really work with the temporal operator and
events. 
Is there a way to get this working? 

Kind regards 
Harris
-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Problem-with-FROM-and-temporal-operators-tp2084522p2084522.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list