Activiti解析.bpmn文件获得User Task节点的CandidateUsers特性的值

时间:2022-09-29 21:47:25

参考文档:

http://www.cnblogs.com/mingforyou/p/5351332.html

http://blog.csdn.net/jackyrongvip/article/details/9256531

    /**
* getJobProcessDefinitionMap
* 查找UserTask节点中CandidateUsers不空的流程,并按照CandidateUser分类存储流程列表。
* @param @return 设定文件
* @return Map<String,Set<ProcessDefinition>> DOM对象
* @throws
* @since CodingExample Ver 1.1
*/
private Map<String,Set<ProcessDefinition>> getJobProcessDefinitionMap() {
Map<String, Set<ProcessDefinition>> jobProcessDefinitionCaditateMap = new HashMap<String,Set<ProcessDefinition>>(); List<ProcessDefinition> processDefinitionList = findLastVersionProcessDefinition(); for(ProcessDefinition processDefinition : processDefinitionList){
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
List<org.activiti.bpmn.model.Process> processList = bpmnModel.getProcesses();
if(processList != null && processList.size() > 0){
for(org.activiti.bpmn.model.Process process : processList){
if(process != null){
Collection<FlowElement> flowElementCollection = process.getFlowElements();
if(flowElementCollection != null && flowElementCollection.size() > 0){
for(FlowElement flowElement : flowElementCollection){
if(flowElement instanceof UserTask){
UserTask userTask = (UserTask)flowElement;
List<String> candidateUsers = userTask.getCandidateUsers();
if(candidateUsers != null && candidateUsers.size() > 0){
for(String candidateUser : candidateUsers){
if(!StringUtils.isBlank(candidateUser)){
Set<ProcessDefinition> processDefinitionCaditateSet = null;
if(jobProcessDefinitionCaditateMap.containsKey(candidateUser)){
processDefinitionCaditateSet = jobProcessDefinitionCaditateMap.get(candidateUser);
}else{
processDefinitionCaditateSet = new HashSet<ProcessDefinition>();
jobProcessDefinitionCaditateMap.put(candidateUser, processDefinitionCaditateSet);
}
if(!processDefinitionCaditateSet.contains(processDefinition)){
processDefinitionCaditateSet.add(processDefinition);
}
}
}
}
}
}
}
}
}
}
} return jobProcessDefinitionCaditateMap;
}