两篇整合Activiti Modeler到业务系统
1. 无法进入editor.
http://localhost:8080/YouPRJ/modeler/service/editor?id=2050,前提是这个id必需存在与act_re_model表里面,
那么,在调用这个之前,如何插入一条记录到这个表么?
待解决........
-------------
看到咖啡兔的例子,是先使用java保存到数据库,然后再打开editor, 保存的代码:
javascript: 一边保存,一边打开,同时保存后的页面又做reload, 很特别很有趣的做法,值得学习....
- $(function() {
- $('#create').button({
- icons: {
- primary: 'ui-icon-plus'
- }
- }).click(function() {
- $('#createModelTemplate').dialog({
- modal: true,
- width: 500,
- buttons: [{
- text: '创建',
- click: function() {
- if (!$('#name').val()) {
- alert('请填写名称!');
- $('#name').focus();
- return;
- }
- setTimeout(function() {
- location.reload();
- }, 1000);
- $('#modelForm').submit();
- }
- }]
- });
- });
- });
- @RequestMapping(value = "create", method = RequestMethod.POST)
- publicvoid 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() + "/service/editor?id=" + modelData.getId());
- } catch (Exception e) {
- logger.error("创建模型失败:", e);
- }
- }
2. web editor保存的bpmn20文件到哪里去了?
会更新ACT_RE_MODEL和ACT_GE_BYTEARRAY表,ACT_GE_BYTEARRAY表保存了图片和xml文件信息( 其实是json格式的字符串),并关联到ACT_RE_MODEL表。
ACT_RE_MODEL
说明:流程设计器设计流程后,保存数据到该表。
EDITOR_SOURCE_VALUE_ID(流程文件放在ACT_GE_BYTEARRAY中的ID);
EDITOR_SOURCE_EXTRA_VALUE_ID(流程文件图像放在ACT_GE_BYTEARRAY中的ID)。
3. 如何去部署保存在数据库里面的ACT_RE_MODEL表里面的工作流?
咖啡兔的源码: 创建,部署,删除,导出,遍历
- package me.kafeitu.demo.activiti.web.workflow;
- import java.io.ByteArrayInputStream;
- import java.util.List;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.activiti.bpmn.converter.BpmnXMLConverter;
- import org.activiti.bpmn.model.BpmnModel;
- import org.activiti.editor.constants.ModelDataJsonConstants;
- import org.activiti.editor.language.json.converter.BpmnJsonConverter;
- import org.activiti.engine.RepositoryService;
- import org.activiti.engine.repository.Deployment;
- import org.activiti.engine.repository.Model;
- import org.apache.commons.io.IOUtils;
- import org.apache.commons.lang3.StringUtils;
- import org.codehaus.jackson.JsonNode;
- import org.codehaus.jackson.map.ObjectMapper;
- import org.codehaus.jackson.node.ObjectNode;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.servlet.ModelAndView;
- import org.springframework.web.servlet.mvc.support.RedirectAttributes;
- /**
- * 流程模型控制器
- *
- * @author henryyan
- */
- @Controller
- @RequestMapping(value = "/workflow/model")
- publicclass ModelController {
- protected Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- RepositoryService repositoryService;
- /**
- * 模型列表
- */
- @RequestMapping(value = "list")
- public ModelAndView modelList() {
- ModelAndView mav = new ModelAndView("workflow/model-list");
- List list = repositoryService.createModelQuery().list();
- mav.addObject("list", list);
- return mav;
- }
- /**
- * 创建模型
- */
- @RequestMapping(value = "create", method = RequestMethod.POST)
- publicvoid 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() + "/service/editor?id=" + modelData.getId());
- } catch (Exception e) {
- logger.error("创建模型失败:", e);
- }
- }
- /**
- * 根据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";
- }
- /**
- * 导出model的xml文件
- */
- @RequestMapping(value = "export/{modelId}")
- publicvoid 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);
- }
- }
- @RequestMapping(value = "delete/{modelId}")
- public String delete(@PathVariable("modelId") String modelId) {
- repositoryService.deleteModel(modelId);
- return"redirect:/workflow/model/list";
- }
- }
两篇整合Activiti Modeler到业务系统的更多相关文章
- 整合Activiti Modeler到业务系统(或BPM平台)
http://www.kafeitu.me/activiti/2013/03/10/integrate-activiti-modeler.html 1. 为什么要整合 Activiti 5.10版本把 ...
- 集成新版(5.17+)Activiti Modeler与Rest服务
声明: 此教程适合Activiti 5.17+版本. 本博客所涉及的内容均可在kft-activiti-demo中找到. 在线demo可以访问 http://demo.kafeitu.me:8080/ ...
- 【Activiti学习之八】Spring整合Activiti
环境 JDK 1.8 MySQL 5.6 Tomcat 8 idea activiti 5.22 activiti-explorer是官方提供的一个演示项目,可以使用页面管理Activiti流程.ac ...
- 运行带有Activiti modeler时,出现这样的报错: java.rmi.AccessException: Cannot modify this registry
最近在做整合Activiti Modeler工作流在线设计器的工作,运行IDEA时,出现了这样一个错误信息: 原因及解决办法: Activiti默认打开了jmx功能,默认端口为1099,idea中 ...
- 《转载-两篇很好的文章整合》Android中自定义控件
两篇很好的文章,有相互借鉴的地方,整合到一起收藏 分别转载自:http://blog.csdn.net/xu_fu/article/details/7829721 http://www.cnblogs ...
- 统一门户与业务系统的sso整合技术方案(单点登录)
一.单点登录(SSO,Single Sign On)整合目前计划接入统一门户的所有业务系统均为基于JavaEE技术的B/S架构系统.由于统一门户的单点登录技术选用的是JA-SIG组织开发的Cas Se ...
- Activiti Modeler初探实践
以下内容对实践activiti很有用,不过我用的不是github下载的源码包编译出来的war包,不知道什么原因我打出来的包会有点问题.不过这不重要,换个地方下载来源就行,下载网址: http://dl ...
- nodejs 基础篇整合
nodeJs 基础篇整合 最近有朋友也想学习nodeJs相关方面的知识,如果你是后端想接近前端,node作为一门跑在服务端的JS语言从这里入门再好不过了.如果你正好喜欢前端,想走的更高,走的更远.no ...
- SSH框架集成Activiti Modeler在线设计器页面出现问号及乱码的解决办法
文·原创/朱季谦 工作流是一个针对企业用户.开发人员.系统管理员的轻量级工作流业务管理平台,其核心是使用Java开发的快速.稳定的BPMN2.0流程引擎.在我们日常开发当中,例如oa系统里的请假功能, ...
随机推荐
- Makefile系列之一 : 书写规则
1. 规则 target : prerequisites command 2. example excute 为最终生成的可执行文件. 可以通过命令 make clean来删除所有编译时产生的中间文 ...
- 阿里CDN核心技术解密
1. 阿里CDN组件分层 其中应用层主要用到的技术有负载均衡和缓存, 负载均衡包括全局负载均衡和本地负载均衡; 缓存通过HTTP缓存服务器Swift做HTTP缓存. 全局负载均衡以DNS服务器Phar ...
- form表单 datalist 和legend
<form action="" method="post" > <fieldset> <legend> 表单元素 </ ...
- 【转载】PDB命令行调试Python代码
转载自这里. (博主按:PDB调试python代码和用GDB调试c++代码很类似) 你有多少次陷入不得不更改别人代码的境地?如果你是一个开发团队的一员,那么你遇到上述境地的次数比你想要的还要多.然而, ...
- 兼容python3的SSDB客户端
SSDB.py import socket class SSDB_Response(object): def __init__(self, code='', data_or_message=None) ...
- PHP PDO类 单例
<?php /*//pdo连接信息 $pdo=array("mysql:host=localhost;dbname=demo;charset=utf8","root ...
- chattr命令的用法
chattr (配置文件隐藏属性)[root@www ~]# chattr [+-=][ASacdistu] 文件或目录名称选项与参数:+ :添加某一个特殊参数,其他原本存在参数则不动.- :移除某一 ...
- ECNU 2018 10月月赛 E 盖房子 (bitset + 倍增)
题目链接 ECNU Monthly 2018.10 Problem E 从开场写到结束…… 显然要把三角形分成上下两部分. 把每一部分分成三部分,以上部分为例. 上面和右边,以及左下角的正方形. 也 ...
- POJ1845 Sumdiv [数论,逆元]
题目传送门 Sumdiv Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 26041 Accepted: 6430 Des ...
- SystemProperties cannot be resolved错误
单独用eclipse打开一个工程,出现SystemProperties.get()会出现SystemProperties cannot be resolved.错误 1. 引用SystemProper ...