本文整理汇总了Java中org.activiti.engine.repository.Model.setKey方法的典型用法代码示例。如果您正苦于以下问题:Java Model.setKey方法的具体用法?Java Model.setKey怎么用?Java Model.setKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.repository.Model
的用法示例。
在下文中一共展示了Model.setKey方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createModel
import org.activiti.engine.repository.Model; //导入方法依赖的package包/类
@PostMapping("createModel")
@ResponseStatus(value = HttpStatus.CREATED)
public ResponseMessage createModel(@RequestBody JSONObject model) throws Exception {
JSONObject stencilset = new JSONObject();
stencilset.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#");
JSONObject editorNode = new JSONObject();
editorNode.put("id", "canvas");
editorNode.put("resourceId", "canvas");
editorNode.put("stencilset", stencilset);
JSONObject modelObjectNode = new JSONObject();
modelObjectNode.put(MODEL_REVISION, 1);
modelObjectNode.put(MODEL_DESCRIPTION, model.getString(MODEL_DESCRIPTION));
modelObjectNode.put(MODEL_KEY, model.getString(MODEL_KEY));
modelObjectNode.put(MODEL_NAME, model.getString(MODEL_NAME));
Model modelData = repositoryService.newModel();
modelData.setMetaInfo(modelObjectNode.toJSONString());
modelData.setName(model.getString(MODEL_NAME));
modelData.setKey(model.getString(MODEL_KEY));
repositoryService.saveModel(modelData);
repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8"));
return ResponseMessage.ok(modelData);
}
示例2: testByLatestVersion
import org.activiti.engine.repository.Model; //导入方法依赖的package包/类
public void testByLatestVersion() {
ModelQuery query = repositoryService.createModelQuery().latestVersion().modelKey("someKey");
Model model = query.singleResult();
assertNotNull(model);
// Add a new version of the model
Model newVersion = repositoryService.newModel();
newVersion.setName("my model");
newVersion.setKey("someKey");
newVersion.setCategory("test");
newVersion.setVersion(model.getVersion() + 1);
repositoryService.saveModel(newVersion);
// Verify query
model = query.singleResult();
assertNotNull(model);
assertTrue(model.getVersion() == 2);
// Cleanup
repositoryService.deleteModel(model.getId());
}
示例3: create
import org.activiti.engine.repository.Model; //导入方法依赖的package包/类
/**
* 创建模型
*/
@RequestMapping(value = "create", method = RequestMethod.POST)
public void create(@RequestParam("name") String name, @RequestParam("key") String key, @RequestParam("description") String description,
HttpServletRequest request, HttpServletResponse response) {
try {
ObjectMapper objectMapper = new ObjectMapper();
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);
Model modelData = repositoryService.newModel();
ObjectNode modelObjectNode = objectMapper.createObjectNode();
modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, name);
modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1);
description = StringUtils.defaultString(description);
modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description);
modelData.setMetaInfo(modelObjectNode.toString());
modelData.setName(name);
modelData.setKey(StringUtils.defaultString(key));
repositoryService.saveModel(modelData);
repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8"));
response.sendRedirect(request.getContextPath() + "/modeler.html?modelId=" + modelData.getId());
} catch (Exception e) {
logger.error("创建模型失败:", e);
}
}
示例4: saveNewModel
import org.activiti.engine.repository.Model; //导入方法依赖的package包/类
@RequestMapping(value = "/model/create", method = RequestMethod.POST)
public void saveNewModel(Map<String, Object> map, String tenantId, String key, String name, String desc) {
try {
// "properties":{"process_id":"appleave","name":"璇峰亣鍗曞鎵?
ObjectNode editorNode = objectMapper.createObjectNode();
editorNode.put("id", "canvas");
editorNode.put("resourceId", "canvas");
ObjectNode properties = objectMapper.createObjectNode();
properties.put("process_id", key);
properties.put("name", name);
editorNode.set("properties", properties);
ObjectNode stencilSetNode = objectMapper.createObjectNode();
stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#");
editorNode.set("stencilset", stencilSetNode);
Model model = repositoryService.newModel();
ObjectNode metaInfo = new ObjectMapper().createObjectNode();
metaInfo.put("name", name);
metaInfo.put("revision", 1);
metaInfo.put("description", desc);
model.setMetaInfo(metaInfo.toString());
model.setName(name);
if (StringUtils.isNotEmpty(tenantId)) {
model.setTenantId(tenantId);
}
model.setKey(key);
repositoryService.saveModel(model);
repositoryService.addModelEditorSource(model.getId(), editorNode.toString().getBytes("UTF-8"));
} catch (Exception e) {
logger.error("Error Save New Model", e);
throw new ActivitiException("Error Save New Model", e);
}
}
示例5: newModel
import org.activiti.engine.repository.Model; //导入方法依赖的package包/类
/**
* 新建一个空模型
*
* @return
* @throws UnsupportedEncodingException
*/
@RequestMapping(value = "/model/new", method = RequestMethod.GET)
public String newModel() throws UnsupportedEncodingException {
//初始化一个空模型
Model model = repositoryService.newModel();
//设置一些默认信息
String name = "new-process";
String description = "";
int revision = 1;
String key = "process";
ObjectNode modelNode = objectMapper.createObjectNode();
modelNode.put(ModelDataJsonConstants.MODEL_NAME, name);
modelNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description);
modelNode.put(ModelDataJsonConstants.MODEL_REVISION, revision);
model.setName(name);
model.setKey(key);
model.setMetaInfo(modelNode.toString());
repositoryService.saveModel(model);
String id = model.getId();
//完善ModelEditorSource
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(id, editorNode.toString().getBytes("utf-8"));
//return ToWeb.buildResult().redirectUrl("/modeler.html?modelId="+id);
return "redirect:/activiti/modeler/" + id;
}
示例6: create
import org.activiti.engine.repository.Model; //导入方法依赖的package包/类
/**
* 创建模型
*/
@RequestMapping(value = "create")
public void create(@RequestParam("name") String name, @RequestParam("key") String key,
@RequestParam(value = "description", required = false) String description,
HttpServletRequest request, HttpServletResponse response) {
try {
ObjectMapper objectMapper = new ObjectMapper();
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);
ObjectNode modelObjectNode = objectMapper.createObjectNode();
modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, name);
modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1);
description = StringUtils.defaultString(description);
modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description);
Model newModel = repositoryService.newModel();
newModel.setMetaInfo(modelObjectNode.toString());
newModel.setName(name);
newModel.setKey(StringUtils.defaultString(key));
repositoryService.saveModel(newModel);
repositoryService.addModelEditorSource(newModel.getId(), editorNode.toString().getBytes("utf-8"));
response.sendRedirect(request.getContextPath() + "/mservice/editor?id=" + newModel.getId());
} catch (Exception e) {
logger.error("创建模型失败:", e);
}
}
示例7: convertToModel
import org.activiti.engine.repository.Model; //导入方法依赖的package包/类
/**
* 转换流程定义为模型
* @param processDefinitionId
* @return
* @throws UnsupportedEncodingException
* @throws XMLStreamException
*/
@RequestMapping(value = "/process/convert-to-model/{processDefinitionId}")
public String convertToModel(@PathVariable("processDefinitionId") String processDefinitionId)
throws UnsupportedEncodingException, XMLStreamException {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
.processDefinitionId(processDefinitionId).singleResult();
InputStream bpmnStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(),
processDefinition.getResourceName());
XMLInputFactory xif = XMLInputFactory.newInstance();
InputStreamReader in = new InputStreamReader(bpmnStream, "UTF-8");
XMLStreamReader xtr = xif.createXMLStreamReader(in);
BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);
BpmnJsonConverter converter = new BpmnJsonConverter();
ObjectNode modelNode = converter.convertToJson(bpmnModel);
Model modelData = repositoryService.newModel();
modelData.setKey(processDefinition.getKey());
modelData.setName(processDefinition.getResourceName());
modelData.setCategory(processDefinition.getDeploymentId());
ObjectNode modelObjectNode = new ObjectMapper().createObjectNode();
modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, processDefinition.getName());
modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1);
modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, processDefinition.getDescription());
modelData.setMetaInfo(modelObjectNode.toString());
repositoryService.saveModel(modelData);
repositoryService.addModelEditorSource(modelData.getId(), modelNode.toString().getBytes("utf-8"));
return "redirect:/chapter20/model/list";
}
示例8: setUp
import org.activiti.engine.repository.Model; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
Model model = repositoryService.newModel();
model.setName("my model");
model.setKey("someKey");
model.setCategory("test");
repositoryService.saveModel(model);
modelOneId = model.getId();
repositoryService.addModelEditorSource(modelOneId, "bytes".getBytes("utf-8"));
super.setUp();
}
示例9: importModel
import org.activiti.engine.repository.Model; //导入方法依赖的package包/类
@RequestMapping(value = "/model/import", method = RequestMethod.POST)
public void importModel(String key, String tenantId, MultipartFile file) {
try {
String fileName = file.getOriginalFilename();
if (fileName.endsWith(".bpmn20.xml") || fileName.endsWith(".bpmn")) {
XMLInputFactory xif = XmlUtil.createSafeXmlInputFactory();
InputStreamReader in = new InputStreamReader(new ByteArrayInputStream(file.getBytes()), "UTF-8");
XMLStreamReader xtr = xif.createXMLStreamReader(in);
BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);
if (bpmnModel.getMainProcess() != null && bpmnModel.getMainProcess().getId() != null) {
if (!bpmnModel.getLocationMap().isEmpty()) {
String processName = bpmnModel.getMainProcess().getName();
if (StringUtils.isEmpty(processName)) {
processName = bpmnModel.getMainProcess().getId();
}
Model model = repositoryService.newModel();
ObjectNode metaInfo = new ObjectMapper().createObjectNode();
metaInfo.put("name", processName);
metaInfo.put("revision", 1);
model.setMetaInfo(metaInfo.toString());
model.setName(processName);
if (StringUtils.isNotEmpty(tenantId)) {
model.setTenantId(tenantId);
}
model.setKey(key);
repositoryService.saveModel(model);
ObjectNode editorNode = new BpmnJsonExConverter().convertToJson(bpmnModel);
repositoryService.addModelEditorSource(model.getId(), editorNode.toString().getBytes("UTF-8"));
}
}
}
} catch (Exception e) {
logger.error("Error Import Model", e);
throw new ActivitiException("Error Import Model", e);
}
}