use of org.kie.api.runtime.KieRuntimeFactory in project drools by kiegroup.
the class DMNKiePMMLTrustyInvocationEvaluator method getPMMLRuntime.
/**
* @param eventManager
* @return
*/
private PMMLRuntime getPMMLRuntime(DMNRuntimeEventManager eventManager) {
DMNRuntimeImpl dmnRuntime = (DMNRuntimeImpl) eventManager.getRuntime();
final DMNRuntimeKB runtimeKB = dmnRuntime.getRuntimeKB();
if (runtimeKB instanceof DMNRuntimeKBWrappingIKB) {
// We are in drools
return getPMMLRuntimeFromDMNRuntimeKBWrappingIKB((DMNRuntimeKBWrappingIKB) runtimeKB);
} else {
// we are in kogito
KieRuntimeFactory kieFactory = dmnRuntime.getKieRuntimeFactory(model);
return kieFactory.get(PMMLRuntime.class);
}
}
use of org.kie.api.runtime.KieRuntimeFactory in project drools by kiegroup.
the class DMNRuntimeBuilderTest method setKieRuntimeFactoryFunction.
@Test
public void setKieRuntimeFactoryFunction() {
KieRuntimeFactory toReturn = KieRuntimeFactory.of(KIE_BASE);
Function<String, KieRuntimeFactory> kieRuntimeFactoryFunction = s -> toReturn;
final DMNRuntimeImpl retrieved = (DMNRuntimeImpl) dmnRuntimeBuilder.setKieRuntimeFactoryFunction(kieRuntimeFactoryFunction).buildConfiguration().fromResources(Collections.emptyList()).getOrElseThrow(RuntimeException::new);
assertNotNull(retrieved);
KieRuntimeFactory kieRuntimeFactory = retrieved.getKieRuntimeFactory("TEST");
assertEquals(toReturn, kieRuntimeFactory);
}
use of org.kie.api.runtime.KieRuntimeFactory in project drools by kiegroup.
the class PMMLMiningModelEvaluator method getPMMLRuntime.
/**
* Retrieve the <code>PMMLRuntime</code> to be used for the given <b>segment</b>
* It creates new <code>InternalKnowledgeBase</code>s and store them in a <code>Map</code>,
* to reuse them.
* @param kModulePackageName
* @param knowledgeBase
* @param containerModelName
* @return
*/
PMMLRuntime getPMMLRuntime(final String kModulePackageName, final KieBase knowledgeBase, final String containerModelName) {
final String key = containerModelName + "_" + kModulePackageName;
InternalKnowledgeBase kieBase = MAPPED_KIEBASES.computeIfAbsent(key, s -> {
final KiePackage kiePackage = knowledgeBase.getKiePackage(kModulePackageName);
final List<KiePackage> packages = kiePackage != null ? Collections.singletonList(knowledgeBase.getKiePackage(kModulePackageName)) : Collections.emptyList();
RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setClassLoader(((RuleBase) knowledgeBase).getRootClassLoader());
InternalKnowledgeBase toReturn = KnowledgeBaseFactory.newKnowledgeBase(kModulePackageName, conf);
toReturn.addPackages(packages);
return toReturn;
});
KieRuntimeFactory kieRuntimeFactory = KieRuntimeFactory.of(kieBase);
return kieRuntimeFactory.get(PMMLRuntime.class);
}
Aggregations