use of org.kie.api.runtime.process.ProcessInstance in project drools by kiegroup.
the class JPAWorkItemManager method abortWorkItem.
public void abortWorkItem(long id) {
PersistenceContext context = getPersistenceContext();
WorkItemInfo workItemInfo = null;
if (this.workItems != null) {
workItemInfo = this.workItems.get(id);
if (workItemInfo != null) {
workItemInfo = (WorkItemInfo) context.merge(workItemInfo);
}
}
if (workItemInfo == null) {
workItemInfo = (WorkItemInfo) context.findWorkItem(id);
}
// work item may have been aborted
if (workItemInfo != null) {
WorkItem workItem = (WorkItemImpl) internalGetWorkItem(workItemInfo);
ProcessInstance processInstance = kruntime.getProcessInstance(workItem.getProcessInstanceId());
workItem.setState(WorkItem.ABORTED);
// process instance may have finished already
if (processInstance != null) {
processInstance.signalEvent("workItemAborted", workItem);
}
context.remove(workItemInfo);
if (workItems != null) {
workItems.remove(workItem.getId());
}
}
}
use of org.kie.api.runtime.process.ProcessInstance in project drools by kiegroup.
the class JPAWorkItemManager method completeWorkItem.
public void completeWorkItem(long id, Map<String, Object> results) {
PersistenceContext context = getPersistenceContext();
WorkItemInfo workItemInfo = null;
if (this.workItems != null) {
workItemInfo = this.workItems.get(id);
if (workItemInfo != null) {
workItemInfo = (WorkItemInfo) context.merge(workItemInfo);
}
}
if (workItemInfo == null) {
workItemInfo = (WorkItemInfo) context.findWorkItem(id);
}
// work item may have been aborted
if (workItemInfo != null) {
WorkItem workItem = internalGetWorkItem(workItemInfo);
workItem.setResults(results);
ProcessInstance processInstance = kruntime.getProcessInstance(workItem.getProcessInstanceId());
workItem.setState(WorkItem.COMPLETED);
// process instance may have finished already
if (processInstance != null) {
processInstance.signalEvent("workItemCompleted", workItem);
}
context.remove(workItemInfo);
if (workItems != null) {
this.workItems.remove(workItem.getId());
}
}
}
use of org.kie.api.runtime.process.ProcessInstance 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;
}
use of org.kie.api.runtime.process.ProcessInstance in project drools by kiegroup.
the class DefaultWorkItemManager method abortWorkItem.
public void abortWorkItem(long id) {
WorkItemImpl workItem = (WorkItemImpl) workItems.get(new Long(id));
// work item may have been aborted
if (workItem != null) {
ProcessInstance processInstance = kruntime.getProcessInstance(workItem.getProcessInstanceId());
workItem.setState(WorkItem.ABORTED);
// process instance may have finished already
if (processInstance != null) {
processInstance.signalEvent("workItemAborted", workItem);
}
workItems.remove(new Long(id));
}
}
use of org.kie.api.runtime.process.ProcessInstance in project drools by kiegroup.
the class DefaultWorkItemManager method completeWorkItem.
public void completeWorkItem(long id, Map<String, Object> results) {
WorkItem workItem = workItems.get(new Long(id));
// work item may have been aborted
if (workItem != null) {
(workItem).setResults(results);
ProcessInstance processInstance = kruntime.getProcessInstance(workItem.getProcessInstanceId());
(workItem).setState(WorkItem.COMPLETED);
// process instance may have finished already
if (processInstance != null) {
processInstance.signalEvent("workItemCompleted", workItem);
}
workItems.remove(new Long(id));
}
}
Aggregations