Search in sources :

Example 6 with RegistryContext

use of org.kie.internal.command.RegistryContext in project drools by kiegroup.

the class GetAllDMNContextCommand method execute.

@Override
public Map<String, Object> execute(Context context) {
    RegistryContext registryContext = (RegistryContext) context;
    DMNResult dmnResult = registryContext.lookup(DMNResult.class);
    if (dmnResult == null) {
        throw new IllegalStateException("There is not DMNResult available");
    }
    return dmnResult.getContext().getAll();
}
Also used : DMNResult(org.kie.dmn.api.core.DMNResult) RegistryContext(org.kie.internal.command.RegistryContext)

Example 7 with RegistryContext

use of org.kie.internal.command.RegistryContext in project drools by kiegroup.

the class GetAllDMNContextCommandTest method execute.

@Test
public void execute() {
    RegistryContext registryContext = new ContextImpl();
    GetAllDMNContextCommand getAllDMNContextCommand = new GetAllDMNContextCommand();
    assertThatThrownBy(() -> getAllDMNContextCommand.execute(registryContext)).isInstanceOf(IllegalStateException.class).hasMessage("There is not DMNResult available");
    DMNResultImpl dmnResult = new DMNResultImpl(null);
    dmnResult.setContext(new DMNContextImpl());
    registryContext.register(DMNResult.class, dmnResult);
    Map<String, Object> result = getAllDMNContextCommand.execute(registryContext);
    assertEquals(0, result.size());
}
Also used : DMNResultImpl(org.kie.dmn.core.impl.DMNResultImpl) RegistryContext(org.kie.internal.command.RegistryContext) ContextImpl(org.drools.core.command.impl.ContextImpl) DMNContextImpl(org.kie.dmn.core.impl.DMNContextImpl) DMNContextImpl(org.kie.dmn.core.impl.DMNContextImpl) Test(org.junit.Test)

Example 8 with RegistryContext

use of org.kie.internal.command.RegistryContext in project drools by kiegroup.

the class GetDMNMessagesCommandTest method execute.

@Test
public void execute() {
    RegistryContext registryContext = new ContextImpl();
    GetDMNMessagesCommand getDMNMessagesCommand = new GetDMNMessagesCommand();
    assertThatThrownBy(() -> getDMNMessagesCommand.execute(registryContext)).isInstanceOf(IllegalStateException.class).hasMessage("There is no DMNResult available");
    DMNResultImpl dmnResult = new DMNResultImpl(null);
    dmnResult.setContext(new DMNContextImpl());
    registryContext.register(DMNResult.class, dmnResult);
    List<DMNMessage> result = getDMNMessagesCommand.execute(registryContext);
    assertEquals(0, result.size());
}
Also used : DMNResultImpl(org.kie.dmn.core.impl.DMNResultImpl) DMNMessage(org.kie.dmn.api.core.DMNMessage) RegistryContext(org.kie.internal.command.RegistryContext) ContextImpl(org.drools.core.command.impl.ContextImpl) DMNContextImpl(org.kie.dmn.core.impl.DMNContextImpl) DMNContextImpl(org.kie.dmn.core.impl.DMNContextImpl) Test(org.junit.Test)

Example 9 with RegistryContext

use of org.kie.internal.command.RegistryContext in project drools by kiegroup.

the class SetDMNInputCommandTest method execute.

@Test
public void execute() {
    RegistryContext registryContext = new ContextImpl();
    String testVariable = "testVariable";
    SetDMNInputCommand setDMNInputCommand = new SetDMNInputCommand(testVariable, 10);
    setDMNInputCommand.execute(registryContext);
    DMNContext lookup = registryContext.lookup(DMNContext.class);
    assertTrue(lookup.isDefined(testVariable));
}
Also used : DMNContext(org.kie.dmn.api.core.DMNContext) RegistryContext(org.kie.internal.command.RegistryContext) ContextImpl(org.drools.core.command.impl.ContextImpl) Test(org.junit.Test)

Example 10 with RegistryContext

use of org.kie.internal.command.RegistryContext 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 : Context(org.kie.api.runtime.Context) RegistryContext(org.kie.internal.command.RegistryContext) RequestContextImpl(org.drools.core.command.RequestContextImpl)

Aggregations

RegistryContext (org.kie.internal.command.RegistryContext)126 KieSession (org.kie.api.runtime.KieSession)106 ExecutionResultImpl (org.drools.core.runtime.impl.ExecutionResultImpl)37 Context (org.kie.api.runtime.Context)27 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)27 ArrayList (java.util.ArrayList)17 FactHandle (org.kie.api.runtime.rule.FactHandle)16 Test (org.junit.Test)14 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)13 List (java.util.List)12 CaseEventSupport (org.jbpm.casemgmt.impl.event.CaseEventSupport)12 EntryPoint (org.kie.api.runtime.rule.EntryPoint)12 Map (java.util.Map)11 HashMap (java.util.HashMap)10 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)9 ExecutableCommand (org.kie.api.command.ExecutableCommand)9 WorkflowProcessInstance (org.jbpm.workflow.instance.WorkflowProcessInstance)8 NodeInstance (org.kie.api.runtime.process.NodeInstance)8 StatefulKnowledgeSession (org.kie.internal.runtime.StatefulKnowledgeSession)8 Collection (java.util.Collection)7