use of org.drools.core.command.RequestContextImpl 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;
}
use of org.drools.core.command.RequestContextImpl 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;
}
use of org.drools.core.command.RequestContextImpl in project drools by kiegroup.
the class SetCommand method execute.
@Override
public T execute(Context context) {
RequestContextImpl reqContext = (RequestContextImpl) context;
T returned = (T) reqContext.getResult();
if (scope == Scope.REQUEST) {
reqContext.set(name, returned);
} else if (scope == Scope.CONVERSATION) {
if (reqContext.getConversationContext() == null) {
throw new IllegalStateException("No Conversation Context Exists");
}
reqContext.getConversationContext().set(name, returned);
} else if (scope == Scope.APPLICATION) {
if (reqContext.getApplicationContext() == null) {
throw new IllegalStateException("No Application Context Exists");
}
reqContext.getApplicationContext().set(name, returned);
}
((RequestContextImpl) context).setLastSetOrGet(name);
return returned;
}
use of org.drools.core.command.RequestContextImpl in project drools by kiegroup.
the class ApplyPmmlModelCommand method execute.
@Override
public PMML4Result execute(Context context) {
PMML4Result resultHolder = new PMML4Result(requestData.getCorrelationId());
RequestContextImpl ctx = (RequestContextImpl) context;
KieBase kbase = ((RegistryContext) context).lookup(KieBase.class);
if (kbase == null) {
System.out.println("KieBase not found in context!");
return null;
} else {
KieContainer kcont = ((KnowledgeBaseImpl) kbase).getKieContainer();
kcont.getKieBaseNames().forEach(n -> {
System.out.println(n);
});
kbase.getKiePackages().forEach(kp -> {
System.out.println("Package: " + kp.getName());
});
}
return null;
// RuleUnitExecutor executor = RuleUnitExecutor.create().bind(kbase);
// DataSource<PMMLRequestData> data = executor.newDataSource("request", this.requestData);
// DataSource<PMML4Result> resultData = executor.newDataSource("results", resultHolder);
// System.out.println("Setting result: "+resultHolder);
// ctx.lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, resultHolder);
// return resultHolder;
}
use of org.drools.core.command.RequestContextImpl in project drools by kiegroup.
the class GetCommand method execute.
@Override
public T execute(Context context) {
RequestContextImpl reqContext = (RequestContextImpl) context;
T object = null;
if (reqContext.has(name)) {
object = (T) reqContext.get(name);
reqContext.setLastSetOrGet(name);
}
return object;
}
Aggregations