[心缘地方]同学录
首页 | 功能说明 | 站长通知 | 最近更新 | 编码查看转换 | 代码下载 | 常见问题及讨论 | 《深入解析ASP核心技术》 | 王小鸭自动发工资条VBA版
登录系统:用户名: 密码: 如果要讨论问题,请先注册。

[备忘]activiti生成流程图,ProcessDiagramGenerator API不能用了,版本 5.19.0.2

上一篇:[备忘]Word,标题一,章节名称,自动编号,怎么去掉前面的数字?
下一篇:[备忘]java导入https的证书

添加日期:2016/4/7 20:34:02 快速返回   返回列表 阅读11169次
如题,网上搜了一段生成流程图的代码,却找不到ProcessDiagramGenerator类。

搜了下,是说,ProcessDiagramGenerator这个类已经移出来了,单独是一个依赖。

在此:
http://mvnrepository.com/artifact/org.activiti/activiti-image-generator

那么,在Pom.xml中增加


<dependency>
    <groupId>org.activiti</groupId>
    <artifactId>activiti-image-generator</artifactId>
    <version>5.19.0.2</version>
</dependency>


即可。

写法也有点变化,原来是静态方法调用,现在得new一个了。

代码大概是这样:


@RequestMapping("getPiImage")
    public void xx(String processInstanceId, HttpServletResponse response)
            throws IOException {
        if (processInstanceId == null) {
            throw new ActivitiIllegalArgumentException(
                    "No process instance id provided");
        }

        ExecutionEntity pi = (ExecutionEntity) runtimeService
                .createProcessInstanceQuery()
                .processInstanceId(processInstanceId).singleResult();

        if (pi == null) {
            throw new ActivitiObjectNotFoundException(
                    "Process instance with id" + processInstanceId
                            + " could not be found", ProcessInstance.class);
        }

        ProcessDefinitionEntity pde = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
                .getDeployedProcessDefinition(pi.getProcessDefinitionId());

        if (pde != null && pde.isGraphicalNotationDefined()) {
            BpmnModel bpmnModel = repositoryService.getBpmnModel(pde.getId());
            ProcessDiagramGenerator ge = new DefaultProcessDiagramGenerator();
            InputStream resource = ge.generateDiagram(bpmnModel, "png",
                    runtimeService.getActiveActivityIds(processInstanceId),
                    new ArrayList<String>(), "宋体", "宋体", null, 1.0d);

            int len = 0;
            byte[] b = new byte[1024];
            while ((len = resource.read(b, 0, 1024)) != -1) {
                response.getOutputStream().write(b, 0, len);
            }

        } else {
            throw new ActivitiException("Process instance with id "
                    + processInstanceId + " has no graphic description");
        }

    }



 

评论 COMMENTS
guest86066809
2020/2/16 22:21:54
代码太老了
guest753891372
2021/6/2 17:00:13
帮大忙了
guest65143611
2021/8/15 21:16:01
挺好

添加评论 Add new comment.
昵称 Name:
评论内容 Comment:
验证码(不区分大小写)
Validation Code:
(not case sensitive)
看不清?点这里换一张!(Change it here!)
 
评论由管理员查看后才能显示。the comment will be showed after it is checked by admin.
CopyRight © 心缘地方 2005-2999. All Rights Reserved