flowable 部署流程定義(從Classpath) 和 (根據ui.modeler的 modelId部署)

FH-Admin發表於2021-11-12
    /**部署流程定義(根據ui.modeler的 modelId部署)
     * @param modelId 模型ID
     * @from  fhadmin.cn
     */
    protected String deploymentProcessDefinitionFromUIModelId(String modelId) throws Exception{
        Model model = modelService.getModel(modelId);
        BpmnModel bpmnModel = modelService.getBpmnModel(model);
        Deployment deployment = repositoryService.createDeployment()
        .name(model.getName())
        .addBpmnModel(model.getKey() + ".bpmn", bpmnModel).deploy();
        return deployment.getId();    //部署ID
    }

    /**部署流程定義(從Classpath)
     * @param name        //部署名稱
     * @param xmlpath    //xml檔案路徑
     * @param pngpath    //png檔案路徑
     * @from  fhadmin.cn
     */
    protected String deploymentProcessDefinitionFromClasspath(String name, String xmlpath, String pngpath){
        DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();        //建立部署物件
        deploymentBuilder.name(name);                        //部署名稱
        deploymentBuilder.addClasspathResource(xmlpath);    //從檔案中讀取xml資源
        deploymentBuilder.addClasspathResource(pngpath);    //從檔案中讀取png資源
        Deployment deployment = deploymentBuilder.deploy();    //完成部署
        return deployment.getId();                            //部署ID
    }
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章