Search in sources :

Example 11 with ResourceType

use of org.kie.api.io.ResourceType in project drools by kiegroup.

the class WeaverTest method testBayesPackageWeaving.

@Test
public void testBayesPackageWeaving() throws Exception {
    KnowledgeBuilderImpl kbuilder = new KnowledgeBuilderImpl();
    kbuilder.add(ResourceFactory.newClassPathResource("Garden.xmlbif", AssemblerTest.class), ResourceType.BAYES);
    InternalKnowledgeBase kbase = getKnowledgeBase();
    kbase.addPackages(kbuilder.getKnowledgePackages());
    InternalKnowledgePackage kpkg = (InternalKnowledgePackage) kbase.getKiePackage("org.drools.beliefs.bayes.integration");
    Map<ResourceType, ResourceTypePackage> map = kpkg.getResourceTypePackages();
    BayesPackage existing = (BayesPackage) map.get(ResourceType.BAYES);
    JunctionTree jtree = existing.getJunctionTree("Garden");
    assertNotNull(jtree);
}
Also used : BayesPackage(org.drools.beliefs.bayes.assembler.BayesPackage) KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) JunctionTree(org.drools.beliefs.bayes.JunctionTree) ResourceType(org.kie.api.io.ResourceType) ResourceTypePackage(org.kie.api.internal.io.ResourceTypePackage) InternalKnowledgeBase(org.drools.core.impl.InternalKnowledgeBase) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage) Test(org.junit.Test)

Example 12 with ResourceType

use of org.kie.api.io.ResourceType in project drools by kiegroup.

the class DMNRuntimeImpl method getModel.

@Override
public DMNModel getModel(String namespace, String modelName) {
    InternalKnowledgePackage kpkg = (InternalKnowledgePackage) runtime.getKieBase().getKiePackage(namespace);
    if (kpkg == null) {
        return null;
    }
    Map<ResourceType, ResourceTypePackage> map = kpkg.getResourceTypePackages();
    DMNPackage dmnpkg = (DMNPackage) map.get(ResourceType.DMN);
    return dmnpkg != null ? dmnpkg.getModel(modelName) : null;
}
Also used : DMNPackage(org.kie.dmn.api.core.DMNPackage) ResourceType(org.kie.api.io.ResourceType) ResourceTypePackage(org.kie.api.internal.io.ResourceTypePackage) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Aggregations

ResourceType (org.kie.api.io.ResourceType)12 ResourceTypePackage (org.kie.api.internal.io.ResourceTypePackage)10 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)8 Map (java.util.Map)3 BayesPackage (org.drools.beliefs.bayes.assembler.BayesPackage)3 PackageDescr (org.drools.compiler.lang.descr.PackageDescr)3 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)3 WindowDeclaration (org.drools.core.rule.WindowDeclaration)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 JunctionTree (org.drools.beliefs.bayes.JunctionTree)2 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)2 PackageRegistry (org.drools.compiler.compiler.PackageRegistry)2 Function (org.drools.core.rule.Function)2 ImportDeclaration (org.drools.core.rule.ImportDeclaration)2 DMNModel (org.kie.dmn.api.core.DMNModel)2 DMNPackageImpl (org.kie.dmn.core.impl.DMNPackageImpl)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Arrays (java.util.Arrays)1