Package org.drools.lang.descr

Examples of org.drools.lang.descr.FieldConstraintDescr


        ruleDescr.setLhs( lhs );

        final PatternDescr patternDescr = new PatternDescr( Cheese.class.getName(),
                                                            "stilton" );

        final FieldConstraintDescr literalDescr = new FieldConstraintDescr( "type" );
        literalDescr.addRestriction( new LiteralRestrictionDescr( "==",
                                                                  null ) );

        patternDescr.addConstraint( literalDescr );

        ruleDescr.setConsequence( "" );
View Full Code Here


        final PatternDescr pattern = new PatternDescr( Cheese.class.getName(),
                                                       "stilton" );
        lhs.addDescr( pattern );

        final FieldConstraintDescr literalDescr = new FieldConstraintDescr( "type" );
        literalDescr.addRestriction( new VariableRestrictionDescr( "==",
                                                                   "$type" ) );

        pattern.addConstraint( literalDescr );

        queryDescr.setConsequence( "update(stilton);" );
View Full Code Here

        packageDescr.addRule( ruleDescr );
        AndDescr lhs = new AndDescr();
        ruleDescr.setLhs( lhs );
        PatternDescr patternDescr = new PatternDescr( Cheese.class.getName(),
                                                      "stilton" );
        FieldConstraintDescr literalDescr = new FieldConstraintDescr( "type" );
        literalDescr.addRestriction( new LiteralRestrictionDescr( "==",
                                                                  null ) );
        patternDescr.addConstraint( literalDescr );
        ruleDescr.setConsequence( "" );

        ruleDescr = new RuleDescr( "rule-1" );
        ruleDescr.setLocation( 42,
                               43 );
        packageDescr.addRule( ruleDescr );
        lhs = new AndDescr();
        ruleDescr.setLhs( lhs );
        patternDescr = new PatternDescr( Cheese.class.getName(),
                                         "stilton" );
        literalDescr = new FieldConstraintDescr( "type" );
        literalDescr.addRestriction( new LiteralRestrictionDescr( "!=",
                                                                  null ) );
        patternDescr.addConstraint( literalDescr );
        ruleDescr.setConsequence( "" );

        ruleDescr = new RuleDescr( "rule-2" );
        ruleDescr.setLocation( 42,
                               43 );
        packageDescr.addRule( ruleDescr );
        lhs = new AndDescr();
        ruleDescr.setLhs( lhs );
        patternDescr = new PatternDescr( Cheese.class.getName(),
                                         "stilton" );

        literalDescr = new FieldConstraintDescr( "type" );
        literalDescr.addRestriction( new LiteralRestrictionDescr( "!=",
                                                                  null ) );

        patternDescr.addConstraint( literalDescr );
        ruleDescr.setConsequence( "" );
View Full Code Here

        lhs.addDescr( pattern1 );

        final FieldBindingDescr fieldBindingDescr = new FieldBindingDescr( "type",
                                                                           "$type" );

        final FieldConstraintDescr literalDescr = new FieldConstraintDescr( "type" );
        literalDescr.addRestriction( new LiteralRestrictionDescr( "==",
                                                                  "stilton" ) );

        pattern1.addConstraint( fieldBindingDescr );
        pattern1.addConstraint( literalDescr );
View Full Code Here

        pattern.addConstraint( fieldBindingDescr );

        packageDescr.addGlobal( new GlobalDescr( "map",
                                                 "java.util.Map" ) );

        final FieldConstraintDescr returnValue = new FieldConstraintDescr( "price" );
        returnValue.addRestriction( new ReturnValueRestrictionDescr( "==",
                                                                     expression ) );

        pattern.addConstraint( returnValue );

        ruleDescr.setConsequence( "update(stilton);" );
View Full Code Here

        lhs.addDescr( (BaseDescr) ceDescr );

        final PatternDescr patternDescr = new PatternDescr( Cheese.class.getName(),
                                                            "stilton" );

        final FieldConstraintDescr literalDescr = new FieldConstraintDescr( "type" );
        literalDescr.addRestriction( new LiteralRestrictionDescr( "==",
                                                                  "stilton" ) );

        patternDescr.addConstraint( literalDescr );

        ceDescr.addDescr( patternDescr );
