activiti工作流常用方法

	//模型实例
	BpmnModel model = repositoryService.getBpmnModel(task.getProcessDefinitionId());
	
	//节点属性
	UserTask userTask = (UserTask) model.getFlowElement(destId);
	//候选组
	List<String> groups = userTask.getCandidateGroups();
	//获取当前节点候选组角色
	List<IdentityLink> ilList = taskService.getIdentityLinksForTask(currtask.getId());
	//获取评论
	List<Comment> comlist = taskService.getTaskComments(task.getId());
	//获取附件
	List<Attachment> attachments = taskService.getTaskAttachments(taskId);
	//获取历史流程(倒叙)
	List<HistoricTaskInstance> his = historyService
	                    .createHistoricTaskInstanceQuery().finished()
	                    .orderByHistoricTaskInstanceEndTime().desc()
	                    .processInstanceId(c.getProcessInstanceId()).list();
//获取流程图所有信息
public JSONArray findHistoryTask(String processInstanceId){
	JSONArray array = new JSONArray();
	ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
	// 查询流程定义 。
	String processDefinitionId = processInstance.getProcessDefinitionId();
	//模型实例
	BpmnModel model = repositoryService.getBpmnModel(processDefinitionId);
	//由于我们这里仅仅定义了一个Process 所以获取集合中的第一个就可以
	//Process对象封装了全部的节点、连线、以及关口等信息。拿到这个对象就能够为所欲为了。
	Process process = model.getProcesses().get(0);
	//获取全部的FlowElement(流元素)信息
	Collection<FlowElement> flowElements = process.getFlowElements();
	for (FlowElement flowElement : flowElements) {
		//假设是开始节点
		if(flowElement instanceof StartEvent){
			StartEvent startEvent = (StartEvent)flowElement;
			System.out.println(startEvent);
		}
		//假设是任务节点
		if(flowElement instanceof UserTask) {
			UserTask userTask = (UserTask)flowElement;
			List<String> candidateUsers = userTask.getCandidateUsers();
			for (String string : candidateUsers) {
				System.out.println("-------"+string);
			}
			System.out.println(userTask);
		}
		//假设是结束节点
		if(flowElement instanceof EndEvent) {
			EndEvent endEvent = (EndEvent)flowElement;
			System.out.println(endEvent);
		}
		//假设是连接线
		if(flowElement instanceof SequenceFlow) {
			SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
			System.out.println(sequenceFlow);
			String name=sequenceFlow.getName();
			String str =sequenceFlow.getConditionExpression();
			String value = str.substring(str.lastIndexOf("=") + 1, str.lastIndexOf("}"));
		}
	}
}	
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值