org.drools.verifier.subsumption.Restrictions.drl Maven / Gradle / Ivy
/*
* Copyright 2010 Red Hat, Inc. and/or its affiliates.
*
* 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: 28.1.2008
package org.drools.verifier.subsumption.patterns
import org.drools.core.base.evaluators.Operator;
import org.drools.verifier.components.Field;
import org.drools.verifier.components.LiteralRestriction;
import org.drools.verifier.components.NumberRestriction;
import org.drools.verifier.report.components.Subsumption;
import org.drools.verifier.data.VerifierReport;
global VerifierReport result;
//
// Fires when two restrictions are subsumptant.
// Creates a Subsumption object.
//
// Dependencies: None
//
// Example 1: P( x > 10 ) and P( x > 100 )
//
rule "Find subsumptant restrictions, greater than"
when
// Covered x > 10
$lower:NumberRestriction(
( valueType == Field.INT || == Field.DOUBLE || == Field.DATE ),
( operator == Operator.GREATER || == Operator.GREATER_OR_EQUAL )
)
// Covered x > 100
$higher :NumberRestriction(
fieldPath == $lower.fieldPath,
( operator == Operator.GREATER || == Operator.GREATER_OR_EQUAL || == Operator.EQUAL ),
value < $lower.value
)
then
insert( new Subsumption( $higher, $lower ) );
end
rule "Find subsumptant restrictions, equal"
when
// Covered x > 10
$left :LiteralRestriction( )
// Covered x > 10
$right :LiteralRestriction(
path != $left.path,
fieldPath == $left.fieldPath,
operator == $left.operator,
valueAsString == $left.valueAsString
)
then
insert( new Subsumption( $left, $right ) );
end
//
// Fires when two restrictions are subsumptant.
// Creates a Subsumption object.
//
// Dependencies: None
//
// Example 1: P( x < 10 ) and P( x < 100 )
//
rule "Find subsumptant restrictions, less than"
when
// Covered x < 10
$higher :NumberRestriction(
( valueType == Field.INT || == Field.DOUBLE || == Field.DATE ),
( operator == Operator.LESS || == Operator.LESS_OR_EQUAL )
)
// Covered x < 100
$lower :NumberRestriction(
fieldPath == $higher.fieldPath,
( operator == Operator.LESS || == Operator.LESS_OR_EQUAL || == Operator.EQUAL),
value < $higher.value
)
then
insert( new Subsumption( $higher, $lower ) );
end
© 2015 - 2025 Weber Informatics LLC | Privacy Policy