/** * 根据模型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") @ResponseBody public 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; }
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.部署之前,我们可以看到原本创建一个模型的时候,数据库中只会在model表和bytearray两张表分别出现一条和两条数据。而当成功部署以后,bytearray表中会再次增加两条数据,同时act_re_procdef和act_re_deployment这两张表也都会各自出现一条对应的数据。bytearray表此时数据如下图:
act_re_procdef表中数据如下:
act_re_deployment中数据如下:
需要说明的是,这些数据在后续的操作中都需要用到,假如有缺少的,必定会影响后续的操作。