View Full Code Here

                                                     "lhs_pattern",
                                                     text );

        assertEquals( 2,
                      pattern.getDescrs().size() );
        FieldConstraintDescr fcd = (FieldConstraintDescr) pattern.getDescrs().get( 0 );
        assertEquals( "age",
                      fcd.getFieldName() );
        fcd = (FieldConstraintDescr) pattern.getDescrs().get( 1 );
        assertEquals( "location",
                      fcd.getFieldName() );
    }
View Full Code Here

        assertEquals( 1,
                      pattern.getDescrs().size() );
        OrDescr or = (OrDescr) pattern.getDescrs().get( 0 );
        assertEquals( 2,
                      or.getDescrs().size() );
        FieldConstraintDescr fcd = (FieldConstraintDescr) or.getDescrs().get( 0 );
        assertEquals( "age",
                      fcd.getFieldName() );
        fcd = (FieldConstraintDescr) or.getDescrs().get( 1 );
        assertEquals( "location",
                      fcd.getFieldName() );
    }
View Full Code Here

                      or.getDescrs().size() );

        AndDescr and = (AndDescr) or.getDescrs().get( 0 );
        assertEquals( 2,
                      and.getDescrs().size() );
        FieldConstraintDescr fcd = (FieldConstraintDescr) and.getDescrs().get( 0 );
        assertEquals( "age",
                      fcd.getFieldName() );
        assertEquals( "<",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getEvaluator() );
        assertEquals( "42",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getText() );
        fcd = (FieldConstraintDescr) and.getDescrs().get( 1 );
        assertEquals( "location",
                      fcd.getFieldName() );
        assertEquals( "==",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getEvaluator() );
        assertEquals( "atlanta",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getText() );

        and = (AndDescr) or.getDescrs().get( 1 );
        assertEquals( 2,
                      and.getDescrs().size() );
        fcd = (FieldConstraintDescr) and.getDescrs().get( 0 );
        assertEquals( "age",
                      fcd.getFieldName() );
        assertEquals( ">",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getEvaluator() );
        assertEquals( "20",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getText() );
        fcd = (FieldConstraintDescr) and.getDescrs().get( 1 );
        assertEquals( "location",
                      fcd.getFieldName() );
        assertEquals( "==",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getEvaluator() );
        assertEquals( "Seatle",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getText() );

        fcd = (FieldConstraintDescr) or.getDescrs().get( 2 );
        assertEquals( "location",
                      fcd.getFieldName() );
        assertEquals( "==",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getEvaluator() );
        assertEquals( "Chicago",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getText() );

    }
View Full Code Here

                      or1.getDescrs().size() );

        AndDescr and1 = (AndDescr) or1.getDescrs().get( 0 );
        assertEquals( 2,
                      and1.getDescrs().size() );
        FieldConstraintDescr fcd = (FieldConstraintDescr) and1.getDescrs().get( 0 );
        assertEquals( "age",
                      fcd.getFieldName() );
        assertEquals( "<",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getEvaluator() );
        assertEquals( "42",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getText() );

        OrDescr or2 = (OrDescr) and1.getDescrs().get( 1 );
        fcd = (FieldConstraintDescr) or2.getDescrs().get( 0 );
        assertEquals( "location",
                      fcd.getFieldName() );
        assertEquals( "==",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getEvaluator() );
        assertEquals( "atlanta",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getText() );

        AndDescr and2 = (AndDescr) or2.getDescrs().get( 1 );
        assertEquals( 2,
                      and2.getDescrs().size() );
        fcd = (FieldConstraintDescr) and2.getDescrs().get( 0 );
        assertEquals( "age",
                      fcd.getFieldName() );
        assertEquals( ">",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getEvaluator() );
        assertEquals( "20",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getText() );
        fcd = (FieldConstraintDescr) and2.getDescrs().get( 1 );
        assertEquals( "location",
                      fcd.getFieldName() );
        assertEquals( "==",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getEvaluator() );
        assertEquals( "Seatle",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getText() );

        fcd = (FieldConstraintDescr) or1.getDescrs().get( 1 );
        assertEquals( "location",
                      fcd.getFieldName() );
        assertEquals( "==",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getEvaluator() );
        assertEquals( "Chicago",
                      ((LiteralRestrictionDescr) fcd.getRestrictions().get( 0 )).getText() );
    }
View Full Code Here

TOP

Related Classes of org.drools.lang.descr.FieldConstraintDescr

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.