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

org.drools.verifier.redundancy.Restrictions.drl Maven / Gradle / Ivy

There is a newer version: 9.44.0.Final
Show newest version
#created on: 7.9.2007
package org.drools.verifier.redundancy.restrictions

import org.drools.verifier.components.*;
import org.drools.verifier.report.components.Redundancy;
import org.drools.verifier.report.components.RedundancyType;

#
# Dependencies: None
#
rule "Find redundant VariableRestriction"
	when
		# Check that Restrictions $left and $right have redundant fields.
		$left :VariableRestriction()
		$right :VariableRestriction(
			id != $left.id,
			operator == $left.operator,
			variable.objectType == $left.variable.objectType,
			variable.objectId == $left.variable.objectId
		)
		# Check that there is not already a pair with these values.
		not Redundancy(
			left == $left,
			right == $right
		)
		not Redundancy(
			left == $right,
			right == $left
		)
	then
		insert( new Redundancy( RedundancyType.STRONG, $left, $right ) );
end

#
# Dependencies: None
#
rule "Find redundant LiteralRestriction"
	when
		# Check that Restrictions $left and $right have redundant fields.
		$left :LiteralRestriction()
		and
		(
				$right :LiteralRestriction(
					id != $left.id,
					operator == $left.operator,
					valueType == $left.valueType,
					valueType == Field.FieldType.BOOLEAN,
					booleanValue == $left.booleanValue
				)
			or
				$right :LiteralRestriction(
					id != $left.id,
					operator == $left.operator,
					valueType == $left.valueType,
					valueType == Field.FieldType.STRING,
					valueAsString matches $left.valueAsString
				)
			or
				$right :LiteralRestriction(
					id != $left.id,
					operator == $left.operator,
					valueType == $left.valueType,
					valueType == Field.FieldType.INT,
					intValue == $left.intValue
				)
			or
				$right :LiteralRestriction(
					id != $left.id,
					operator == $left.operator,
					valueType == $left.valueType,
					valueType == Field.FieldType.DOUBLE,
					doubleValue == $left.doubleValue
				)
			or
				$right :LiteralRestriction(
					id != $left.id,
					operator == $left.operator,
					valueType == $left.valueType,
					valueType == Field.FieldType.DATE,
					eval( dateValue.equals($left.getDateValue()) )
				)
			or
			(
				$right :LiteralRestriction(
					id != $left.id,
					operator == $left.operator,
					valueType == $left.valueType,
					valueType == Field.FieldType.VARIABLE
				)
				and
					$v :Variable(
						objectType == VerifierComponentType.FIELD,
						objectId == $left.id
					)
				and
					Variable(
						objectType == VerifierComponentType.FIELD,
						objectId == $right.id,
						objectName == $v.objectName,
						name == $v.name
					)
			)
		)
		# Check that there is not already a pair with these values.
		not Redundancy(
			left == $left,
			right == $right
		)
		not Redundancy(
			left == $right,
			right == $left
		)
	then
		insert( new Redundancy( RedundancyType.STRONG, $left, $right ) );
end




© 2015 - 2025 Weber Informatics LLC | Privacy Policy