Search in sources :

Example 51 with RegistryContext

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

the class ClearActivationGroupCommand method execute.

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

Example 52 with RegistryContext

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

the class ClearAgendaGroupCommand method execute.

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

Example 53 with RegistryContext

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

the class FireAllRulesCommand method execute.

public Integer execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    int fired;
    if (max != -1 && agendaFilter != null) {
        fired = ((StatefulKnowledgeSessionImpl) ksession).fireAllRules(agendaFilter, max);
    } else if (max != -1) {
        fired = ksession.fireAllRules(max);
    } else if (agendaFilter != null) {
        fired = ((StatefulKnowledgeSessionImpl) ksession).fireAllRules(agendaFilter);
    } else {
        fired = ksession.fireAllRules();
    }
    if (this.outIdentifier != null) {
        ((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, fired);
    }
    return fired;
}
Also used : ExecutionResultImpl(org.drools.core.runtime.impl.ExecutionResultImpl) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext)

Example 54 with RegistryContext

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

the class NewKieSessionCommand method execute.

public KieSession execute(Context context) {
    KieContainer kieContainer;
    if (releaseId != null) {
        // use the new API to retrieve the session by ID
        KieServices kieServices = KieServices.Factory.get();
        kieContainer = kieServices.newKieContainer(releaseId);
    } else {
        kieContainer = ((RegistryContext) context).lookup(KieContainer.class);
        if (kieContainer == null) {
            throw new RuntimeException("ReleaseId was not specfied, nor was an existing KieContainer assigned to the Registry");
        }
    }
    KieSession ksession = sessionId != null ? kieContainer.newKieSession(sessionId) : kieContainer.newKieSession();
    ((RegistryContext) context).register(KieSession.class, ksession);
    return ksession;
}
Also used : KieServices(org.kie.api.KieServices) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext) KieContainer(org.kie.api.runtime.KieContainer)

Example 55 with RegistryContext

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

the class GetSessionTimeCommand method execute.

@Override
public Long execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    SessionClock sessionClock = ksession.<SessionClock>getSessionClock();
    long result = sessionClock.getCurrentTime();
    ExecutionResultImpl results = ((RegistryContext) context).lookup(ExecutionResultImpl.class);
    if (results != null) {
        results.getResults().put(this.outIdentifier, result);
    }
    return result;
}
Also used : ExecutionResultImpl(org.drools.core.runtime.impl.ExecutionResultImpl) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext) SessionClock(org.kie.api.time.SessionClock)

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