Package org.drools.verifier.components

Examples of org.drools.verifier.components.SubPattern


    }

    private void createPatternPossibilities() {
        List<Set<VerifierComponent>> lists = patternSolver.getPossibilityLists();
        if ( lists.size() == 0 ) {
            SubPattern subPattern = newSubPattern();

            ruleSolver.add( subPattern );
            subPatterns.add( subPattern );
        } else {

            for ( Set<VerifierComponent> list : lists ) {
                SubPattern subPattern = newSubPattern();

                for ( VerifierComponent descr : list ) {
                    subPattern.add( (PatternComponent) descr );
                }

                ruleSolver.add( subPattern );
                subPatterns.add( subPattern );
            }
View Full Code Here


            }
        }
    }

    private SubPattern newSubPattern() {
        SubPattern subPattern = new SubPattern( patternSolver.getPattern(),
                                                subPatternIndex++ );

        return subPattern;
    }
View Full Code Here

                                                                         "" );

        Redundancy redundancy = new Redundancy( left,
                                                right );

        SubPattern possibility = new SubPattern( pattern,
                                                 0 );
        possibility.add( left );
        possibility.add( right );

        objects.add( left );
        objects.add( right );
        objects.add( redundancy );
        objects.add( possibility );
View Full Code Here

        VerifierRule rule = VerifierComponentMockFactory.createRule1();
        Pattern pattern = VerifierComponentMockFactory.createPattern1();

        Collection<Object> objects = new ArrayList<Object>();
        SubPattern left = new SubPattern( pattern,
                                          0 );

        SubPattern right = new SubPattern( pattern,
                                           1 );

        Redundancy redundancy = new Redundancy( left,
                                                right );
View Full Code Here

        List<Restriction> result2 = new ArrayList<Restriction>();
        result2.add( r3 );
        result2.add( r4 );

        Object[] possibilies = list.get( 0 ).getItems().toArray();
        SubPattern p1 = (SubPattern) possibilies[0];
        SubPattern p2 = (SubPattern) possibilies[1];

        /*
         * Order may change but it doesn't matter.
         */
        if ( p1.getItems().containsAll( result ) ) {
            assertTrue( p2.getItems().containsAll( result2 ) );
        } else if ( p1.getItems().containsAll( result2 ) ) {
            assertTrue( p2.getItems().containsAll( result ) );
        } else {
            fail( "No items found." );
        }
    }
View Full Code Here

        result.add( r );
        result.add( r2 );

        Set<RuleComponent> set = list.get( 0 ).getItems();
        for ( RuleComponent component : set ) {
            SubPattern possibility = (SubPattern) component;
            assertTrue( possibility.getItems().containsAll( result ) );
        }
    }
View Full Code Here

        Pattern pattern2 = VerifierComponentMockFactory.createPattern2();

        /*
         * Working pair
         */
        SubPattern pp1 = new SubPattern( pattern1,
                                         0 );
        SubPattern pp2 = new SubPattern( pattern2,
                                         0 );

        Restriction r1 = LiteralRestriction.createRestriction( pattern1,
                                                               "" );
        pp1.add( r1 );

        Restriction r2 = LiteralRestriction.createRestriction( pattern2,
                                                               "" );
        pp2.add( r2 );

        Restriction r3 = LiteralRestriction.createRestriction( pattern1,
                                                               "" );
        pp1.add( r3 );

        Restriction r4 = LiteralRestriction.createRestriction( pattern2,
                                                               "" );
        pp2.add( r4 );

        Incompatibility o1 = new Incompatibility( r1,
                                                  r2 );
        Incompatibility o2 = new Incompatibility( r3,
                                                  r4 );

        Pattern pattern3 = VerifierComponentMockFactory.createPattern( 3 );
        Pattern pattern4 = VerifierComponentMockFactory.createPattern( 4 );
        /*
         * Another working pair.
         */
        SubPattern pp3 = new SubPattern( pattern3,
                                         0 );
        SubPattern pp4 = new SubPattern( pattern4,
                                         0 );

        Restriction r5 = LiteralRestriction.createRestriction( pattern3,
                                                               "" );
        pp3.add( r5 );

        Restriction r6 = LiteralRestriction.createRestriction( pattern4,
                                                               "" );
        pp4.add( r6 );

        Restriction r7 = LiteralRestriction.createRestriction( pattern3,
                                                               "" );
        pp3.add( r7 );

        Restriction r8 = LiteralRestriction.createRestriction( pattern4,
                                                               "" );
        pp4.add( r8 );

        Incompatibility o3 = new Incompatibility( r5,
                                                  r6 );

        data.add( r1 );
