use of org.drools.core.RuleBaseConfiguration in project drools by kiegroup.
the class PhreakNotNodeTest method createContext.
public BuildContext createContext() {
RuleBaseConfiguration conf = new RuleBaseConfiguration();
KnowledgeBaseImpl rbase = new KnowledgeBaseImpl("ID", conf);
BuildContext buildContext = new BuildContext(rbase, Collections.emptyList());
RuleImpl rule = new RuleImpl("rule1").setPackage("org.pkg1");
InternalKnowledgePackage pkg = CoreComponentFactory.get().createKnowledgePackage("org.pkg1");
pkg.getDialectRuntimeRegistry().setDialectData("java", new JavaDialectRuntimeData());
pkg.addRule(rule);
buildContext.setRule(rule);
return buildContext;
}
use of org.drools.core.RuleBaseConfiguration in project drools by kiegroup.
the class KieBaseBuilder method createKieBaseFromModel.
public static InternalKnowledgeBase createKieBaseFromModel(Collection<Model> models, KieBaseModel kieBaseModel) {
RuleBaseConfiguration kieBaseConf = new RuleBaseConfiguration();
kieBaseConf.setEventProcessingMode(kieBaseModel.getEventProcessingMode());
kieBaseConf.setSessionPoolSize(kieBaseModel.getSessionsPool().getSize());
KiePackagesBuilder builder = new KiePackagesBuilder(kieBaseConf);
models.stream().filter(m -> isPackageInKieBase(kieBaseModel, m.getPackageName())).forEach(builder::addModel);
return new KieBaseBuilder(kieBaseModel, kieBaseConf).createKieBase(builder.build());
}
use of org.drools.core.RuleBaseConfiguration 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