《Activiti/Flowable 深入BPM工作流》-流程定義怎麼進行刪除?
一. 問題
之前我們分享過流程定義的流程任務查詢, 流程任務處理,
任務那麼怎麼進行刪除?
二. 詳情
直接repositoryService.deleteDeployment(deploymentId,true); 即可
設置true 級聯刪除流程定義,即使該流程有流程實例啓動也可以刪除,設
置爲false非級別刪除方式.
刪除已經成功不是的流程定義
具體實現代碼如下:
/**
* 刪除流程定義
*/
@Test
public void removeDeployment() {
// 1.建立配置文件鏈接
ProcessEngineConfiguration configuration = ProcessEngineConfiguration
.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
// 2.創建引擎
ProcessEngine processEngine = configuration.buildProcessEngine();
// 3.獲取repositoryService
RepositoryService repositoryService = processEngine.getRepositoryService();
String deploymentId="10001";
repositoryService.deleteDeployment(deploymentId);
/**
* 設置true 級聯刪除流程定義,即使該流程有流程實例啓動也可以刪除,設
* 置爲false非級別刪除方式,如果流程
*/
//repositoryService.deleteDeployment(deploymentId, true);
}
小結:
1) 使用 repositoryService 刪除流程定義
2) 如果該流程定義下沒有正在運行的流程,則可以用普通刪除。
3) 如果該流程定義下存在已經運行的流程,使用普通刪除報錯,可用級聯刪除方法將流程及相關
記錄全部刪除。項目開發中使用級聯刪除的情況比較多,刪除操作一般只開放給超級管理員使
用。