flowable 部署流程的三種方式

fhadmin 發表於 2022-01-14
 
	/**部署流程定義(根據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
	}
	
	/**部署流程定義(從zip壓縮包)
	 * @param name		//部署名稱
	 * @param zippath	//zip檔案路徑
	 * @from fhadmin.cn
	 * @throws FileNotFoundException 
	 */
	protected String deploymentProcessDefinitionFromZip(String name, String zippath) throws Exception{
		File outfile = new File(zippath);
		FileInputStream inputStream = new FileInputStream(outfile);
		ZipInputStream ipInputStream = new ZipInputStream(inputStream);
		DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();		//建立部署物件
		deploymentBuilder.name(name);						//部署名稱
		deploymentBuilder.addZipInputStream(ipInputStream);
		Deployment deployment = deploymentBuilder.deploy();	//完成部署
		ipInputStream.close();
		inputStream.close();
		return deployment.getId();							//部署ID
	}


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31558068/viewspace-2852293/,如需轉載,請註明出處,否則將追究法律責任。