org.drools.verifier.redundancy.Possibilities.drl Maven / Gradle / Ivy
#created on: 7.9.2007
package org.drools.verifier.redundancy.possibilities
import org.drools.verifier.components.*;
import org.drools.verifier.report.components.Redundancy;
import org.drools.verifier.report.components.RedundancyType;
import org.drools.verifier.report.components.PartialRedundancy;
import org.drools.verifier.report.components.Subsumption;
import org.drools.verifier.report.components.Cause;
import org.drools.verifier.report.components.CauseType;
import java.util.ArrayList;
#
# Fires when two PatternPossibilities are redundant.
# Marks these possibilities as redundant.
#
# Dependencies: Needs at least one rule from both packages.
#
# package org.drools.verifier.redundancy.patterns
# rule "Find redundant Patterns with restrictions"
# rule "Find redundant Patterns without restrictions"
# package org.drools.verifier.redundancy.restrictions
# rule "Find redundant VariableRestriction"
# rule "Find redundant LiteralRestriction"
#
# Example 1: Pattern1( a == b ) and Pattern1( a == b )
# Example 2: Pattern1( a == b || a == c ) and Pattern1( a == b )
#
rule "Find pattern possibility redundancy"
when
$redundancy :Redundancy(
left.causeType == CauseType.PATTERN
)
# Find two PatternPossibilities.
(
$pp1 :PatternPossibility(
eval( patternId == $redundancy.getLeft().getId() )
)
and
$pp2 :PatternPossibility(
eval( patternId == $redundancy.getRight().getId() )
)
) or (
$pp1 :PatternPossibility(
eval( patternId == $redundancy.getRight().getId() )
)
and
$pp2 :PatternPossibility(
eval( patternId == $redundancy.getLeft().getId() )
)
)
# For every restriction in $pp1 there is a redundancy to $pp2.
forall(
$r :Restriction(
patternId == $pp1.patternId,
this memberOf $pp1.items
)
Redundancy(
(
left == $r
&&
right memberOf $pp2.items
) || (
left memberOf $pp2.items
&&
right == $r
)
)
)
# For every restriction in $pp2 there is a redundancy to $pp1.
forall(
$r :Restriction(
patternId == $pp2.patternId,
this memberOf $pp2.items
)
Redundancy(
(
left == $r
&&
right memberOf $pp1.items
) || (
left memberOf $pp1.items
&&
right == $r
)
)
)
then
insert( new Redundancy( RedundancyType.STRONG, $pp1, $pp2 ) );
end
#
# Fires when two PatternPossibilities are redundant.
# Marks these possibilities as redundant.
#
# Dependencies:
#
# Needs at least one rule from these packages:
# package org.drools.verifier.equivalency.rules
# rule "Find equivalent Rules"
# package org.drools.verifier.redundancy.rules
# rule "Find redundant Rules, strong redundancy"
#
# And this rule:
# package org.drools.verifier.redundancy.possibilities
# rule "Find pattern possibility redundancy"
#
# Example: rule "1" Pattern( a == b) end
# rule "2" Pattern( a == b) end
#
rule "Find rule possibility redundancy"
when
$redundancy :Redundancy(
left.causeType == CauseType.RULE
)
# Find two RulePossibilities.
$rp1 :RulePossibility(
eval( ruleId == $redundancy.getLeft().getId() )
)
$rp2 :RulePossibility(
eval( ruleId == $redundancy.getRight().getId() )
)
# For every pattern possibility in $rp1 there is a redundant pattern possibility in $rp2.
forall(
$pp :PatternPossibility(
ruleId == $rp1.ruleId,
this memberOf $rp1.items
)
Redundancy(
type == RedundancyType.STRONG,
left == $pp,
right memberOf $rp2.items
)
)
# For every pattern possibility in $rp2 there is a redundant pattern possibility in $rp1.
forall(
$pp :PatternPossibility(
ruleId == $rp2.ruleId,
this memberOf $rp2.items
)
Redundancy(
type == RedundancyType.STRONG,
left == $pp,
right memberOf $rp1.items
)
)
then
insert( new Redundancy( RedundancyType.STRONG, $rp1, $rp2 ) );
end
© 2015 - 2025 Weber Informatics LLC | Privacy Policy