}
}
}
// 恢复所有的FromTaskInstance
INetInstance netInstance = rtCtx.getKernelManager().getNetInstance(
workflowProcess.getId(),
workItem.getTaskInstance().getVersion());
if (netInstance == null) {
throw new EngineException(thisTaskInstance.getProcessInstanceId(),
thisTaskInstance.getWorkflowProcess(), thisTaskInstance
.getTaskId(),
"Not find the net instance for workflow process [id="
+ workflowProcess.getId() + ", version="
+ workItem.getTaskInstance().getVersion() + "]");
}
// 执行reject操作。
IWorkflowSession session = ((IWorkflowSessionAware) workItem)
.getCurrentWorkflowSession();
session.setWithdrawOrRejectOperationFlag(true);
int newStepNumber = thisTaskInstance.getStepNumber() + 1;
try {
// 首先将本WorkItem和TaskInstance cancel掉。
workItem.setComments(comments);
((WorkItem) workItem).setState(IWorkItem.CANCELED);
((WorkItem) workItem).setEndTime(rtCtx.getCalendarService()
.getSysDate());
rtCtx.getPersistenceService().saveOrUpdateWorkItem(workItem);
persistenceService.abortTaskInstance(thisTaskInstance);
// 删除本环节的token
persistenceService.deleteTokensForNode(thisTaskInstance
.getProcessInstanceId(), thisTaskInstance.getActivityId());
IActivityInstance fromActivityInstance = null;
for (int i = 0; i < fromActivityIdList.size(); i++) {
String fromActivityId = (String) fromActivityIdList.get(i);
Object obj = netInstance.getWFElementInstance(fromActivityId);
fromActivityInstance = (IActivityInstance) obj;
Token newToken = new Token();
((Token) newToken).setAlive(true);
((Token) newToken).setNodeId(fromActivityId);
newToken.setProcessInstanceId(thisTaskInstance