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

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

There is a newer version: 9.44.0.Final
Show newest version
#created on: 23.02.2008
package org.drools.verifier.incompatibility

#list any import classes here.
import org.drools.verifier.components.LiteralRestriction;
import org.drools.verifier.components.VariableRestriction;

import org.drools.verifier.report.components.Incompatibility;

import org.drools.base.evaluators.Operator;


#
# If two LiteralRestrictions are in conflict.
#
# Dependencies: None
# Example: IncorencePattern( a < 1 && a == 10 )
#
rule "Incompatible LiteralRestrictions with ranges in pattern possibility, impossible equality less or equal"
	when
		$r1 :LiteralRestriction(
			operator == Operator.EQUAL
		)

		$r2 :LiteralRestriction(
			restrictionType == $r1.restrictionType,
			fieldId == $r1.fieldId,
			valueType == $r1.valueType,
			( operator == Operator.LESS_OR_EQUAL || == Operator.LESS || == Operator.EQUAL ),
			id != $r1.id
		)

		eval( $r1.compareValues( $r2 ) == 1 )
	then
		insert( new Incompatibility( $r1, $r2 ) );
end

#
# If two LiteralRestrictions are in conflict.
#
# Dependencies: None
# Example: IncorencePattern( a > 10 && a == 1 )
#
rule "Incompatible LiteralRestrictions with ranges in pattern possibility, impossible equality greater"
	when
		$r1 :LiteralRestriction(
			( operator == Operator.GREATER || == Operator.GREATER_OR_EQUAL )
		)

		$r2 :LiteralRestriction(
			restrictionType == $r1.restrictionType,
			fieldId == $r1.fieldId,
			valueType == $r1.valueType,
			operator == Operator.EQUAL,
			id != $r1.id
		)

		eval( $r1.compareValues( $r2 ) == 1 )
	then
		insert( new Incompatibility( $r1, $r2 ) );
end

#
# If two LiteralRestrictions are in conflict.
#
# Dependencies: None
# Example: IncorencePattern( a < "12-Dec-2007", a > "12-Dec-2007" )
#
rule "Incompatible LiteralRestrictions with ranges in pattern possibility, impossible range"
	when
		$r1 :LiteralRestriction(
			operator == Operator.LESS
		)

		$r2 :LiteralRestriction(
			restrictionType == $r1.restrictionType,
			fieldId == $r1.fieldId,
			valueType == $r1.valueType,
			operator == Operator.GREATER,
			id != $r1.id
		)

		eval( $r1.compareValues( $r2 ) == 0 )
	then
		insert( new Incompatibility( $r1, $r2 ) );
end

#
# If two VariableRestrictions are in conflict.
#
# Dependencies: None
# Example: Pattern( a > $var, a < $var )
#
rule "Incoherent VariableRestrictions in pattern possibility, impossible range"
	when
		$r1 :VariableRestriction(
			operator == Operator.LESS
		)

		$r2 :VariableRestriction(
			fieldId == $r1.fieldId,
			operator == Operator.GREATER,
			variable.objectId == $r1.variable.objectId,
			variable.objectType == $r1.variable.objectType,
			id != $r1.id
		)
	then
		insert( new Incompatibility( $r1, $r2 ) );
end




© 2015 - 2025 Weber Informatics LLC | Privacy Policy