- Common ways to obtain Model
private void myMethod () {Model m =
RepositoryService repositoryService;String modelId;repositoryService.getModel(modelId)
RepositoryService repositoryService;repositoryService.newModel()
CommandExecutor commandExecutor;String modelId;commandExecutor.execute(new GetModelCmd(modelId))
- Smart code suggestions by Codota
}
/** * 导出model的png文件 */ @RequestMapping(value = "/model/export/image/{modelId}", method = RequestMethod.GET) public void exportPng(@PathVariable("modelId") String modelId, HttpServletResponse response) { try { Model modelData = repositoryService.getModel(modelId); byte[] pngBytes = repositoryService.getModelEditorSourceExtra(modelData.getId()); ByteArrayInputStream in = new ByteArrayInputStream(pngBytes); IOUtils.copy(in, response.getOutputStream()); String filename = modelData.getKey() + ".process.model.png"; response.setHeader("Content-Disposition", "attachment; filename=" + filename); response.flushBuffer(); } catch (Exception e) { LOGGER.error("导出model的png文件失败:modelId={}", modelId, e); } }
String fileName = model.getKey() + ".model.bpmn"; String realPath = dirPath + File.separator + DIR_PATH + File.separator + fileName; File file = new File(realPath); } else { byte[] pngBytes = repositoryService.getModelEditorSourceExtra(modelId); String fileName = model.getKey() + ".model.png"; String realPath = dirPath + File.separator + DIR_PATH + File.separator + fileName; File file = new File(realPath);
String fileName = modelData.getKey() + ".bpmn20.model.zip"; String zipFileName = DIR_PATH + File.separator + fileName; File file = new File(basePath + File.separator + zipFileName); String processName = modelData.getKey() + ".bpmn20.xml"; DeploymentBuilder deploymentBuilder = repositoryService.createDeployment() .name(modelData.getName())
Map<String, Model> modelMap = new HashMap<String, Model>(); for (Model model : modelList) if (!modelMap.containsKey(model.getKey())) modelMap.put(model.getKey(), model); Iterator it = entityList.iterator(); while (it.hasNext()) { Entity entity = (Entity) it.next(); String key = entity.getKey(); if (modelMap.containsKey(key)) merge(entity, modelMap.get(key)); else it.remove(); }
public ModelResponse createModelResponse(Model model, RestUrlBuilder urlBuilder) { ModelResponse response = new ModelResponse(); response.setCategory(model.getCategory()); response.setCreateTime(model.getCreateTime()); response.setId(model.getId()); response.setKey(model.getKey()); response.setLastUpdateTime(model.getLastUpdateTime()); response.setMetaInfo(model.getMetaInfo()); response.setName(model.getName()); response.setDeploymentId(model.getDeploymentId()); response.setVersion(model.getVersion()); response.setTenantId(model.getTenantId()); response.setUrl(urlBuilder.buildUrl(RestUrls.URL_MODEL, model.getId())); if (model.getDeploymentId() != null) { response.setDeploymentUrl(urlBuilder.buildUrl(RestUrls.URL_DEPLOYMENT, model.getDeploymentId())); } if (model.hasEditorSource()) { response.setSourceUrl(urlBuilder.buildUrl(RestUrls.URL_MODEL_SOURCE, model.getId())); } if (model.hasEditorSourceExtra()) { response.setSourceExtraUrl(urlBuilder.buildUrl(RestUrls.URL_MODEL_SOURCE_EXTRA, model.getId())); } return response; }