org.drools.verifier.incompatibility.Restrictions.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: 23.02.2008
package org.drools.verifier.incompatibility
#list any import classes here.
import org.drools.verifier.components.LiteralRestriction;
import org.drools.verifier.components.NumberRestriction;
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 :NumberRestriction(
operator == Operator.EQUAL
)
$r2 :NumberRestriction(
restrictionType == $r1.restrictionType,
fieldPath == $r1.fieldPath,
valueType == $r1.valueType,
( operator == Operator.LESS_OR_EQUAL || == Operator.LESS || == Operator.EQUAL ),
path != $r1.path,
value < $r1.value
)
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 :NumberRestriction(
( operator == Operator.GREATER || == Operator.GREATER_OR_EQUAL )
)
$r2 :NumberRestriction(
restrictionType == $r1.restrictionType,
fieldPath == $r1.fieldPath,
valueType == $r1.valueType,
operator == Operator.EQUAL,
path != $r1.path,
value < $r1.value
)
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,
fieldPath == $r1.fieldPath,
valueType == $r1.valueType,
operator == Operator.GREATER,
path != $r1.path,
valueAsString == $r1.valueAsString
)
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(
fieldPath == $r1.fieldPath,
operator == Operator.GREATER,
variable.parentPath == $r1.variable.parentPath,
variable.parentType == $r1.variable.parentType,
path != $r1.path
)
then
insert( new Incompatibility( $r1, $r2 ) );
end
© 2015 - 2025 Weber Informatics LLC | Privacy Policy