Java Code Examples for org.activiti.engine.repository.Model#getName()
The following examples show how to use
org.activiti.engine.repository.Model#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlowableModelManagerController.java From hsweb-framework with Apache License 2.0 | 6 votes |
@PostMapping("/{modelId}/deploy") @ApiOperation("发布模型") @Authorize(action = "deploy") public ResponseMessage<Deployment> deployModel(@PathVariable String modelId) throws Exception { Model modelData = repositoryService.getModel(modelId); if (modelData == null) { throw new NotFoundException("模型不存在!"); } ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId())); BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode); byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model); String processName = modelData.getName() + ".bpmn20.xml"; Deployment deployment = repositoryService.createDeployment() .name(modelData.getName()) .addString(processName, new String(bpmnBytes, "utf8")) .deploy(); return ResponseMessage.ok(deployment).include(Deployment.class, "id", "name", "new"); }
Example 2
Source File: ModelUtils.java From openwebflow with BSD 2-Clause "Simplified" License | 6 votes |
public static Deployment deployModel(RepositoryService repositoryService, String modelId) throws IOException { Model modelData = repositoryService.getModel(modelId); //EditorSource就是XML格式的 byte[] bpmnBytes = repositoryService.getModelEditorSource(modelId); String processName = modelData.getName() + ".bpmn20.xml"; Deployment deployment = repositoryService.createDeployment().name(modelData.getName()) .addString(processName, new String(bpmnBytes, "utf-8")).deploy(); //设置部署ID modelData.setDeploymentId(deployment.getId()); repositoryService.saveModel(modelData); return deployment; }
Example 3
Source File: ModelController.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
/** * 根据Model部署流程 */ @RequestMapping(value = "deploy/{modelId}") public String deploy(@PathVariable("modelId") String modelId, RedirectAttributes redirectAttributes) { 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(); redirectAttributes.addFlashAttribute("message", "部署成功,部署ID=" + deployment.getId()); } catch (Exception e) { logger.error("根据模型部署流程失败:modelId={}", modelId, e); } return "redirect:/chapter20/model/list"; }
Example 4
Source File: ModelerController.java From lemon with Apache License 2.0 | 4 votes |
@RequestMapping("modeler-deploy") public String deploy(@RequestParam("id") String id, org.springframework.ui.Model theModel) throws Exception { String tenantId = tenantHolder.getTenantId(); RepositoryService repositoryService = processEngine .getRepositoryService(); Model modelData = repositoryService.getModel(id); byte[] bytes = repositoryService .getModelEditorSource(modelData.getId()); if (bytes == null) { theModel.addAttribute("message", "模型数据为空,请先设计流程并成功保存,再进行发布。"); return "modeler/failure"; } JsonNode modelNode = (JsonNode) new ObjectMapper().readTree(bytes); 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, "UTF-8")) .tenantId(tenantId).deploy(); modelData.setDeploymentId(deployment.getId()); repositoryService.saveModel(modelData); List<ProcessDefinition> processDefinitions = repositoryService .createProcessDefinitionQuery() .deploymentId(deployment.getId()).list(); for (ProcessDefinition processDefinition : processDefinitions) { processEngine.getManagementService().executeCommand( new SyncProcessCmd(processDefinition.getId())); } return "redirect:/modeler/modeler-list.do"; }