View Full Code Here

                                                               "" );
        Restriction r2 = LiteralRestriction.createRestriction( pattern1,
                                                               "" );
        Incompatibility i1 = new Incompatibility( r1,
                                                  r2 );
        SubPattern pp1 = new SubPattern( pattern1,
                                         0 );
        pp1.add( r1 );
        pp1.add( r2 );

        Restriction r3 = new VariableRestriction( pattern1 );
        Restriction r4 = new VariableRestriction( pattern1 );
        Incompatibility i2 = new Incompatibility( r1,
                                                  r2 );
        SubPattern pp2 = new SubPattern( pattern1,
                                         1 );
        pp2.add( r1 );
        pp2.add( r2 );

        // This pattern does not have an error.
        Pattern pattern2 = VerifierComponentMockFactory.createPattern2();

        Restriction r5 = LiteralRestriction.createRestriction( pattern2,
                                                               "" );
        Restriction r6 = LiteralRestriction.createRestriction( pattern2,
                                                               "" );
        SubPattern pp3 = new SubPattern( pattern2,
                                         0 );
        pp3.add( r5 );
        pp3.add( r6 );

        Restriction r7 = new VariableRestriction( pattern2 );
        Restriction r8 = new VariableRestriction( pattern2 );
        Incompatibility i4 = new Incompatibility( r7,
                                                  r8 );
        SubPattern pp4 = new SubPattern( pattern2,
                                         1 );
        pp4.add( r7 );
        pp4.add( r8 );

        data.add( VerifierComponentMockFactory.createRule1() );

        data.add( pattern1 );
        data.add( r1 );
View Full Code Here

        // This rule has an error.
        VerifierRule rule1 = VerifierComponentMockFactory.createRule1();
        Pattern pattern1 = VerifierComponentMockFactory.createPattern1();

        SubPattern pp1 = new SubPattern( pattern1,
                                         0 );
        SubPattern pp2 = new SubPattern( pattern1,
                                         1 );
        Incompatibility i1 = new Incompatibility( pp1,
                                                  pp2 );
        SubRule rp1 = new SubRule( rule1,
                                   0 );
        rp1.add( pp1 );
        rp1.add( pp2 );

        SubPattern pp3 = new SubPattern( pattern1,
                                         2 );
        SubPattern pp4 = new SubPattern( pattern1,
                                         3 );
        Incompatibility i2 = new Incompatibility( pp1,
                                                  pp2 );
        SubRule rp2 = new SubRule( rule1,
                                   1 );
        rp2.add( pp1 );
        rp2.add( pp2 );

        // This pattern does not have an error.
        VerifierRule rule2 = VerifierComponentMockFactory.createRule2();
        Pattern pattern2 = VerifierComponentMockFactory.createPattern2();

        SubPattern pp5 = new SubPattern( pattern2,
                                         0 );
        SubPattern pp6 = new SubPattern( pattern2,
                                         1 );
        SubRule rp3 = new SubRule( rule2,
                                   2 );
        rp3.add( pp5 );
        rp3.add( pp6 );

        SubPattern pp7 = new SubPattern( pattern2,
                                         2 );
        SubPattern pp8 = new SubPattern( pattern2,
                                         3 );
        Incompatibility i4 = new Incompatibility( pp7,
                                                  pp8 );
        SubRule rp4 = new SubRule( rule2,
                                   3 );
View Full Code Here

        Pattern pattern = VerifierComponentMockFactory.createPattern1();

        /*
         * Working pair
         */
        SubPattern pp1 = new SubPattern( pattern,
                                         0 );
        SubPattern pp2 = new SubPattern( pattern,
                                         1 );

        Restriction r1 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp1.add( r1 );

        Restriction r2 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp2.add( r2 );

        Restriction r3 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp1.add( r3 );

        Restriction r4 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp2.add( r4 );

        Opposites o1 = new Opposites( r1,
                                      r2 );
        Opposites o2 = new Opposites( r3,
                                      r4 );

        /*
         * Pair that doesn't work.
         */
        SubPattern pp3 = new SubPattern( pattern,
                                         2 );
        SubPattern pp4 = new SubPattern( pattern,
                                         3 );

        Restriction r5 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp3.add( r5 );

        Restriction r6 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp4.add( r6 );

        Restriction r7 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp3.add( r7 );

        Restriction r8 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp4.add( r8 );

        Opposites o3 = new Opposites( r5,
                                      r6 );

        data.add( r1 );
View Full Code Here

TOP

Related Classes of org.drools.verifier.components.SubPattern

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.