Examples of RuleDescr


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

        return map;
    }

    private void addRule(RuleBuildContext context) {
        final RuleDescr ruleDescr = context.getRuleDescr();

        Package pkg = context.getPkg();

        ruleBuilder.build(context);

        this.results.addAll(context.getErrors());
        this.results.addAll(context.getWarnings());

        context.getRule().setResource(ruleDescr.getResource());

        context.getDialect().addRule(context);

        if (context.needsStreamMode()) {
            pkg.setNeedStreamMode();
View Full Code Here

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

    }

    public static JavaAnalysisResult createJavaAnalysisResult(final RuleBuildContext context,
                                                               String consequenceName,
                                                               Map<String, Declaration> decls) {
        final RuleDescr ruleDescr = context.getRuleDescr();

        BoundIdentifiers bindings = new BoundIdentifiers(context.getDeclarationResolver().getDeclarationClasses( decls ),
                                                         context.getPackageBuilder().getGlobals(),
                                                         null,
                                                         KnowledgeHelper.class );

        String consequenceStr = ( Rule.DEFAULT_CONSEQUENCE_NAME.equals( consequenceName ) ) ?
                (String) ruleDescr.getConsequence() :
                (String) ruleDescr.getNamedConsequences().get( consequenceName );
        consequenceStr = consequenceStr + "\n";

        return ( JavaAnalysisResult) context.getDialect().analyzeBlock( context,
                                                                         ruleDescr,
                                                                         consequenceStr,
View Full Code Here

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

        return EXPRESSION_DIALECT_NAME;
    }

    public void addRule(RuleBuildContext context) {
        // MVEL: Compiler change
        final RuleDescr ruleDescr = context.getRuleDescr();

        // setup the line mappins for this rule
        final String name = this.pkg.getName() + "." + StringUtils.ucFirst( ruleDescr.getClassName() );
        final LineMappings mapping = new LineMappings( name );
        mapping.setStartLine( ruleDescr.getConsequenceLine() );
        mapping.setOffset( ruleDescr.getConsequenceOffset() );

        context.getPkg().getDialectRuntimeRegistry().getLineMappings().put( name,
                                                                            mapping );

    }
View Full Code Here

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

            }
            return;
        }

        while ( !roots.isEmpty() ) {
            RuleDescr root = roots.remove( 0 );
            sorted.put( root.getName(), root );
            List<RuleDescr> childz = children.remove( root.getName() );
            if ( childz != null ) {
                roots.addAll( childz );
            }
        }
View Full Code Here

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

            // TODO: process annotations

            // process pattern
            Package pkg = pkgRegistry.getPackage();
            DialectCompiletimeRegistry ctr = pkgRegistry.getDialectCompiletimeRegistry();
            RuleDescr dummy = new RuleDescr( wd.getName() + " Window Declaration" );
            dummy.addAttribute( new AttributeDescr( "dialect", "java" ) );
            RuleBuildContext context = new RuleBuildContext( this,
                                                             dummy,
                                                             ctr,
                                                             pkg,
                                                             ctr.getDialect( pkgRegistry.getDialect() ) );
View Full Code Here

Examples of org.drools.lang.descr.RuleDescr

    public void setUp() {
    }

    public void testSimpleExpression() {
        final Package pkg = new Package( "pkg1" );
        final RuleDescr ruleDescr = new RuleDescr( "rule 1" );

        PackageBuilder pkgBuilder = new PackageBuilder( pkg );
        final PackageBuilderConfiguration conf = pkgBuilder.getPackageBuilderConfiguration();
        MVELDialect mvelDialect = ( MVELDialect ) pkgBuilder.getDialectRegistry().getDialect( "mvel" );
View Full Code Here

Examples of org.drools.lang.descr.RuleDescr

        assertFalse( parser.hasErrors() );
    }

    public void testLiteralBoolAndNegativeNumbersRule() throws Exception {
        final DRLParser parser = parseResource( "literal_bool_and_negative.drl" );
        final RuleDescr rule = parser.rule();
        assertFalse( parser.hasErrors() );

        assertNotNull( rule );

        assertEquals( "simple_rule",
                      rule.getName() );
        assertNotNull( rule.getLhs() );
        assertEqualsIgnoreWhitespace( "cons();",
                                      (String) rule.getConsequence() );

        final AndDescr lhs = rule.getLhs();
        assertEquals( 3,
                      lhs.getDescrs().size() );

        PatternDescr pattern = (PatternDescr) lhs.getDescrs().get( 0 );
        assertEquals( 1,
View Full Code Here

Examples of org.drools.lang.descr.RuleDescr

        parseResource( "test_EmptyPattern.drl" );
        this.parser.compilation_unit();
        final PackageDescr packageDescr = this.parser.getPackageDescr();
        assertEquals( 1,
                      packageDescr.getRules().size() );
        final RuleDescr ruleDescr = (RuleDescr) packageDescr.getRules().get( 0 );
        assertEquals( "simple rule",
                      ruleDescr.getName() );
        assertNotNull( ruleDescr.getLhs() );
        assertEquals( 1,
                      ruleDescr.getLhs().getDescrs().size() );
        final PatternDescr patternDescr = (PatternDescr) ruleDescr.getLhs().getDescrs().get( 0 );
        assertEquals( 0,
                      patternDescr.getConstraint().getDescrs().size() ); //this may be null, not sure as the test doesn't get this far...
        assertEquals( "Cheese",
                      patternDescr.getObjectType() );
View Full Code Here

Examples of org.drools.lang.descr.RuleDescr

    }

    public void testSimpleMethodCallWithFrom() throws Exception {

        final RuleDescr rule = parseResource( "test_SimpleMethodCallWithFrom.drl" ).rule();
        final PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get( 0 );
        final FromDescr from = (FromDescr) pattern.getSource();
        final AccessorDescr method = (AccessorDescr) from.getDataSource();

        assertFalse( this.parser.getErrorMessages().toString(),
                     this.parser.hasErrors() );
View Full Code Here

Examples of org.drools.lang.descr.RuleDescr

                      method.toString() );
    }

    public void testSimpleFunctionCallWithFrom() throws Exception {

        final RuleDescr rule = parseResource( "test_SimpleFunctionCallWithFrom.drl" ).rule();
        final PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get( 0 );
        final FromDescr from = (FromDescr) pattern.getSource();
        final AccessorDescr func = (AccessorDescr) from.getDataSource();

        assertFalse( this.parser.getErrorMessages().toString(),
                     this.parser.hasErrors() );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.