TaskService taskService = env.get(TaskService.class);
TaskImpl currentTask = (TaskImpl)taskService.getTask(taskId);
ExecutionImpl exec = currentTask.getProcessInstance();
//获取当前任务的活动节点 ActivityImpl currentActivity = exec.getActivity();
//获取该活动节点的IncomingTransition TransitionImpl incomingTransition = (TransitionImpl)currentActivity.getIncomingTransitions().get(0);
//获取IncomingTransition的源活动节点 ActivityImpl sourceActivity = incomingTransition.getSource(); TransitionImpl backTransition = currentActivity.createOutgoingTransition(); //当前活动节点为新的回退Transition的源,而原来的“源”活动节点变成了目标活动节点 backTransition.setSource(currentActivity); backTransition.setDestination(sourceActivity); backTransition.setName("regect "+incomingTransition.getName()); taskService.completeTask(taskId,backTransition.getName()); return sourceActivity.getName();
}