作者:田大才子2016-10-8 14:48分类: Activiti
本文所有文字解释都在代码中以注释的方式存在。
请复制代码到自己喜欢的文本编辑器中观看。
public boolean create(ActivitiModel activiti) { org.activiti.engine.repository.Model newModel = repositoryService.newModel(); try { ObjectMapper objectMapper = new ObjectMapper(); ObjectNode modelObjectNode = objectMapper.createObjectNode(); modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME,activiti.getName()); modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1); modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION,StringUtils.defaultString(activiti.getDescription())); newModel.setMetaInfo(modelObjectNode.toString()); newModel.setName(activiti.getName()); newModel.setKey(StringUtils.defaultString(activiti.getKey())); repositoryService.saveModel(newModel); ObjectNode editorNode = objectMapper.createObjectNode(); editorNode.put("id", "canvas"); editorNode.put("resourceId", "canvas"); ObjectNode stencilSetNode = objectMapper.createObjectNode(); stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#"); editorNode.put("stencilset", stencilSetNode); repositoryService.addModelEditorSource(newModel.getId(),editorNode.toString().getBytes("utf-8")); return true; } catch (Exception e) { e.getStackTrace(); } return false; } public class ActivitiModel { private String name; private String key; private String description; private String id; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getKey() { return key; } public void setKey(String key) { this.key = key; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } }
发表评论:
昵称
邮件地址 (选填)
个人主页 (选填)
个人公众号,希望您的关注~
发表评论: