Activiti获取流程节点、流程图,驳回,终止

最近项目,用到流程。第一次用,就自己做了一下小结:

1.
===================================下面这段代码是获取流程线信息=============================
//
        //processDefinitionId 对应表ACT_RE_PROCDEF主键信息
        String processDefinitionId="出差:1:2549";
        //获取bpmnModel对象
        BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
        //因为我们这里只定义了一个Process 所以获取集合中的第一个即可
        Process process = bpmnModel.getProcesses().get(0);
        //获取所有的FlowElement信息
        Collection<FlowElement> flowElements = process.getFlowElements();
        for (FlowElement flowElement : flowElements) {
            //如果是任务节点
            if (flowElement instanceof UserTask) {
                UserTask userTask=(UserTask) flowElement;
                //获取入线信息
                List<SequenceFlow> incomingFlows = userTask.getIncomingFlows();
                for (SequenceFlow sequenceFlow : incomingFlows) {
                    System.out.println(sequenceFlow.getId() +"=="+sequenceFlow.getName()+"-"+sequenceFlow.getConditionExpression()+"--"+sequenceFlow.getDocumentation()+"-"
                    +sequenceFlow.getSourceRef()+"--"+sequenceFlow.getTargetRef()+"-");
                }
            }

        }

====================================================================================

2.
=========================================获取流程节点===========================================
    
        ProcessDefinitionEntity processDefinitionEntity=(ProcessDefinitionEntity)repositoryService.getProcessDefinition("请病假:1:9");
        List<ActivityImpl> activityList=processDefinitionEntity.getActivities();
        for(ActivityImpl activiti:activityList) {
                 System.out.println("节点ID:"+activiti.getId());
                 System.out.println("节点名称:"+activiti.getProperty("name"));    
        }

====================================================================================

3.
=======================================这个方法是获取流程图,节点数据=============================================

         Model modelD = repositoryService.getModel(modelId);
         BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
         //获取节点信息
         byte[] arg0 = repositoryService.getModelEditorSource(modelD.getId());
         JsonNode editorNode = new ObjectMapper().readTree(arg0);
         //将节点信息转换为xml
         BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(editorNode);
         BpmnXMLConverter xmlConverter = new BpmnXMLConverter();
         byte[] bpmn = xmlConverter.convertToXML(bpmnModel);
         String s = new String(bpmn);
         System.out.println(s);
          
         ByteArrayInputStream in = new ByteArrayInputStream(bpmn);
         IOUtils.copy(in, response.getOutputStream());

====================================================================================

4.
========================================这个方法是终止流程============================================
    /**
    *taskId:任务id
    *opinion:意见
    *
    */
    public void endTask(String taskId,String opinion){ 
        
        //根据taskID查询任务          
        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
                
        ActivityImpl endActivity = findActivitiImpl(taskId, "end");
        
        if(endActivity==null){
            return;    
        }
  
        // 获取当前活动节点ID           
        //String activityId = task.ge

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值