package com;
import java.util.ArrayList;
import java.util.List;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.impl.RepositoryServiceImpl;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.pvm.PvmTransition;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.task.Task;
public class Text {
protected String taskId;
protected List<ChoosedActivityVO> choosedNextActivitys;//节点信息
/**
* 判断当前节点是否是包含网关的活动节点
*
* @param taskId
* @return
*/
protected void getNextNode(String taskid) {
try {
// 1、首先是根据流程ID获取当前任务:
List<Task> tasks = ProcessEngines.getDefaultProcessEngine().getTaskService().createTaskQuery()
.taskId(taskId).list();
List<String> result = new ArrayList<String>();
for (Task task : tasks) {
RepositoryService rs = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
// 2、然后根据当前任务获取当前流程的流程定义,然后根据流程定义获得所有的节点:
ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl) rs)
.getDeployedProcessDefinition(task.getProcessDefinitionId());
// ActivityImpl findActivity =
// def.findActivity("inclusivegateway1");
ActivityImpl currentActivity = def.findActivity(activityId);// 当前节点信息activityId
Boolean iscurrent = false;// 取进线的目标节点
Boolean isout = false;// 取出线的目标节点
Boolean isend = false;// 结束节点
Boolean isdeend = false;//
if (currentActivity != null) {
List<PvmTransition> currentPvmTransitions = currentActivity.getIncomingTransitions();// 取出节点的所有进来的线
List<PvmTransition> outPvmTransitions = currentActivity.getOutgoingTransitions();// 取出当前节点的所有出去的线
for (PvmTransition pvmTransition : currentPvmTransitions) {
ActivityImpl pvmActivityImpl = (ActivityImpl) pvmTransition.getSource();// 取进线的目标节点
String a = pvmActivityImpl.getId();
if (pvmActivityImpl.getId().startsWith("inclusivegateway")) {
iscurrent = true;
break;
}
}
for (PvmTransition pvmTransition : outPvmTransitions) {
ActivityImpl pvmActivityImpl = (ActivityImpl) pvmTransition.getDestination();// 取出线的目标节点
String a = pvmActivityImpl.getId();
if (pvmActivityImpl.getId().startsWith("inclusivegateway")) {
isout = true;
break;
}
}
}
if (choosedNextActivitys != null && choosedNextActivitys.size() > 0) {// choosedNextActivitys选择的活动信息
for (ChoosedActivityVO vo : choosedNextActivitys) {
// 活动名
String activityId = vo.getActivityId();
if ("endevent1".equals(activityId)) {
isend = true;
break;
}
}
}
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}