Search in sources :

Example 1 with ScriptKnowledgeBase

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();
    }
}
Also used : DefaultKnowledgeBase(org.openksavi.sponge.core.kb.DefaultKnowledgeBase) KnowledgeBase(org.openksavi.sponge.kb.KnowledgeBase) ScriptKnowledgeBase(org.openksavi.sponge.kb.ScriptKnowledgeBase) DefaultScriptKnowledgeBase(org.openksavi.sponge.core.kb.DefaultScriptKnowledgeBase) ScriptKnowledgeBase(org.openksavi.sponge.kb.ScriptKnowledgeBase) DefaultScriptKnowledgeBase(org.openksavi.sponge.core.kb.DefaultScriptKnowledgeBase)

Example 2 with ScriptKnowledgeBase

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;
}
Also used : DefaultScriptKnowledgeBase(org.openksavi.sponge.core.kb.DefaultScriptKnowledgeBase) ScriptKnowledgeBase(org.openksavi.sponge.kb.ScriptKnowledgeBase) DefaultScriptKnowledgeBase(org.openksavi.sponge.core.kb.DefaultScriptKnowledgeBase)

Aggregations

DefaultScriptKnowledgeBase (org.openksavi.sponge.core.kb.DefaultScriptKnowledgeBase)2 ScriptKnowledgeBase (org.openksavi.sponge.kb.ScriptKnowledgeBase)2 DefaultKnowledgeBase (org.openksavi.sponge.core.kb.DefaultKnowledgeBase)1 KnowledgeBase (org.openksavi.sponge.kb.KnowledgeBase)1