activity(三)

博客介绍了流程图查找相关内容,包括获取流程定义的流程图并与流程实例的流程图作区分。还阐述了runtimeService.startProcessInstanceByKey()和runtimeService.startProcessInstanceById()的区别,前者默认启动最新版部署信息,后者可根据流程定义ID部署以前版本。

 1.

The process definition id attribute in the XML file is used as the process definition key property.

The process definition name attribute in the XML file is used as the process definition name property. If the name attribute is not specified, then id attribute is used as the name.

//XML文件中的流程定义ID属性用作流程定义key属性。



//XML文件中的流程定义name属性用作流程定义name属性。如果未指定name属性,则使用id属性作为名称。

2.流程图查找

If an image resource exists in the deployment that has a name of the BPMN 2.0 XML file name concatenated with the process key and an image suffix, this image is used. In our example, this would be org/activiti/expenseProcess.expense.png (or .jpg/gif). In case you have multiple images defined in one BPMN 2.0 XML file, this approach makes most sense. Each diagram image will then have the process key in its file name.

If no such image exists, am image resource in the deployment matching the name of the BPMN 2.0 XML file is searched for. In our example this would be org/activiti/expenseProcess.png


//首先寻找与流程定义的xml文件名称相同并且流程定义的ID相同且带有图片后缀(.png/.gif等)等图片
//即xml文件名.流程定义的key.png


//若无则寻找与xml文件名相同以图片后缀结尾的

2.1获取流程定义的流程图,区别与流程实例的流程图:

@RequestMapping(value = "/image")
    @ResponseBody
    public void getImage(HttpServletResponse response) {

        InputStream inputStream=null;
        OutputStream os=null;

        ProcessDefinition processDefinition =repositoryService.createProcessDefinitionQuery()
                .processDefinitionId("bbb1:1:db07dc52-6efc-11e9-879e-aa801846c666").singleResult();

        //方式一
        String diagramResourceName=processDefinition.getDiagramResourceName();
        //方式二
//        InputStream inputStream =repositoryService.getResourceAsStream(processDefinition.getDeploymentId(),diagramResourceName);
        inputStream=repositoryService.getProcessDiagram(processDefinition.getId());
        response.setContentType("image/png");

        try {
            os= response.getOutputStream();
            IOUtils.copy(inputStream, os);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                if (os != null) {
                        os.flush();
                        os.close();
                    }
                    if (inputStream != null) {
                        inputStream.close();
                    }

                }catch (IOException e) {
                    e.printStackTrace();
                }

        }



    }

3.runtimeService.startProcessInstanceByKey()和runtimeService.startProcessInstanceById()区别

前者默认启动最新版的部署信息,因为无论部署多少个版本,key都是不变的。

而startProcessInstanceById方法是根据流程定义的ID进行部署的,所以可以部署以前的版本。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值