本文整理汇总了Java中org.activiti.engine.repository.Model类的典型用法代码示例。如果您正苦于以下问题:Java Model类的具体用法?Java Model怎么用?Java Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Model类属于org.activiti.engine.repository包,在下文中一共展示了Model类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: open
import org.activiti.engine.repository.Model; //导入依赖的package包/类
@RequestMapping("modeler-open")
public String open(@RequestParam(value = "id", required = false) String id)
throws Exception {
RepositoryService repositoryService = processEngine
.getRepositoryService();
Model model = null;
if (!StringUtils.isEmpty(id)) {
model = repositoryService.getModel(id);
}
if (model == null) {
model = repositoryService.newModel();
repositoryService.saveModel(model);
id = model.getId();
}
// return "redirect:/cdn/modeler/editor.html?id=" + id;
//return "redirect:/widgets/modeler/modeler.html?modelId=" + id;
return "redirect:/cdn/modeler/modeler.html?modelId=" + id;
}
示例2: modelSave
import org.activiti.engine.repository.Model; //导入依赖的package包/类
@RequestMapping("model/{modelId}/save")
@ResponseBody
public String modelSave(@PathVariable("modelId") String modelId,
@RequestParam("description") String description,
@RequestParam("json_xml") String jsonXml,
@RequestParam("name") String name,
@RequestParam("svg_xml") String svgXml) throws Exception {
RepositoryService repositoryService = processEngine
.getRepositoryService();
Model model = repositoryService.getModel(modelId);
model.setName(name);
// model.setMetaInfo(root.toString());
logger.info("jsonXml : {}", jsonXml);
repositoryService.saveModel(model);
repositoryService.addModelEditorSource(model.getId(),
jsonXml.getBytes("utf-8"));
return "{}";
}
示例3: deploy
import org.activiti.engine.repository.Model; //导入依赖的package包/类
/**
* 根据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:/workflow/model/list";
}
示例4: 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);
}
示例5: deployModel
import org.activiti.engine.repository.Model; //导入依赖的package包/类
@PutMapping("{modelId}/deploy")
public ResponseMessage 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");
}
示例6: queryModelTest
import org.activiti.engine.repository.Model; //导入依赖的package包/类
/***
* 查询 模型信息
*/
@Test
public void queryModelTest() {
// ACT_RE_MODEL
List<Model> modelList = repositoryService.createModelQuery()
.deploymentId("111")
.modelCategory("222")
.latestVersion()
.list();
logger.info("###================================================ modelList, {}", modelList);
// 自定义SQL语句查询
modelList = repositoryService.createNativeModelQuery()
.sql("select distinct RES.* from ACT_RE_MODEL RES where RES.ID_ = #{id}")
.parameter("id", "111")
.list();
logger.info("###================================================ modelList, {}", modelList);
}
示例7: uniqueKey
import org.activiti.engine.repository.Model; //导入依赖的package包/类
@RequestMapping(value = "/model/uniquekey", method = RequestMethod.POST)
@ResponseBody
public Map uniqueKey(String key, String id) {
Map<String, Boolean> map = new HashMap<>();
if (StrUtil.isEmpty(key)) {
map.put("valid", true);
} else {
List<Model> models = repositoryService.createModelQuery().modelKey(key).list();
if (StrUtil.isEmpty(id)) {
if (models.isEmpty())
map.put("valid", true);
else
map.put("valid", false);
} else {
map.put("valid", false);
for (Model model : models) {
if (model.getId().equals(id)) {
map.put("valid", true);
break;
}
}
}
}
return map;
}
示例8: exportPng
import org.activiti.engine.repository.Model; //导入依赖的package包/类
/**
* 导出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);
}
}
示例9: getModelList
import org.activiti.engine.repository.Model; //导入依赖的package包/类
@Override
public List<Model> getModelList(QueryCondition condition, PageInfo pageInfo) {
String name = null;
if (condition != null)
name = condition.getConditionMap().get("name").toString();
List<Model> modelList;
long count;
ModelQuery query = repositoryService.createModelQuery();
if (!StrUtil.isEmpty(name)) {
query = query.modelNameLike(name);
}
count = query.count();
modelList = query.orderByCreateTime().desc().listPage((pageInfo.getPageNum() - 1) * pageInfo.getPageSize(), pageInfo.getPageSize());
pageInfo.setCount((int) count);
return modelList;
}
示例10: deploy
import org.activiti.engine.repository.Model; //导入依赖的package包/类
/**
* 根据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";
}
示例11: export
import org.activiti.engine.repository.Model; //导入依赖的package包/类
/**
* 导出model的xml文件
*/
@RequestMapping(value = "export/{modelId}")
public void export(@PathVariable("modelId") String modelId, HttpServletResponse response) {
try {
Model modelData = repositoryService.getModel(modelId);
BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
JsonNode editorNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(editorNode);
BpmnXMLConverter xmlConverter = new BpmnXMLConverter();
byte[] bpmnBytes = xmlConverter.convertToXML(bpmnModel);
ByteArrayInputStream in = new ByteArrayInputStream(bpmnBytes);
IOUtils.copy(in, response.getOutputStream());
String filename = bpmnModel.getMainProcess().getId() + ".bpmn20.xml";
response.setHeader("Content-Disposition", "attachment; filename=" + filename);
response.flushBuffer();
} catch (Exception e) {
logger.error("导出model的xml文件失败:modelId={}", modelId, e);
}
}
示例12: testNewModelPersistence
import org.activiti.engine.repository.Model; //导入依赖的package包/类
public void testNewModelPersistence() {
Model model = repositoryService.newModel();
assertNotNull(model);
model.setName("Test model");
model.setCategory("test");
model.setMetaInfo("meta");
repositoryService.saveModel(model);
assertNotNull(model.getId());
model = repositoryService.getModel(model.getId());
assertNotNull(model);
assertEquals("Test model", model.getName());
assertEquals("test", model.getCategory());
assertEquals("meta", model.getMetaInfo());
assertNotNull(model.getCreateTime());
assertEquals(Integer.valueOf(1), model.getVersion());
repositoryService.deleteModel(model.getId());
}
示例13: testNewModelWithSource
import org.activiti.engine.repository.Model; //导入依赖的package包/类
public void testNewModelWithSource() throws Exception {
Model model = repositoryService.newModel();
model.setName("Test model");
byte[] testSource = "modelsource".getBytes("utf-8");
repositoryService.saveModel(model);
assertNotNull(model.getId());
repositoryService.addModelEditorSource(model.getId(), testSource);
model = repositoryService.getModel(model.getId());
assertNotNull(model);
assertEquals("Test model", model.getName());
byte[] editorSourceBytes = repositoryService.getModelEditorSource(model.getId());
assertEquals("modelsource", new String(editorSourceBytes, "utf-8"));
repositoryService.deleteModel(model.getId());
}
示例14: testByDeploymentId
import org.activiti.engine.repository.Model; //导入依赖的package包/类
public void testByDeploymentId() {
Deployment deployment = repositoryService.createDeployment().addString("test", "test").deploy();
assertEquals(0, repositoryService.createModelQuery().deploymentId(deployment.getId()).count());
assertEquals(0, repositoryService.createModelQuery().deployed().count());
assertEquals(1, repositoryService.createModelQuery().notDeployed().count());
Model model = repositoryService.createModelQuery().singleResult();
model.setDeploymentId(deployment.getId());
repositoryService.saveModel(model);
assertEquals(1, repositoryService.createModelQuery().deploymentId(deployment.getId()).count());
assertEquals(1, repositoryService.createModelQuery().deployed().count());
assertEquals(0, repositoryService.createModelQuery().notDeployed().count());
// Cleanup
repositoryService.deleteDeployment(deployment.getId(), true);
// After cleanup the model should still exist
assertEquals(0, repositoryService.createDeploymentQuery().count());
assertEquals(0, repositoryService.createModelQuery().deploymentId(deployment.getId()).count());
assertEquals(1, repositoryService.createModelQuery().notDeployed().count());
assertEquals(1, repositoryService.createModelQuery().count());
}
示例15: 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());
}