All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.drools.verifier.alwaysTrue.Rules.drl Maven / Gradle / Ivy

There is a newer version: 9.44.0.Final
Show newest version
#
# 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.PatternPossibility;
import org.drools.verifier.components.RulePossibility;
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.dao.VerifierResult;

global VerifierResult 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 :RulePossibility(
			ruleId == $r.id
		)
		
		# Each pattern possibility in rule possibility needs to be always true.
		forall(
			$pp :PatternPossibility(
				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 :RulePossibility(
				ruleId == $r.id
			)
			
			AlwaysTrue(
				cause == $rp
			)
		)
	then 
		result.add( new VerifierMessage(
								Severity.WARNING,
								MessageType.ALWAYS_TRUE,
								$r,
								$r + " is always satisfied." ) );
end




© 2015 - 2025 Weber Informatics LLC | Privacy Policy