use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class DroolsAbstractPMMLTest method readKnowledgeBase.
private static KieBase readKnowledgeBase(List<InputStream> theory) {
KieServices ks = KieServices.Factory.get();
KieRepository kr = ks.getRepository();
KieFileSystem kfs = ks.newKieFileSystem();
for (int j = 0; j < theory.size(); j++) {
Resource res = ks.getResources().newInputStreamResource(theory.get(j));
kfs.write(RESOURCE_PATH + "source_" + j + ".drl", res);
}
KieModuleModel model = ks.newKieModuleModel();
KieBaseModel kbModel = model.newKieBaseModel(DEFAULT_KIEBASE).setDefault(true).addPackage(BASE_PACK).setEventProcessingMode(EventProcessingOption.STREAM);
kfs.writeKModuleXML(model.toXML());
KieBuilder kb = ks.newKieBuilder(kfs);
kb.buildAll();
if (kb.getResults().hasMessages(Message.Level.ERROR)) {
throw new RuntimeException("Build Errors:\n" + kb.getResults().toString());
}
KieContainer kContainer = ks.newKieContainer(kr.getDefaultReleaseId());
return kContainer.getKieBase();
}
use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class DroolsAbstractPMMLTest method getModelSession.
protected KieSession getModelSession(String[] pmmlSources, boolean verbose) {
KieServices ks = KieServices.Factory.get();
KieRepository kr = ks.getRepository();
KieFileSystem kfs = ks.newKieFileSystem();
for (int j = 0; j < pmmlSources.length; j++) {
Resource res = ResourceFactory.newClassPathResource(pmmlSources[j]).setResourceType(ResourceType.PMML);
kfs.write(res);
}
KieModuleModel model = ks.newKieModuleModel();
model.setConfigurationProperty("drools.propertySpecific", "ALLOWED");
KieBaseModel kbModel = model.newKieBaseModel(DEFAULT_KIEBASE).setDefault(true).addPackage(BASE_PACK).setEventProcessingMode(EventProcessingOption.STREAM);
kfs.writeKModuleXML(model.toXML());
KieBuilder kb = ks.newKieBuilder(kfs);
kb.buildAll();
if (kb.getResults().hasMessages(Message.Level.ERROR)) {
throw new RuntimeException("Build Errors:\n" + kb.getResults().toString());
}
KieContainer kContainer = ks.newKieContainer(kr.getDefaultReleaseId());
KieBase kieBase = kContainer.getKieBase();
setKbase(kieBase);
return kieBase.newKieSession();
}
use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class CalendarTimerResourcesTest method init.
@Before
public void init() {
final KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
KieModuleModel kmodule = ks.newKieModuleModel();
KieBaseModel baseModel = kmodule.newKieBaseModel("defaultKBase").setDefault(true).setEventProcessingMode(EventProcessingOption.STREAM);
baseModel.newKieSessionModel("defaultKSession").setDefault(true).setClockType(ClockTypeOption.get("pseudo"));
kfs.writeKModuleXML(kmodule.toXML());
// README when path is set then test works
kfs.write(ks.getResources().newClassPathResource("calendar_timer.xls", this.getClass()));
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
assertEquals(0, kieBuilder.getResults().getMessages(org.kie.api.builder.Message.Level.ERROR).size());
ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();
clock = ksession.getSessionClock();
}
use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class PrioritySetWithFormulaTest method init.
@Before
public void init() {
final KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
KieModuleModel kmodule = ks.newKieModuleModel();
kfs.writeKModuleXML(kmodule.toXML());
kfs.write(ks.getResources().newClassPathResource("prioritySetWithFormula.xls", this.getClass()));
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
assertEquals(0, kieBuilder.getResults().getMessages(org.kie.api.builder.Message.Level.ERROR).size());
kieBase = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).getKieBase();
}
use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class DrlxCompiler method createKieFileSystem.
private static KieFileSystem createKieFileSystem(KieServices ks, ReleaseId releaseId) {
KieModuleModel kproj = ks.newKieModuleModel();
KieFileSystem kfs = ks.newKieFileSystem();
kfs.writeKModuleXML(kproj.toXML());
kfs.writePomXML(getPom(releaseId));
return kfs;
}
Aggregations