Package org.drools.compiler.lang.descr

Examples of org.drools.compiler.lang.descr.ExprConstraintDescr


        PatternDescr pattern = (PatternDescr) ((RuleDescr) parse( "rule",
                                                                  text )).getLhs().getDescrs().get( 0 );

        assertEquals( 4,
                      pattern.getDescrs().size() );
        ExprConstraintDescr ecd = (ExprConstraintDescr) pattern.getDescrs().get( 0 );
        assertEquals( "bigInteger == (10I)",
                      ecd.getExpression() );

        ecd = (ExprConstraintDescr) pattern.getDescrs().get( 1 );
        assertEquals( "bigDecimal == (10B)",
                      ecd.getExpression() );

        ecd = (ExprConstraintDescr) pattern.getDescrs().get( 2 );
        assertEquals( "bigInteger < 50I",
                      ecd.getExpression() );

        ecd = (ExprConstraintDescr) pattern.getDescrs().get( 3 );
        assertEquals( "bigDecimal < 50B",
                      ecd.getExpression() );
    }
View Full Code Here


        PatternDescr pattern = (PatternDescr) ((ExistsDescr) ((RuleDescr) parse( "rule",
                                                                                 text )).getLhs().getDescrs().get( 0 )).getDescrs().get( 0 );

        assertEquals( "TelephoneCall",
                      pattern.getObjectType() );
        ExprConstraintDescr constr = (ExprConstraintDescr) pattern.getConstraint().getDescrs().get( 0 );
        assertEquals( "this finishes [1m] \"25-May-2011\"",
                      constr.getText() );

    }
View Full Code Here

        PatternDescr pattern = (PatternDescr) ((RuleDescr) parse( "rule",
                                                                  text )).getLhs().getDescrs().get( 0 );

        assertEquals( "Person",
                      pattern.getObjectType() );
        ExprConstraintDescr constr = (ExprConstraintDescr) pattern.getConstraint().getDescrs().get( 0 );
        assertEquals( "eval( name.startsWith(\"b\") && name.finishesWith(\"b\"))",
                      constr.getText() );

    }
View Full Code Here

        PatternDescr pattern = (PatternDescr) ((RuleDescr) parse( "rule",
                                                                  text )).getLhs().getDescrs().get( 0 );

        assertEquals( "StockTick",
                      pattern.getObjectType() );
        ExprConstraintDescr constr = (ExprConstraintDescr) pattern.getConstraint().getDescrs().get( 0 );
        assertEquals( "this after[-*,*] $another",
                      constr.getText() );

    }
View Full Code Here

                                  final boolean isJavaDialect,
                                  final Map<String, String> boundParams,
                                  final PackageDataModelOracle dmo ) {
        for ( BaseDescr descr : constraint.getDescrs() ) {
            if ( descr instanceof ExprConstraintDescr ) {
                ExprConstraintDescr exprConstraint = (ExprConstraintDescr) descr;
                Expr expr = parseExpr( exprConstraint.getExpression(),
                                       isJavaDialect,
                                       boundParams,
                                       dmo );
                factPattern.addConstraint( expr.asFieldConstraint( m,
                                                                   factPattern ) );
View Full Code Here

        pattern.addConstraint( fieldBindingDescr );

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

        pattern.addConstraint( new ExprConstraintDescr("price == x") );

        // There is no m this should produce errors.
        ruleDescr.setConsequence( "update(m);" );

        builder.addPackage( packageDescr );
View Full Code Here

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

        pattern.addConstraint( new ExprConstraintDescr( "type == 'stilton'" ) );

        ruleDescr.setConsequence( "update(stilton);" );

        builder.addPackage( packageDescr );
View Full Code Here

        pattern.addConstraint( fieldBindingDescr );

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

        pattern.addConstraint( new ExprConstraintDescr("price == (( (Integer) map.get( new Integer( x )) ).intValue() * y)") );

        ruleDescr.setConsequence( "update(stilton);" );

        builder.addPackage( packageDescr );

View Full Code Here

        pattern.addConstraint( fieldBindingDescr2 );

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

        final ExprConstraintDescr predicate = new ExprConstraintDescr( "eval(( ( Integer )map.get( new Integer(x) )).intValue() == y)" );
        pattern.addConstraint( predicate );

        ruleDescr.setConsequence( "update(stilton);" );

        builder.addPackage( packageDescr );
View Full Code Here

    }

    @Test
    public void testNumbers() throws Exception {
        // test boolean
        createLiteralRule( new ExprConstraintDescr( "booleanPrimitive == true ") );

        // test boolean
        createLiteralRule( new ExprConstraintDescr( "booleanPrimitive == false ") );

        // test char
        createLiteralRule( new ExprConstraintDescr( "charPrimitive == 'a' ") );
        createLiteralRule( new ExprConstraintDescr( "charPrimitive == \"a\" ") );

        // test byte
        createLiteralRule( new ExprConstraintDescr( "bytePrimitive == 1 ")  );
        createLiteralRule( new ExprConstraintDescr( "bytePrimitive == 0 ")  );
        createLiteralRulenew ExprConstraintDescr( "bytePrimitive == -1 ") );

        // test short
        createLiteralRule( new ExprConstraintDescr( "shortPrimitive == 1 ")  );              
        createLiteralRulenew ExprConstraintDescr( "shortPrimitive == 0 ")  );       
        createLiteralRule( new ExprConstraintDescr( "shortPrimitive == -1 ")  );

        // test int
        createLiteralRule( new ExprConstraintDescr( "intPrimitive == 1") );
        createLiteralRulenew ExprConstraintDescr( "intPrimitive == 0") );
        createLiteralRulenew ExprConstraintDescr( "intPrimitive == -1")  );

        // test long
        createLiteralRule( new ExprConstraintDescr( "longPrimitive == 1") );
        createLiteralRule( new ExprConstraintDescr( "longPrimitive == 0") );
        createLiteralRule( new ExprConstraintDescr( "longPrimitive == -1") );

        // test float
        createLiteralRule( new ExprConstraintDescr( "floatPrimitive == 1.1") );
        createLiteralRule( new ExprConstraintDescr( "floatPrimitive == 0") );
        createLiteralRule( new ExprConstraintDescr( "floatPrimitive == -1.1") );

        // test double
        createLiteralRulenew ExprConstraintDescr( "doublePrimitive == 1.1") );
        createLiteralRulenew ExprConstraintDescr( "doublePrimitive == 0") );
        createLiteralRulenew ExprConstraintDescr( "doublePrimitive == -1.1") );
    }
View Full Code Here

TOP

Related Classes of org.drools.compiler.lang.descr.ExprConstraintDescr

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.