JBPM4.4 动态生成transition 实现流程驳回

	/**
	 * 驳回
	 * @param task 当前执行的任务
	 * @param destActivityName 需要流转到的目的节点
	 * @param createTransitionName 动态生成的transition的名称
	 */
	protected void reject(Task task, String destActivityName,String createTransitionName ) {
		//这里不会影响事物
		EnvironmentImpl envImpl = ((EnvironmentFactory)processEngine).openEnvironment();
		try {
			
			//动态回退到“窗口收件” 
			ExecutionImpl e = (ExecutionImpl)executionService.findExecutionById(task.getExecutionId());

			ActivityImpl clerkOpinionActivityImpl = e.getActivity();
			
			ProcessDefinitionImpl processDefinitionImpl = clerkOpinionActivityImpl.getProcessDefinition();
			
			//生成一个"经办人意见"——>"窗口收件"的transition
			ActivityImpl applyActivityImpl = processDefinitionImpl.findActivity(destActivityName);
			TransitionImpl toApply = clerkOpinionActivityImpl.createOutgoingTransition();
			toApply.setSource(clerkOpinionActivityImpl);
			toApply.setDestination(applyActivityImpl);
			toApply.setName(createTransitionName);
			this.taskService.completeTask(task.getId(),createTransitionName);
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			envImpl.close();
		}
	}

 

 

 

 

你可能感兴趣的:(transition)