Search in sources :

Example 6 with ResourceTypePackageRegistry

use of org.drools.core.definitions.ResourceTypePackageRegistry in project drools by kiegroup.

the class KnowledgePackageImpl method addProcess.

/**
 * Add a rule flow to this package.
 */
public void addProcess(Process process) {
    ResourceTypePackageRegistry rtps = getResourceTypePackages();
    ProcessPackage rtp = ProcessPackage.getOrCreate(rtps);
    rtp.add(process);
}
Also used : ProcessPackage(org.drools.core.definitions.ProcessPackage) ResourceTypePackageRegistry(org.drools.core.definitions.ResourceTypePackageRegistry)

Example 7 with ResourceTypePackageRegistry

use of org.drools.core.definitions.ResourceTypePackageRegistry 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");
    ResourceTypePackageRegistry 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) ResourceTypePackageRegistry(org.drools.core.definitions.ResourceTypePackageRegistry) InternalKnowledgeBase(org.drools.kiesession.rulebase.InternalKnowledgeBase) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage) Test(org.junit.Test)

Example 8 with ResourceTypePackageRegistry

use of org.drools.core.definitions.ResourceTypePackageRegistry in project drools by kiegroup.

the class DMNRuntimeKBWrappingIKB method getModel.

@Override
public DMNModel getModel(String namespace, String modelName) {
    Objects.requireNonNull(namespace, () -> MsgUtil.createMessage(Msg.PARAM_CANNOT_BE_NULL, "namespace"));
    Objects.requireNonNull(modelName, () -> MsgUtil.createMessage(Msg.PARAM_CANNOT_BE_NULL, "modelName"));
    InternalKnowledgePackage kpkg = (InternalKnowledgePackage) knowledgeBase.getKiePackage(namespace);
    if (kpkg == null) {
        return null;
    }
    ResourceTypePackageRegistry 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) ResourceTypePackageRegistry(org.drools.core.definitions.ResourceTypePackageRegistry) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Example 9 with ResourceTypePackageRegistry

use of org.drools.core.definitions.ResourceTypePackageRegistry in project drools by kiegroup.

the class DMNWeaverService method merge.

@Override
public void merge(KiePackage kiePkg, DMNPackage dmnpkg) {
    ResourceTypePackageRegistry registry = ((InternalKnowledgePackage) kiePkg).getResourceTypePackages();
    DMNPackageImpl existing = registry.computeIfAbsent(ResourceType.DMN, rt -> new DMNPackageImpl(dmnpkg.getNamespace()));
    for (Map.Entry<String, DMNModel> entry : dmnpkg.getAllModels().entrySet()) {
        existing.addModel(entry.getKey(), entry.getValue());
    }
    existing.addProfiles(((DMNPackageImpl) dmnpkg).getProfiles());
}
Also used : DMNPackageImpl(org.kie.dmn.core.impl.DMNPackageImpl) ResourceTypePackageRegistry(org.drools.core.definitions.ResourceTypePackageRegistry) Map(java.util.Map) DMNModel(org.kie.dmn.api.core.DMNModel) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Aggregations

ResourceTypePackageRegistry (org.drools.core.definitions.ResourceTypePackageRegistry)9 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)8 JunctionTree (org.drools.beliefs.bayes.JunctionTree)2 BayesPackage (org.drools.beliefs.bayes.assembler.BayesPackage)2 PackageRegistry (org.drools.compiler.compiler.PackageRegistry)2 PackageDescr (org.drools.drl.ast.descr.PackageDescr)2 DMNModel (org.kie.dmn.api.core.DMNModel)2 DMNPackage (org.kie.dmn.api.core.DMNPackage)2 DMNPackageImpl (org.kie.dmn.core.impl.DMNPackageImpl)2 PMMLPackageImpl (org.kie.pmml.evaluator.assembler.container.PMMLPackageImpl)2 Map (java.util.Map)1 BayesInstance (org.drools.beliefs.bayes.BayesInstance)1 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)1 ProcessPackage (org.drools.core.definitions.ProcessPackage)1 InternalKnowledgeBase (org.drools.kiesession.rulebase.InternalKnowledgeBase)1 Test (org.junit.Test)1 DMNMessage (org.kie.dmn.api.core.DMNMessage)1 DMNKnowledgeBuilderError (org.kie.dmn.core.impl.DMNKnowledgeBuilderError)1 HasNestedModels (org.kie.pmml.commons.model.HasNestedModels)1 KiePMMLModel (org.kie.pmml.commons.model.KiePMMLModel)1