@Override
public void completeWorkItem(long id, Map<String, Object> results) {
Environment env = this.kruntime.getEnvironment();
WorkItemInfo workItemInfo = null;
workItemInfo = this.workItems.get(id);
if (workItemInfo != null) {
workItemInfo = (WorkItemInfo) GrailsIntegration.getGormDomainService()
.mergeDomain(workItemInfo);
}
if (workItemInfo == null) {
workItemInfo = GrailsIntegration.getGormDomainService()
.getWorkItemInfo(id);
}
// work item may have been aborted
if (workItemInfo != null) {
WorkItem workItem = (WorkItemImpl) workItemInfo.getWorkItem(env);
workItem.setResults(results);
ProcessInstance processInstance =
kruntime.getProcessInstance(workItem.getProcessInstanceId());
workItem.setState(WorkItem.COMPLETED);
// process instance may have finished already