public void abortWorkItem(long id) {
Environment env = this.kruntime.getEnvironment();
// EntityManager em = (EntityManager) env.get(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER);
PersistenceContext context = ((PersistenceContextManager) env.get( EnvironmentName.PERSISTENCE_CONTEXT_MANAGER )).getCommandScopedPersistenceContext();
WorkItemInfo workItemInfo = null;
if (this.workItems != null) {
workItemInfo = this.workItems.get(id);
if (workItemInfo != null) {
workItemInfo = context.merge(workItemInfo);
}
}
if (workItemInfo == null) {
workItemInfo = context.findWorkItemInfo( id );
}
// work item may have been aborted
if (workItemInfo != null) {
WorkItem workItem = (WorkItemImpl) workItemInfo.getWorkItem(env);
ProcessInstance processInstance = kruntime.getProcessInstance(workItem.getProcessInstanceId());
workItem.setState(WorkItem.ABORTED);
// process instance may have finished already
if (processInstance != null) {
processInstance.signalEvent("workItemAborted", workItem);