org.drools.verifier.alwaysTrue.Rules.drl Maven / Gradle / Ivy
/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// created on: 27.6.2008
//
// Rules in this package look for patterns and rules that are always satisfied.
//
//
package org.drools.verifier.alwaysTrue
import org.drools.verifier.components.Pattern;
import org.drools.verifier.components.SubPattern;
import org.drools.verifier.components.SubRule;
import org.drools.verifier.components.VerifierRule;
import org.drools.verifier.report.components.AlwaysTrue;
import org.drools.verifier.report.components.Opposites;
import org.drools.verifier.report.components.VerifierMessage;
import org.drools.verifier.report.components.Severity;
import org.drools.verifier.report.components.MessageType;
import org.drools.verifier.data.VerifierReport;
import java.util.Map;
import java.util.HashMap;
global VerifierReport result;
//
// Finds rule possibilities that are always true.
//
// Dependencies:
// Needs at least one of the following packages or rules to fire:
// package org.drools.verifier.alwaysTrue;
// rule "Pattern possibility that is always true"
//
//
rule "Rule possibility that is always true"
when
$r :VerifierRule()
$rp :SubRule(
rulePath == $r.path
)
# Each pattern possibility in rule possibility needs to be always true.
forall(
$pp :SubPattern(
this memberOf $rp.items
)
AlwaysTrue(
cause == $pp
)
)
then
insert( new AlwaysTrue( $rp ));
end
//
// Finds rules that are always true.
//
// Dependencies:
// Needs at least one of the following packages or rules to fire:
// package org.drools.verifier.alwaysTrue;
// rule "Rule possibility that is always true"
//
//
rule "Rule that is always true"
when
$r :VerifierRule()
forall(
$rp :SubRule(
rulePath == $r.path
)
AlwaysTrue(
cause == $rp
)
)
then
Map impactedRules = new HashMap();
impactedRules.put( $r.getPath(), $r.getName());
result.add( new VerifierMessage(
impactedRules,
Severity.WARNING,
MessageType.ALWAYS_TRUE,
$r,
$r + " is always satisfied." ) );
end
© 2015 - 2025 Weber Informatics LLC | Privacy Policy