flowable 三种方式部署流程

1070阅读 0评论2022-05-30 fhadmin
分类:Java


点击(此处)折叠或打开


  1.     /**部署流程定义(根据ui.modeler的 modelId部署)
  2.      * @param modelId 模型ID
  3.      * @from fhadmin.cn
  4.      */
  5.     protected String deploymentProcessDefinitionFromUIModelId(String modelId) throws Exception{
  6.         Model model = modelService.getModel(modelId);
  7.         BpmnModel bpmnModel = modelService.getBpmnModel(model);
  8.         Deployment deployment = repositoryService.createDeployment()
  9.         .name(model.getName())
  10.         .addBpmnModel(model.getKey() + ".bpmn", bpmnModel).deploy();
  11.         return deployment.getId();    //部署ID
  12.     }
  13.     
  14.     /**部署流程定义(从Classpath)
  15.      * @param name        //部署名称
  16.      * @param xmlpath    //xml文件路径
  17.      * @param pngpath    //png文件路径
  18.      * @from fhadmin.cn
  19.      */
  20.     protected String deploymentProcessDefinitionFromClasspath(String name, String xmlpath, String pngpath){
  21.         DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();        //创建部署对象
  22.         deploymentBuilder.name(name);                        //部署名称
  23.         deploymentBuilder.addClasspathResource(xmlpath);    //从文件中读取xml资源
  24.         deploymentBuilder.addClasspathResource(pngpath);    //从文件中读取png资源
  25.         Deployment deployment = deploymentBuilder.deploy();    //完成部署
  26.         return deployment.getId();                            //部署ID
  27.     }
  28.     
  29.     /**部署流程定义(从zip压缩包)
  30.      * @param name        //部署名称
  31.      * @param zippath    //zip文件路径
  32.      * @from fhadmin.cn
  33.      * @throws FileNotFoundException
  34.      */
  35.     protected String deploymentProcessDefinitionFromZip(String name, String zippath) throws Exception{
  36.         File outfile = new File(zippath);
  37.         FileInputStream inputStream = new FileInputStream(outfile);
  38.         ZipInputStream ipInputStream = new ZipInputStream(inputStream);
  39.         DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();        //创建部署对象
  40.         deploymentBuilder.name(name);                        //部署名称
  41.         deploymentBuilder.addZipInputStream(ipInputStream);
  42.         Deployment deployment = deploymentBuilder.deploy();    //完成部署
  43.         ipInputStream.close();
  44.         inputStream.close();
  45.         return deployment.getId();                            //部署ID
  46.     }


上一篇:SpringBoot 2.7.0 处理跨域的问题
下一篇:springcloud 整合 druid 阿里的数据库连接池