Package org.kie.api

Examples of org.kie.api.KieBase





    protected KieSession getSession(String theory) {
        KieBase kbase = readKnowledgeBase( new ByteArrayInputStream( theory.getBytes() ) );
        return kbase != null ? kbase.newKieSession() : null;
    }
View Full Code Here


        if ( res.hasMessages( Message.Level.ERROR ) ) {
            System.out.println( res.getMessages( Message.Level.ERROR ) );
        }
        assertEquals( 0, res.getMessages( Message.Level.ERROR ).size() );

        KieBase kieBase = ks.newKieContainer( ks.getRepository().getDefaultReleaseId() ).getKieBase();

        FactType ft = kieBase.getFactType( "test", "MyAdapter" );
        assertTrue( ft != null );
        assertTrue( ft.getFactClass().isInterface() );

        FactType fto = kieBase.getFactType( "test", "MyOutAdapter" );
        assertTrue( fto != null );

        assertTrue( fto.getFactClass().isInterface() );
    }
View Full Code Here

                     "";

        KieBuilder kieBuilder = build(drl);

        assertFalse( kieBuilder.getResults().hasMessages( Message.Level.ERROR ) );
        KieBase kieBase = KieServices.Factory.get().newKieContainer( kieBuilder.getKieModule().getReleaseId() ).getKieBase();

        FactType type = kieBase.getFactType( "org.drools.compiler", "Person" );

    }
View Full Code Here

                     "end \n";

        KieBuilder kieBuilder = build(drl);

        assertFalse( kieBuilder.getResults().hasMessages( Message.Level.ERROR ) );
        KieBase kieBase = KieServices.Factory.get().newKieContainer( kieBuilder.getKieModule().getReleaseId() ).getKieBase();

        FactType factType = kieBase.getFactType("org.test", "Pet");
        Object instance = factType.newInstance();
        factType.get(instance, "unknownField");
        factType.set(instance, "unknownField", "myValue");
    }
View Full Code Here

                     "end\n";

        KieBuilder kieBuilder = build(drl);

        assertFalse(kieBuilder.getResults().hasMessages(Message.Level.ERROR));
        KieBase kieBase = KieServices.Factory.get().newKieContainer( kieBuilder.getKieModule().getReleaseId() ).getKieBase();

        FactType factType = kieBase.getFactType( "org.test", "Person" );
        Object instance = factType.newInstance();
        factType.set(instance, "name", "Mark");
        factType.set(instance, "age", 37);

        List<String> names = new ArrayList<String>();
        KieSession ksession = kieBase.newKieSession();
        ksession.setGlobal("names", names);

        ksession.insert(instance);
        ksession.fireAllRules();
View Full Code Here

                     "end\n";

        KieBuilder kieBuilder = build(drl);

        assertFalse(kieBuilder.getResults().hasMessages(Message.Level.ERROR));
        KieBase kieBase = KieServices.Factory.get().newKieContainer( kieBuilder.getKieModule().getReleaseId() ).getKieBase();

        FactType factType = kieBase.getFactType("org.test", "Person");
        Object instance = factType.newInstance();
        factType.set(instance, "name", "Mark");
        factType.set(instance, "age", 37);

        List<String> names = new ArrayList<String>();
        KieSession ksession = kieBase.newKieSession();
        ksession.setGlobal("names", names);

        ksession.insert(instance);
        ksession.fireAllRules();
View Full Code Here

        List<Message> msg = helper.verify().getMessages( Message.Level.ERROR );
        System.out.println( msg );
        assertEquals( 0, msg.size() );

        KieBase kieBase = helper.build();
        FactType type = kieBase.getFactType( "org.kie1", "Foo" );
        assertEquals( 2, type.getFields().size() );

        Object foo = null;
        try {
            foo = type.newInstance();
            type.set( foo, "name", "bar" );
            assertEquals( "bar", type.get( foo, "name" ) );
        } catch ( InstantiationException e ) {
            fail( e.getMessage() );
        } catch ( IllegalAccessException e ) {
            fail( e.getMessage() );
        }

        KieSession session = kieBase.newKieSession();
        FactHandle handle = session.insert( foo );
        int n = session.fireAllRules( 5 );

        assertTrue( handle instanceof EventFactHandle );
        assertEquals( 1, n );
View Full Code Here

                        fileCount += newKM.addResourceToCompiler(ckbuilder, resourceName) ? 1 : 0;
                    }
                }
            }

            KieBase kBase = kBaseEntry.getValue();
            for ( ResourceChangeSet.RuleLoadOrder loadOrder : rcs.getLoadOrder() ) {
              KnowledgePackageImpl pkg = (KnowledgePackageImpl)kBase.getKiePackage( loadOrder.getPkgName() );
              if( pkg != null ) {
                  RuleImpl rule = pkg.getRule( loadOrder.getRuleName() );
                  if ( rule != null ) {
                      // rule can be null, if it didn't exist before
                      rule.setLoadOrder( loadOrder.getLoadOrder() );
View Full Code Here

    public Results verify(String... kModelNames) {
        return this.kProject.verify( kModelNames );
    }

    public KieBase getKieBase(String kBaseName) {
        KieBase kBase = kBases.get( kBaseName );
        if ( kBase == null ) {
            ResultsImpl msgs = new ResultsImpl();
            kBase = createKieBase(kBaseName, kProject, msgs, null);
            if ( kBase == null ) {
                // build error, throw runtime exception
View Full Code Here

        return newKieBase(defaultKieBaseModel.getName(), conf);
    }

    public KieBase newKieBase(String kBaseName, KieBaseConfiguration conf) {
        ResultsImpl msgs = new ResultsImpl();
        KieBase kBase = createKieBase(kBaseName, kProject, msgs, conf);
        if ( kBase == null ) {
            // build error, throw runtime exception
            throw new RuntimeException( "Error while creating KieBase" + msgs.filterMessages( Level.ERROR  ) );
        }
        return kBase;
View Full Code Here

TOP

Related Classes of org.kie.api.KieBase

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.