Search in sources :

Example 1 with Context

use of org.kie.api.runtime.Context in project drools by kiegroup.

the class GetContextCommand method execute.

@Override
public Void execute(Context context) {
    Context returned = ((RegistryContext) context).getContextManager().getContext(name);
    ((RequestContextImpl) context).setApplicationContext(returned);
    return null;
}
Also used : RegistryContext(org.drools.core.command.impl.RegistryContext) Context(org.kie.api.runtime.Context) RequestContextImpl(org.drools.core.command.RequestContextImpl)

Example 2 with Context

use of org.kie.api.runtime.Context in project drools by kiegroup.

the class NewContextCommand method execute.

@Override
public Void execute(Context context) {
    Context returned = ((RegistryContext) context).getContextManager().createContext(name);
    ((RequestContextImpl) context).setApplicationContext(returned);
    return null;
}
Also used : RegistryContext(org.drools.core.command.impl.RegistryContext) Context(org.kie.api.runtime.Context) RequestContextImpl(org.drools.core.command.RequestContextImpl)

Example 3 with Context

use of org.kie.api.runtime.Context in project drools by kiegroup.

the class ConversationContextManager method joinConversation.

public void joinConversation(RequestContextImpl requestContext, String conversationId) {
    Context ctx = conversationContexts.get(conversationId);
    if (ctx == null) {
        throw new RuntimeException("Conversation cannot be found");
    }
    requestContext.setConversationContext(ctx);
}
Also used : Context(org.kie.api.runtime.Context)

Example 4 with Context

use of org.kie.api.runtime.Context in project drools by kiegroup.

the class SetVariableCommandFromLastReturn method execute.

public Object execute(Context context) {
    Context targetCtx;
    if (this.contextName == null) {
        targetCtx = context;
    } else {
        targetCtx = ((RegistryContext) context).getContextManager().getContext(this.contextName);
    }
    GetDefaultValue sim = (GetDefaultValue) context.get("simulator");
    Object o = sim.getObject();
    // for FactHandle's we store the handle on a map and the actual object as
    if (o instanceof FactHandle) {
        Map<String, FactHandle> handles = (Map<String, FactHandle>) targetCtx.get("h");
        if (handles == null) {
            handles = new HashMap<String, FactHandle>();
            targetCtx.set("h", handles);
        }
        handles.put(identifier, (FactHandle) o);
        o = ((InternalFactHandle) o).getObject();
    }
    targetCtx.set(identifier, o);
    return o;
}
Also used : RegistryContext(org.drools.core.command.impl.RegistryContext) Context(org.kie.api.runtime.Context) InternalFactHandle(org.drools.core.common.InternalFactHandle) FactHandle(org.kie.api.runtime.rule.FactHandle) RegistryContext(org.drools.core.command.impl.RegistryContext) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with Context

use of org.kie.api.runtime.Context in project drools by kiegroup.

the class ContextManagerImpl method createContext.

public Context createContext(String identifier) {
    Context ctx = this.contexts.get(identifier);
    if (ctx == null) {
        ctx = new ContextImpl(identifier, this, root);
        this.contexts.put(identifier, ctx);
    }
    return ctx;
}
Also used : Context(org.kie.api.runtime.Context) ContextImpl(org.drools.core.command.impl.ContextImpl)

Aggregations

Context (org.kie.api.runtime.Context)5 RegistryContext (org.drools.core.command.impl.RegistryContext)3 RequestContextImpl (org.drools.core.command.RequestContextImpl)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ContextImpl (org.drools.core.command.impl.ContextImpl)1 InternalFactHandle (org.drools.core.common.InternalFactHandle)1 FactHandle (org.kie.api.runtime.rule.FactHandle)1