@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"); }
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; }
@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"); }
/** * Deploys the Activiti XML into Activiti given the specified namespace and job name. If an existing process definition with the specified namespace and job * name already exists, a new process definition with an incremented version will be created by Activiti. * * @param namespace the namespace. * @param jobName the job name. * @param activitiJobXml the Activiti job XML. * * @return the newly created process definition. */ private ProcessDefinition createProcessDefinition(String namespace, String jobName, String activitiJobXml) { // Deploy Activiti XML using Activiti API. String activitiIdString = jobDefinitionHelper.buildActivitiIdString(namespace, jobName); Deployment deployment = activitiRepositoryService.createDeployment().name(activitiIdString).addString(activitiIdString + ACTIVITI_DEPLOY_XML_SUFFIX, activitiJobXml) .deploy(); // Read the created process definition. return activitiRepositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).list().get(0); }
/** * Deploys the Activiti XML into Activiti given the specified namespace and job name. If an existing process definition with the specified namespace and job * name already exists, a new process definition with an incremented version will be created by Activiti. * * @param namespace the namespace. * @param jobName the job name. * @param activitiJobXml the Activiti job XML. * * @return the newly created process definition. */ private ProcessDefinition createProcessDefinition(String namespace, String jobName, String activitiJobXml) { // Deploy Activiti XML using Activiti API. String activitiIdString = jobDefinitionHelper.buildActivitiIdString(namespace, jobName); Deployment deployment = activitiRepositoryService.createDeployment().name(activitiIdString).addString(activitiIdString + ACTIVITI_DEPLOY_XML_SUFFIX, activitiJobXml) .deploy(); // Read the created process definition. return activitiRepositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).list().get(0); }
@RequestMapping(value = "/model/deploy/{id}", method = RequestMethod.POST) public ResponseCode deploy(@PathVariable("id") String id) throws Exception { //获取模型 Model modelData = repositoryService.getModel(id); byte[] bytes = repositoryService.getModelEditorSource(modelData.getId()); if (bytes == null) { return ResponseCode.error("模型数据为空,请先设计流程并成功保存,再进行发布。"); } JsonNode modelNode = new ObjectMapper().readTree(bytes); BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode); if (model.getProcesses().size() == 0) { return ResponseCode.error("数据模型不符要求,请至少设计一条主线流程。"); } byte[] 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")) .deploy(); modelData.setDeploymentId(deployment.getId()); repositoryService.saveModel(modelData); return ResponseCode.ok(); }
public String deployWorkflow(KickstartWorkflow kickstartWorkflow, Map<String, String> metadata) { String deploymentName = "Process " + kickstartWorkflow.getName(); String bpmn20XmlResourceName = generateBpmnResourceName(kickstartWorkflow.getName()); DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().name(deploymentName); // png image (must go first, since it will add DI to the process xml) ProcessDiagramGenerator diagramGenerator = new ProcessDiagramGenerator(kickstartWorkflow, marshallingService); deploymentBuilder.addInputStream(bpmn20XmlResourceName.replace(".bpmn20.xml", ".png"), diagramGenerator.execute()); // bpmn 2.0 xml String workflowXml = marshallingService.marshallWorkflow(kickstartWorkflow); deploymentBuilder.addString(bpmn20XmlResourceName,workflowXml); Deployment deployment = deploymentBuilder.deploy(); return deployment.getId(); }
protected void deployModelerModel(final ObjectNode modelNode) { 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)) .deploy(); ExplorerApp.get().getViewManager().showDeploymentPage(deployment.getId()); }
Deployment deployment = repositoryService.createDeployment() .name(modelData.getName()) .addString(processName, new String(bpmnBytes)) .deploy();
.addString(conversion.getProcess().getId() + ".bpmn20.xml", conversion.getBpmn20Xml()) .deploy();