當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
activiti自定义流程之Spring整合activiti-modeler5.16实例(四):部署流程定义
生活随笔
收集整理的這篇文章主要介紹了
activiti自定义流程之Spring整合activiti-modeler5.16实例(四):部署流程定义
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
注:(1)環(huán)境搭建:activiti自定義流程之Spring整合activiti-modeler5.16實例(一):環(huán)境搭建
? ? ? ? (2)創(chuàng)建流程模型:activiti自定義流程之Spring整合activiti-modeler5.16實例(二):創(chuàng)建流程模型?
? ? ? ? (3)流程模型列表展示:activiti自定義流程之Spring整合activiti-modeler5.16實例(三):流程模型列表展示
1.maven導包及spring的一些基本配置與之前的沒有什么變化,依舊沿用就好。
2.與流程定義相關的有3張表,分別是act_ge_bytearray、act_re_procdef和act_re_deployment。當然了,如果更準確的說,在我的自定義流程中,流程定義需要用到流程模型相關的數據,也可以說流程定義相關的就有四張表,也包括model表。
3.后臺業(yè)務代碼,根據前端傳入的deploymentId部署流程定義,這里還是使用repositoryService進行操作,大致上的過程就是根據deploymentId查詢出創(chuàng)建模型時生成的相關文件,然后進行一定的轉換后進行部署:
? ? ? ? /*** 根據模型id部署流程定義* * @author:tuzongxun* @Title: deploye* @param @param activitiModel* @param @param redirectAttributes* @param @return* @return Object* @date Mar 17, 2016 12:30:05 PM* @throws*/@RequestMapping(value = "/deploye.do", method = RequestMethod.POST, produces = "application/json;charset=utf-8")@ResponseBodypublic Object deploye(@RequestBody ActivitiModel activitiModel,HttpServletRequest req) {Map<String, Object> map = new HashMap<String, Object>();boolean isLogin = this.isLogin(req);if (isLogin) {String modelId = activitiModel.getId();try {Model modelData = repositoryService.getModel(modelId);ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));byte[] bpmnBytes = null;BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);bpmnBytes = new BpmnXMLConverter().convertToXML(model);String processName = modelData.getName() + ".bpmn20.xml";Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();if (deployment != null && deployment.getId() != null) {map.put("isLogin", "yes");map.put("userName",(String) req.getSession().getAttribute("userName"));map.put("result", "success");}} catch (Exception e) {e.printStackTrace();}} else {map.put("isLogin", "no");}return map;}
4.angular js前臺代碼,這里實際上只是在之前的模型列表頁面調用了一個方法,因此前端代碼依舊是上篇中的代碼,只是其中的方法這里調用罷了:
angular.module('activitiApp') .controller('modelCtr', ['$rootScope','$scope','$http','$location', function($rootScope,$scope,$http,$location){ $scope.init=function(){$http.post("./modelList.do").success(function(result) {if(result.isLogin==="yes"){$rootScope.userName=result.userName;console.log(result.data); $scope.modelList=result.data;}else{$location.path("/login");}});} //部署流程定義,這里主要就是用這個方法$scope.deploye=function(model){console.log(model);$http.post("./deploye.do",model).success(function(deployResult){$location.path("/processList");});}$scope.update=function(modelId){window.open("http://localhost:8080/activitiTest2/service/editor?id="+modelId);}}])
? ? ? ? (2)創(chuàng)建流程模型:activiti自定義流程之Spring整合activiti-modeler5.16實例(二):創(chuàng)建流程模型?
? ? ? ? (3)流程模型列表展示:activiti自定義流程之Spring整合activiti-modeler5.16實例(三):流程模型列表展示
1.maven導包及spring的一些基本配置與之前的沒有什么變化,依舊沿用就好。
2.與流程定義相關的有3張表,分別是act_ge_bytearray、act_re_procdef和act_re_deployment。當然了,如果更準確的說,在我的自定義流程中,流程定義需要用到流程模型相關的數據,也可以說流程定義相關的就有四張表,也包括model表。
3.后臺業(yè)務代碼,根據前端傳入的deploymentId部署流程定義,這里還是使用repositoryService進行操作,大致上的過程就是根據deploymentId查詢出創(chuàng)建模型時生成的相關文件,然后進行一定的轉換后進行部署:
? ? ? ? /*** 根據模型id部署流程定義* * @author:tuzongxun* @Title: deploye* @param @param activitiModel* @param @param redirectAttributes* @param @return* @return Object* @date Mar 17, 2016 12:30:05 PM* @throws*/@RequestMapping(value = "/deploye.do", method = RequestMethod.POST, produces = "application/json;charset=utf-8")@ResponseBodypublic Object deploye(@RequestBody ActivitiModel activitiModel,HttpServletRequest req) {Map<String, Object> map = new HashMap<String, Object>();boolean isLogin = this.isLogin(req);if (isLogin) {String modelId = activitiModel.getId();try {Model modelData = repositoryService.getModel(modelId);ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));byte[] bpmnBytes = null;BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);bpmnBytes = new BpmnXMLConverter().convertToXML(model);String processName = modelData.getName() + ".bpmn20.xml";Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();if (deployment != null && deployment.getId() != null) {map.put("isLogin", "yes");map.put("userName",(String) req.getSession().getAttribute("userName"));map.put("result", "success");}} catch (Exception e) {e.printStackTrace();}} else {map.put("isLogin", "no");}return map;}
4.angular js前臺代碼,這里實際上只是在之前的模型列表頁面調用了一個方法,因此前端代碼依舊是上篇中的代碼,只是其中的方法這里調用罷了:
angular.module('activitiApp') .controller('modelCtr', ['$rootScope','$scope','$http','$location', function($rootScope,$scope,$http,$location){ $scope.init=function(){$http.post("./modelList.do").success(function(result) {if(result.isLogin==="yes"){$rootScope.userName=result.userName;console.log(result.data); $scope.modelList=result.data;}else{$location.path("/login");}});} //部署流程定義,這里主要就是用這個方法$scope.deploye=function(model){console.log(model);$http.post("./deploye.do",model).success(function(deployResult){$location.path("/processList");});}$scope.update=function(modelId){window.open("http://localhost:8080/activitiTest2/service/editor?id="+modelId);}}])
5.部署之前,我們可以看到原本創(chuàng)建一個模型的時候,數據庫中只會在model表和bytearray兩張表分別出現一條和兩條數據。而當成功部署以后,bytearray表中會再次增加兩條數據,同時act_re_procdef和act_re_deployment這兩張表也都會各自出現一條對應的數據。bytearray表此時數據如下圖:
act_re_procdef表中數據如下:
act_re_deployment中數據如下:
需要說明的是,這些數據在后續(xù)的操作中都需要用到,假如有缺少的,必定會影響后續(xù)的操作。
總結
以上是生活随笔為你收集整理的activiti自定义流程之Spring整合activiti-modeler5.16实例(四):部署流程定义的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: LeetCode Longest Sub
- 下一篇: JavaScript程序员必备的5个de