use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.
the class FromExternalFactHandleCommand method execute.
public FactHandle execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
Collection<FactHandle> factHandles = ksession.getFactHandles();
int fhId = Integer.parseInt(factHandleExternalForm.split(":")[1]);
for (FactHandle factHandle : factHandles) {
if (factHandle instanceof InternalFactHandle && ((InternalFactHandle) factHandle).getId() == fhId) {
InternalFactHandle fhClone = ((InternalFactHandle) factHandle).clone();
if (disconnected) {
fhClone.disconnect();
}
return fhClone;
}
}
return null;
}
use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.
the class GetFactHandlesCommand method execute.
public Collection<FactHandle> execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
Collection<FactHandle> disconnectedFactHandles = new ArrayList<FactHandle>();
if (filter != null) {
Collection<InternalFactHandle> factHandles = ksession.getFactHandles(this.filter);
if (factHandles != null && disconnected) {
for (InternalFactHandle factHandle : factHandles) {
InternalFactHandle handle = factHandle.clone();
handle.disconnect();
disconnectedFactHandles.add(handle);
}
if (outIdentifier != null) {
((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, disconnectedFactHandles);
}
return disconnectedFactHandles;
} else {
Collection<FactHandle> ksessionFactHandles = ksession.getFactHandles(this.filter);
if (outIdentifier != null) {
((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, new ArrayList<FactHandle>(ksessionFactHandles));
}
return ksessionFactHandles;
}
} else {
Collection<InternalFactHandle> factHandles = ksession.getFactHandles();
if (factHandles != null && disconnected) {
for (InternalFactHandle factHandle : factHandles) {
InternalFactHandle handle = factHandle.clone();
handle.disconnect();
disconnectedFactHandles.add(handle);
}
if (outIdentifier != null) {
((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, disconnectedFactHandles);
}
return disconnectedFactHandles;
} else {
Collection<FactHandle> ksessionFactHandles = ksession.getFactHandles();
if (outIdentifier != null) {
((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, new ArrayList<FactHandle>(ksessionFactHandles));
}
return ksessionFactHandles;
}
}
}
use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.
the class GetObjectsCommand method execute.
public Collection execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
Collection col = null;
if (getFilter() != null) {
col = ksession.getObjects(this.filter);
} else {
col = ksession.getObjects();
}
if (this.outIdentifier != null) {
List objects = new ArrayList(col);
((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, objects);
}
return col;
}
use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.
the class ReTryWorkItemCommand method execute.
public Void execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
((org.drools.core.process.instance.WorkItemManager) ksession.getWorkItemManager()).retryWorkItem(workItemId, params);
return null;
}
use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.
the class SetProcessInstanceVariablesCommand method execute.
public Void execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
if (processInstance != null) {
if (variables != null) {
for (Map.Entry<String, Object> entry : variables.entrySet()) {
((WorkflowProcessInstance) processInstance).setVariable(entry.getKey(), entry.getValue());
}
}
}
return null;
}
Aggregations