【入门篇】Activiti流程资源文件下载保存到本地
2017-10-24 10:47
1191 查看
需求
用户或者开发人员,有时候需要对绘制好的流程文件进行查看
参考数据库
![](https://img-blog.csdn.net/20171024104916463?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemx0OTk1NzY4MDI1/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
方案
根据流程标识,查找流程定义表,然后读取到跟这个流程有关的文件,然后保存到本地或者给出界面显示,目前只做保存到本地
代码
//流程定义资源文件查询
@Test
public void queryProcessDefinitionResource() throws IOException{
//得到repositoryService
RepositoryService repositoryService = processEngine.getRepositoryService();
//根据流程定义id查询部署id
String processDefinitionId = "purchasingflow:1:4";
ProcessDefinition processDefinition = repositoryService
.createProcessDefinitionQuery()
.processDefinitionId(processDefinitionId).singleResult();
//部署id
String deploymentId = processDefinition.getDeploymentId();
//bpmn文件
//bpmn资源文件名称
String resourceName_bpmn = processDefinition.getResourceName();
//bpmn资源文件输入流
InputStream inputStream_bpmn = repositoryService.getResourceAsStream(deploymentId, resourceName_bpmn);
//png文件
//png文件名称
String resourceName_png = processDefinition.getDiagramResourceName();
//png资源文件输入流
InputStream inputStream_png = repositoryService.getResourceAsStream(deploymentId, resourceName_png);
//构造输入流
File file_bpmn = new File("d:/" + resourceName_bpmn);
File file_png = new File("d:/" + resourceName_png);
FileOutputStream fileOutputStream_bpmn = new FileOutputStream(file_bpmn);
FileOutputStream fileOutputStream_png = new FileOutputStream(file_png);
//流复制
byte[] b = new byte[1024];
int len = -1;
while((len = inputStream_bpmn.read(b,0,1024)) != -1){
fileOutputStream_bpmn.write(b,0,len);
}
while((len = inputStream_png.read(b,0,1024)) != -1){
fileOutputStream_png.write(b,0,len);
}
//关闭流
inputStream_bpmn.close();
inputStream_png.close();
fileOutputStream_bpmn.close();
fileOutputStream_png.close();
}
效果图
用户或者开发人员,有时候需要对绘制好的流程文件进行查看
参考数据库
方案
根据流程标识,查找流程定义表,然后读取到跟这个流程有关的文件,然后保存到本地或者给出界面显示,目前只做保存到本地
代码
//流程定义资源文件查询
@Test
public void queryProcessDefinitionResource() throws IOException{
//得到repositoryService
RepositoryService repositoryService = processEngine.getRepositoryService();
//根据流程定义id查询部署id
String processDefinitionId = "purchasingflow:1:4";
ProcessDefinition processDefinition = repositoryService
.createProcessDefinitionQuery()
.processDefinitionId(processDefinitionId).singleResult();
//部署id
String deploymentId = processDefinition.getDeploymentId();
//bpmn文件
//bpmn资源文件名称
String resourceName_bpmn = processDefinition.getResourceName();
//bpmn资源文件输入流
InputStream inputStream_bpmn = repositoryService.getResourceAsStream(deploymentId, resourceName_bpmn);
//png文件
//png文件名称
String resourceName_png = processDefinition.getDiagramResourceName();
//png资源文件输入流
InputStream inputStream_png = repositoryService.getResourceAsStream(deploymentId, resourceName_png);
//构造输入流
File file_bpmn = new File("d:/" + resourceName_bpmn);
File file_png = new File("d:/" + resourceName_png);
FileOutputStream fileOutputStream_bpmn = new FileOutputStream(file_bpmn);
FileOutputStream fileOutputStream_png = new FileOutputStream(file_png);
//流复制
byte[] b = new byte[1024];
int len = -1;
while((len = inputStream_bpmn.read(b,0,1024)) != -1){
fileOutputStream_bpmn.write(b,0,len);
}
while((len = inputStream_png.read(b,0,1024)) != -1){
fileOutputStream_png.write(b,0,len);
}
//关闭流
inputStream_bpmn.close();
inputStream_png.close();
fileOutputStream_bpmn.close();
fileOutputStream_png.close();
}
效果图
相关文章推荐
- php 下载保存文件保存到本地的两种方法
- java 中 excel生成并文件下载保存到本地(三)
- [工具库]JFileDownloader工具类——多线程下载网络文件,并保存在本地
- [转]使用URLConnection下载文件或图片并保存到本地
- jsp内存数据下载到本地--弹出的文件保存框时 两次调用action中下载方法问题
- Java 使用urlconnection下载文件或图片并保存到本地
- Android HTTP下载文件并保存到本地或SD卡
- 用js实现下载远程文件并保存在本地的脚本
- 如何打包Activiti的流程资源文件(bpmn20.xml、form、png)
- java提高篇(41)--urlconnection下载文件或图片并保存到本地
- 从缓存的源文件中读取资源文件,下载到本地(包括图片和样式脚本)
- iOS 将服务器下载下来的db文件和本地的db文件合并后保存
- 打包Activiti的流程资源文件(bpmn20.xml、form、png)
- 用js实现下载远程文件并保存在本地的脚本
- 根据URL下载文件到本地(将二进制文件保存到磁盘)
- ASP.NET中文件上传下载方法集合(上传限制,保存方式-二进制或文件形式,上传Internet上的资源 )
- Flex快速入门系列之五:crossdomain.xml文件创建以及允许本地跨域访问远程资源
- php 下载保存文件保存到本地
- 用LoadRunner下载文件并保存到本地
- loadrunner自动下载文件并保存到本地脚本