use of org.openksavi.sponge.kb.ScriptKnowledgeBase in project sponge by softelnet.
the class DefaultKnowledgeBaseManager method onInitializeKnowledgeBases.
/**
* Initialize knowledge bases.
*/
protected void onInitializeKnowledgeBases() {
for (KnowledgeBase knowledgeBase : knowledgeBases.values()) {
if (knowledgeBase instanceof ScriptKnowledgeBase) {
ScriptKnowledgeBase scriptKnowledgeBase = (ScriptKnowledgeBase) knowledgeBase;
if (knowledgeBase.getType() == null) {
knowledgeBase.setType(inferKnowledgeBaseType(scriptKnowledgeBase.getName(), scriptKnowledgeBase.getScripts()));
}
verifyKnowledgeBaseFileTypes(scriptKnowledgeBase);
}
if (knowledgeBase.getInterpreter() == null) {
knowledgeBase.setInterpreter(createKnowledgeBaseInterpreter(knowledgeBase.getType().getTypeCode(), knowledgeBase));
}
if (knowledgeBase instanceof ScriptKnowledgeBase) {
((ScriptKnowledgeBase) knowledgeBase).load();
}
knowledgeBase.onInit();
}
}
use of org.openksavi.sponge.kb.ScriptKnowledgeBase in project sponge by softelnet.
the class EngineBuilder method knowledgeBase.
/**
* Adds the knowledge base.
*
* @param name the knowledge base name.
* @param type the knowledge base type.
* @param scripts the knowledge base scripts.
* @return this Engine Builder.
*/
public EngineBuilder<T> knowledgeBase(String name, KnowledgeBaseType type, List<KnowledgeBaseScript> scripts) {
ScriptKnowledgeBase knowledgeBase = new DefaultScriptKnowledgeBase(name, type);
scripts.forEach(script -> knowledgeBase.addScript(script));
knowledgeBases.add(knowledgeBase);
return this;
}
Aggregations