Search in sources :

Example 41 with RegistryContext

use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.

the class GetObjectsInEntryPointCommand method execute.

public Collection execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    EntryPoint ep = ksession.getEntryPoint(entryPoint);
    Collection col = null;
    if (filter != null) {
        col = ep.getObjects(this.filter);
    } else {
        col = ep.getObjects();
    }
    if (this.outIdentifier != null) {
        List objects = new ArrayList(col);
        ((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, objects);
    }
    return col;
}
Also used : ExecutionResultImpl(org.drools.core.runtime.impl.ExecutionResultImpl) ArrayList(java.util.ArrayList) EntryPoint(org.kie.api.runtime.rule.EntryPoint) Collection(java.util.Collection) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext) ArrayList(java.util.ArrayList) List(java.util.List)

Example 42 with RegistryContext

use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.

the class HaltCommand method execute.

public Void execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    ksession.halt();
    return null;
}
Also used : KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext)

Example 43 with RegistryContext

use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.

the class InsertObjectCommand method execute.

public FactHandle execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    FactHandle factHandle;
    if (StringUtils.isEmpty(this.entryPoint)) {
        factHandle = ksession.insert(object);
    } else {
        factHandle = ksession.getEntryPoint(this.entryPoint).insert(object);
    }
    if (outIdentifier != null) {
        if (this.returnObject) {
            ((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, object);
        }
        ((RegistryContext) context).lookup(ExecutionResultImpl.class).getFactHandles().put(this.outIdentifier, factHandle);
    }
    if (disconnected) {
        DefaultFactHandle disconnectedHandle = ((DefaultFactHandle) factHandle).clone();
        disconnectedHandle.disconnect();
        return disconnectedHandle;
    }
    return factHandle;
}
Also used : DefaultFactHandle(org.drools.core.common.DefaultFactHandle) FactHandle(org.kie.api.runtime.rule.FactHandle) DefaultFactHandle(org.drools.core.common.DefaultFactHandle) ExecutionResultImpl(org.drools.core.runtime.impl.ExecutionResultImpl) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext)

Example 44 with RegistryContext

use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.

the class DeleteFromEntryPointCommand method execute.

public Void execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    ksession.getEntryPoint(entryPoint).delete(handle, fhState);
    return null;
}
Also used : KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext)

Example 45 with RegistryContext

use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.

the class EnableAuditLogCommand method execute.

@Override
public Void execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    KieServices.Factory.get().getLoggers().newFileLogger(ksession, auditLogFile);
    return null;
}
Also used : KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext)

Aggregations

RegistryContext (org.drools.core.command.impl.RegistryContext)58 KieSession (org.kie.api.runtime.KieSession)52 ExecutionResultImpl (org.drools.core.runtime.impl.ExecutionResultImpl)20 EntryPoint (org.kie.api.runtime.rule.EntryPoint)12 FactHandle (org.kie.api.runtime.rule.FactHandle)10 ArrayList (java.util.ArrayList)8 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)7 InternalFactHandle (org.drools.core.common.InternalFactHandle)6 DefaultFactHandle (org.drools.core.common.DefaultFactHandle)4 HashMap (java.util.HashMap)3 RequestContextImpl (org.drools.core.command.RequestContextImpl)3 Context (org.kie.api.runtime.Context)3 KieContainer (org.kie.api.runtime.KieContainer)3 Collection (java.util.Collection)2 List (java.util.List)2 Map (java.util.Map)2 EntryPointCreator (org.drools.core.command.EntryPointCreator)2 StatefulKnowledgeSessionImpl (org.drools.core.impl.StatefulKnowledgeSessionImpl)2 KieServices (org.kie.api.KieServices)2 CorrelationAwareProcessRuntime (org.kie.internal.process.CorrelationAwareProcessRuntime)2