Package org.drools.compiler.builder.impl

Examples of org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addPackage()


        ruleDescr.addAttribute( new AttributeDescr( "dialect", "mvl" ) );
        ruleDescr.setConsequence( "" );
        pkgDescr.addRule( ruleDescr );

        final KnowledgeBuilderImpl kBuilder = new KnowledgeBuilderImpl();
        kBuilder.addPackage(pkgDescr);

        assertFalse(kBuilder.getErrors().toString(),
                    kBuilder.getErrors().isEmpty());
    }   
   
View Full Code Here


        ruleDescr.setLhs( andDescr );
        ruleDescr.setConsequence( "" );
        pkgDescr.addRule( ruleDescr );

        final KnowledgeBuilderImpl kBuilder = new KnowledgeBuilderImpl();
        kBuilder.addPackage(pkgDescr);

        assertTrue(kBuilder.getErrors().toString(),
                   kBuilder.getErrors().isEmpty());

        final RuleImpl rule = kBuilder.getPackages()[0].getRule( "Test Rule" );
View Full Code Here

public class MVELAccumulateBuilderTest {

    @Test
    public void testSimpleExpression() {
        KnowledgeBuilderImpl pkgBuilder = new KnowledgeBuilderImpl();
        pkgBuilder.addPackage( new PackageDescr( "pkg1" ) );

        InternalKnowledgePackage pkg = pkgBuilder.getPackage();
        final RuleDescr ruleDescr = new RuleDescr( "rule 1" );

        final KnowledgeBuilderConfigurationImpl conf = pkgBuilder.getBuilderConfiguration();
View Full Code Here

        accumDescr.setActionCode( "x += $price;" );
        accumDescr.setResultCode( "new Integer( x )" );
       
        //org.drools.core.rule.Package pkg = new org.kie.rule.Package( "org.kie" );
        final KnowledgeBuilderImpl pkgBuilder = new KnowledgeBuilderImpl();
        pkgBuilder.addPackage( new PackageDescr( "org.drools" ) );
        final KnowledgeBuilderConfigurationImpl conf = pkgBuilder.getBuilderConfiguration();
        PackageRegistry pkgReg = pkgBuilder.getPackageRegistry( "org.drools" );
        InternalKnowledgePackage pkg = pkgReg.getPackage();
        DialectCompiletimeRegistry dialectRegistry = pkgReg.getDialectCompiletimeRegistry();
        Dialect dialect = dialectRegistry.getDialect( "java" );
View Full Code Here

        functionImportDescr.setTarget( "java.lang.System.currentTimeMillis" );
        pkgDescr.addFunctionImport( functionImportDescr );

        pkgDescr.addRule( ruleDescr );

        builder.addPackage( pkgDescr );

        assertSame( ruleDescr,
                    mockDialect2.getRuleDescr() );
        assertTrue( mockDialect2.getImport().contains( "java.util.HashMap" ) );
        assertTrue( mockDialect2.getStaticImport().contains( "java.lang.System.currentTimeMillis" ) );
View Full Code Here

        expr.setPosition( 2 );
        expr.setType( Type.POSITIONAL );       
        pattern.addConstraint( expr );
        ruleDescr.setConsequence( "System.out.println(\"age: \" + $age);" );

        builder.addPackage( packageDescr );
        assertLength( 0,
                      builder.getErrors().getErrors() );

        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
        kbase.addKnowledgePackages(Arrays.asList( new KnowledgePackage[] { builder.getPackage() } ));
View Full Code Here

        AndDescr lhs2 = new AndDescr();
        queryDescr2.setLhs( lhs2 );
        PatternDescr pattern2 = new PatternDescr( Cheese.class.getName() );
        lhs2.addDescr( pattern2 );

        builder.addPackage( packageDescr );

        assertLength( 0,
                      builder.getErrors().getErrors() );

        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
View Full Code Here

        functionImportDescr.setTarget( "java.lang.System.currentTimeMillis" );
        pkgDescr.addFunctionImport( functionImportDescr );

        pkgDescr.addRule( ruleDescr );

        builder.addPackage( pkgDescr );

        assertSame( ruleDescr,
                    mockDialect2.getRuleDescr() );
        assertTrue( mockDialect2.getImport().contains( "java.util.HashMap" ) );
        assertTrue( mockDialect2.getStaticImport().contains( "java.lang.System.currentTimeMillis" ) );
View Full Code Here

            final PackageDescr packageDescr = xmlPackageReader.getPackageDescr();

            //          pre build the package
            final KnowledgeBuilderImpl builder = new KnowledgeBuilderImpl();
            builder.addPackage( packageDescr );
            InternalKnowledgePackage pkg = builder.getPackage();

            final LocalRuleExecutionSetProviderImpl localRuleExecutionSetProvider = new LocalRuleExecutionSetProviderImpl();
            return localRuleExecutionSetProvider.createRuleExecutionSet( pkg,
                                                                         properties );
View Full Code Here

        String drl = streamToString( is );

        DrlParser parser = new DrlParser();
        PackageDescr packageDescr = parser.parse(null, drl);
        KnowledgeBuilderImpl builder = new KnowledgeBuilderImpl();
        builder.addPackage(packageDescr);
        InternalKnowledgePackage pkg = builder.getPackage();
        KnowledgeBaseImpl ruleBase = (KnowledgeBaseImpl) KnowledgeBaseFactory.newKnowledgeBase();
        ruleBase.addPackage(pkg);

        final ReteooVisitor visitor = new ReteooVisitor( graph );
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.