use of org.drools.persistence.info.WorkItemInfo in project drools by kiegroup.
the class JPAWorkItemManager method internalAbortWorkItem.
public void internalAbortWorkItem(long id) {
PersistenceContext context = getPersistenceContext();
WorkItemInfo workItemInfo = (WorkItemInfo) context.findWorkItem(id);
// work item may have been aborted
if (workItemInfo != null) {
WorkItemImpl workItem = (WorkItemImpl) internalGetWorkItem(workItemInfo);
WorkItemHandler handler = (WorkItemHandler) this.workItemHandlers.get(workItem.getName());
if (handler != null) {
handler.abortWorkItem(workItem, this);
} else {
if (workItems != null) {
workItems.remove(id);
throwWorkItemNotFoundException(workItem);
}
}
if (workItems != null) {
workItems.remove(id);
}
context.remove(workItemInfo);
}
}
use of org.drools.persistence.info.WorkItemInfo 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.drools.persistence.info.WorkItemInfo in project drools by kiegroup.
the class JPAWorkItemManager method retryWorkItemWithParams.
public void retryWorkItemWithParams(long workItemId, Map<String, Object> map) {
Environment env = this.kruntime.getEnvironment();
WorkItem workItem = getWorkItem(workItemId);
if (workItem != null) {
workItem.setParameters(map);
WorkItemInfo workItemInfo = new WorkItemInfo(workItem, env);
PersistenceContext context = getPersistenceContext();
context.merge(workItemInfo);
retryWorkItem(workItem);
}
}
Aggregations