Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drools rule "not exists"

I'm using JBoss Drools to write some business rules. I got a problem on the "not exists" rule.Here is my code.

rule "ATL 27R-A12 Subfleet A319-100 Departure configuration list has flap 1"
    salience 20
    no-loop true
    when
        AircraftConfig(aircraftType=="A319-100")
        RunwayInfo(airport3lCode== "ATL", runwayId == "27R-A12" )
        not (exists (DepartureConfiguration( flap == 1 )))
    then
        throw new RuleNotMatchException("The configurations do not match the rule of this runway.");
end

My facts contains:An AircraftConfig, an RunwayInfo and several DepartureConfigurations. I want to fire the rule when there are no DepartureConfiguration which flap=1. I mean, if there are three DepartureConfigurations, one of them has the flap=1, the others are flap=2 or flap=3, then this rule will not fire. How could I make this work?

like image 871
Nigel Wu Avatar asked Dec 17 '22 02:12

Nigel Wu


1 Answers

The keyword for checking for the non-existence of a fact is not, not not exists. Change the last line of your condition to:

not DepartureConfiguration( flap == 1 )
like image 74
mike9322 Avatar answered Jan 25 '23 02:01

mike9322