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?
List<LandingConfiguration> result = new ArrayList<LandingConfiguration>(); KnowledgeBase kbase = readKnowledgeBase("runway.A319.landing.drl"); StatelessKnowledgeSession ksession = kbase .newStatelessKnowledgeSession(); List<Object> facts = new ArrayList<Object>(); facts.add(subFleet); facts.add(runway); facts.addAll(configurations); ksession.execute(facts);
– Sorptionforall(DepartureConfiguration( flap == 1 ))
, it not fires, but when I useforall(DepartureConfiguration( flap != 1 )
, it fires. – Sorption