use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.
the class AdvanceSessionTimeCommand method execute.
@Override
public Long execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
SessionPseudoClock sessionClock = ksession.<SessionPseudoClock>getSessionClock();
sessionClock.advanceTime(amount, unit);
long result = sessionClock.getCurrentTime();
ExecutionResultImpl results = ((RegistryContext) context).lookup(ExecutionResultImpl.class);
if (results != null) {
results.getResults().put(this.outIdentifier, result);
}
return result;
}
use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.
the class DisposeCommand method execute.
public Void execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
ksession.dispose();
return null;
}
use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.
the class GetGlobalCommand method execute.
public Object execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
Object object = ksession.getGlobal(identifier);
ExecutionResultImpl results = ((RegistryContext) context).lookup(ExecutionResultImpl.class);
if (results != null) {
results.getResults().put((this.outIdentifier != null) ? this.outIdentifier : this.identifier, object);
}
return object;
}
use of org.drools.core.command.impl.RegistryContext 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.impl.RegistryContext in project drools by kiegroup.
the class SetGlobalCommand method execute.
public Object execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
if (this.outIdentifier != null) {
((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, object);
}
ksession.setGlobal(this.identifier, this.object);
// returning the object is necessary for drools-simulator
return this.object;
}
Aggregations