Trying to figure out if it can be done in a rule almost some sort of pre rule before other rules are triggered.

The current rule I have is

rule "RemoveInvalidEndTimestamps"
salience 100

when

$factN : Fact()
$factsToRemove : ArrayList(size>=5)
                 from collect( Fact(endTime==$factN.endTime))
then
List newFactsToRemove = new ArrayList();
newFactsToRemove.addAll($factsToRemove);
for(Fact n : newFactsToRemove ){
 retract(n);
}
end

I am using a cloud based process . I could sort the facts and stream them in.
Just in a few test cases there are many facts with invalid times , which kills the speed .
>From the log I think that each collection of size>=5 , is triggered which means triggered for 5,6,7, etc.

Just wondering if there is way to say before doing any other rules collect up all these invalid times and remove them.

I was just going to write up a some java code and filter before feeding facts into drools but I find the rule syntax is much easier to read for the non software developers in my group.


--
Thanks,

Benjamin Bennett