activtiy 在线编辑器

2023-10-10 12:10
文章标签 编辑器 在线 activtiy

本文主要是介绍activtiy 在线编辑器,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

目录

maven 依赖

 下载activiti-webapp

Activiti configsurtion

contrller

ServiceImpl

entity

 调整


maven 依赖

  <dependency><groupId>org.activiti</groupId><artifactId>activiti-spring-boot-starter</artifactId><version>7.0.0.SR1</version></dependency><dependency><groupId>org.activiti</groupId><artifactId>activiti-modeler</artifactId><version>5.23.0</version></dependency><dependency><groupId>org.activiti</groupId><artifactId>activiti-diagram-rest</artifactId><version>5.23.0</version></dependency>

 下载activiti-webapp

去搜索 activiti-webapp 或者是去这里 百度网盘 请输入提取码百度网盘为您提供文件的网络备份、同步和分享服务。空间大、速度快、安全稳固,支持教育网加速,支持手机端。注册使用百度网盘即可享受免费存储空间https://pan.baidu.com/s/16OQv_h8SxPn2VEw7HRp_tQ提取码为链接:https://pan.baidu.com/s/16OQv_h8SxPn2VEw7HRp_tQ
提取码:awc4

 赋值到你的web目录下

Activiti configsurtion

@Configuration
public class ActivityBen extends AbstractProcessEngineAutoConfiguration {@AutowiredDataSource dataSource;@Beanpublic SpringProcessEngineConfiguration springProcessEngineConfiguration(PlatformTransactionManager platformTransactionManager){SpringProcessEngineConfiguration spec = new SpringProcessEngineConfiguration();spec.setDataSource(dataSource);spec.setTransactionManager(platformTransactionManager);spec.setDatabaseSchemaUpdate("true");Resource[] resources = null;// 启动自动部署流程try {resources = new PathMatchingResourcePatternResolver().getResources("classpath*:processes/*.bpmn");} catch (IOException e) {e.printStackTrace();}spec.setDeploymentResources(resources);return spec;}@Beanpublic ProcessEngineFactoryBean processEngine(SpringProcessEngineConfiguration engineConfiguration){ProcessEngineFactoryBean processEngineFactoryBean = new ProcessEngineFactoryBean();processEngineFactoryBean.setProcessEngineConfiguration(engineConfiguration);return processEngineFactoryBean;}@Beanpublic RepositoryService repositoryService(ProcessEngineFactoryBean engineFactoryBean) throws Exception{return engineFactoryBean.getObject().getRepositoryService();}@Beanpublic RuntimeService runtimeService(ProcessEngineFactoryBean engineFactoryBean) throws Exception{return engineFactoryBean.getObject().getRuntimeService();}@Beanpublic TaskService taskService(ProcessEngineFactoryBean engineFactoryBean) throws Exception{return engineFactoryBean.getObject().getTaskService();}@Beanpublic HistoryService historyService(ProcessEngineFactoryBean engineFactoryBean) throws Exception{return engineFactoryBean.getObject().getHistoryService();}

contrller

ntroller
public class ActivityContrllerCreate {//2. 声明一个Logger,这个是static的方式,我比较习惯这么写。private final static Logger logger = LoggerFactory.getLogger(ActivityCreateSerivce.class);@AutowiredActivityCreateSerivce activityCreateSerivce;@RequestMapping("modeler/Create")public void CreateModel(HttpServletRequest request, HttpServletResponse response){
//        String s = activityCreateSerivce.CreatModel();try {response.sendRedirect(request.getContextPath() + "/modeler.html?modelId=2501");}catch(Exception e){logger.debug(e.getMessage());}}@RequestMapping(value = "modeler/service/model/{modelId}/json",method= RequestMethod.GET,produces = "application/json")@ResponseBodypublic ObjectNode getEditorJson(@PathVariable String modelId){return activityCreateSerivce.BySelectId(modelId);}@RequestMapping(value="modeler/service/editor/stencilset", method = RequestMethod.GET, produces = "application/json;charset=utf-8")public @ResponseBody String getStencilset() {InputStream stencilsetStream = this.getClass().getClassLoader().getResourceAsStream("static/stencilset.json");try {return IOUtils.toString(stencilsetStream, "utf-8");} catch (Exception e) {throw new ActivitiException("Error while loading stencil set", e);}}@RequestMapping(value="modeler/service/model/{modelId}/save", method = RequestMethod.PUT)public void saveModel(@PathVariable String modelId, @RequestParam("name") String name,@RequestParam("json_xml") String json_xml, @RequestParam("svg_xml") String svg_xml,@RequestParam("description") String description,HttpServletResponse response) {ActivitiEnitiy activitiEnitiy=new ActivitiEnitiy();activitiEnitiy.setModeid(modelId);activitiEnitiy.setName(name);activitiEnitiy.setDescription(description);activitiEnitiy.setJson_xml(json_xml);activitiEnitiy.setSvg_xml(svg_xml);if(activityCreateSerivce.ModelSave(activitiEnitiy)){ResponseUtil.out(response, Result.successWithData("模型已经保存!"));}else{ResponseUtil.out(response,Result.failed("模型保存失败!"));}}@RequestMapping(value="modeler/service/deploy",method = RequestMethod.GET)public void Deploy(@PathVariable String modelId, HttpServletResponse response )throws IOException {if(activityCreateSerivce.deploy(modelId)){ResponseUtil.out(response,Result.successWithData("已部署模型"));}else{ResponseUtil.out(response,Result.failed("模型数据为空或者数据模型不符要求!"));}}@RequestMapping(value="modeler/service/model/list")@ResponseBodypublic List<Model> Selectlist(){return activityCreateSerivce.selectList();}}
@Controller
public class RunTimeContrller {@AutowiredTaskServiceImpl service;@RequestMapping(value="modeler/service/run")public void run(@PathVariable String keyName, HttpServletResponse response){if(service.run(keyName)){ResponseUtil.out(response, Result.successWithData("已执行该操作!"));}else{ResponseUtil.out(response,Result.failed("操作失败!"));}}
}
@Controller
public class TaskContrller {@AutowiredRuntimeServiceImpl runtimeService;@RequestMapping(value="modeler/service/process")@ResponseBodypublic ProcessInstance SelectProcess(@PathVariable String process){ProcessInstance processInstance = runtimeService.startProcess(process);return processInstance;}
}

ServiceImpl

@Service
public class ActivityCreateSerivce {@Qualifier("repositoryService")@AutowiredRepositoryService service;@AutowiredObjectMapper mapper;//2. 声明一个Logger,这个是static的方式,我比较习惯这么写。private final static Logger logger = LoggerFactory.getLogger(ActivityCreateSerivce.class);public String CreatModel(){ObjectNode editorNode = mapper.createObjectNode();editorNode.put("id", "canvas");editorNode.put("resourceId", "canvas");ObjectNode stencilSetNode = mapper.createObjectNode();stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#");editorNode.put("stencilset", stencilSetNode);Model modelData = service.newModel();ObjectNode modelObjectNode = mapper.createObjectNode();modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, "hello1111");modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1);String description = "hello1111";modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description);modelData.setMetaInfo(modelObjectNode.toString());modelData.setName("hello1111");modelData.setKey("12313123");try {//保存模型service.saveModel(modelData);service.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8"));return    modelData.getId();}catch (Exception e){logger.error(e.getMessage());}return null;}public ObjectNode BySelectId(String modelId)  {ObjectNode  modelNode=null;try {Model model = service.getModel(modelId);if (model != null) {if (StringUtils.isNotEmpty(model.getMetaInfo())) {modelNode = (ObjectNode) mapper.readTree(model.getMetaInfo());} else {modelNode = mapper.createObjectNode();modelNode.put("MODEL_NAME", model.getName());}modelNode.put("MODEL_ID", model.getId());ObjectNode editorJsonNode = (ObjectNode)mapper.readTree(new String(service.getModelEditorSource(model.getId()), "utf-8"));modelNode.put("model", editorJsonNode);}}catch (Exception e){logger.error(e.getMessage());throw new ActivitiException("Error creating model JSON", e);}return modelNode;}public boolean ModelSave(ActivitiEnitiy activitiEnitiy){  try {Model model = service.getModel(activitiEnitiy.getModeid());ObjectNode modelJson = (ObjectNode) mapper.readTree(model.getMetaInfo());modelJson.put("MODEL_NAME", activitiEnitiy.getName());modelJson.put("MODEL_DESCRIPTION", activitiEnitiy.getDescription());model.setMetaInfo(modelJson.toString());model.setName(activitiEnitiy.getName());service.saveModel(model);service.addModelEditorSource(model.getId(), activitiEnitiy.getJson_xml().getBytes("utf-8"));InputStream svgStream = new ByteArrayInputStream(activitiEnitiy.getSvg_xml().getBytes("utf-8"));TranscoderInput input = new TranscoderInput(svgStream);PNGTranscoder transcoder = new PNGTranscoder();// Setup outputByteArrayOutputStream outStream = new ByteArrayOutputStream();TranscoderOutput output = new TranscoderOutput(outStream);// Do the transformationtranscoder.transcode(input, output);final byte[] result = outStream.toByteArray();service.addModelEditorSourceExtra(model.getId(), result);outStream.close();return true;} catch (Exception e) {logger.error("Error saving model", e);throw new ActivitiException("Error saving model", e);}finally {return false;}}public List<Model> selectList(){return service.createModelQuery().list();}public Boolean deploy(String modelID) throws IOException {Model model = service.getModel(modelID);byte[] modelEditorSource = service.getModelEditorSource(model.getId());if(modelEditorSource==null){return  false;}try {JsonNode modelNode = new ObjectMapper().readTree(modelEditorSource);BpmnModel modelBmpn = new BpmnJsonConverter().convertToBpmnModel(modelNode);if (modelBmpn.getProcesses().size() == 0) {return false;}byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(modelBmpn);String processName = model.getName() + ".bpmn20.xml";Deployment deploy = service.createDeployment().name(model.getName()).addString(processName, new String(bpmnBytes, "UTF-8")).deploy();model.setDeploymentId(deploy.getId());service.saveModel(model);return true;}catch (Exception e){logger.error(e.getMessage());return false;}}
}
@Service
public class RuntimeServiceImpl {@AutowiredRuntimeServiceImpl runtimeService;public ProcessInstance startProcess(String keyName){ProcessInstance processInstance = runtimeService.startProcess(keyName);return  processInstance;}}
@Service
public class TaskServiceImpl {@Qualifier("taskService")@AutowiredTaskService taskService;public boolean run(String processId){Task task = taskService.createTaskQuery().processDefinitionId(processId).singleResult();if(task== null){return false;}taskService.complete(task.getId());return true;}
}

entity


@Data
@Accessors(chain = true)
public class ActivitiEnitiy {private String  modeid;private String name;private String json_xml;private String svg_xml;private String description;
}

 调整

在activiti-webapp 里有几个地方需要改一下

在editor-app里app-cfg.js

 */
'use strict';var ACTIVITI = ACTIVITI || {};ACTIVITI.CONFIG = {'contextRoot' : 'modeler/service',
};

在editor-app 里的configuration 里的 url-config.js

var KISBPM = KISBPM || {};var  modelId1=null;
KISBPM.URL = {getModel: function(modelId) {modelId1=modelIdreturn ACTIVITI.CONFIG.contextRoot + '/model/' + modelId + '/json';},getStencilSet: function() {return ACTIVITI.CONFIG.contextRoot + '/editor/stencilset?version=' + Date.now();},putModel: function(modelId) {return ACTIVITI.CONFIG.contextRoot + '/model/' + modelId1+ '/save';}
};

效果是这样的

 

这篇关于activtiy 在线编辑器的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/180352

相关文章

水位雨量在线监测系统概述及应用介绍

在当今社会,随着科技的飞速发展,各种智能监测系统已成为保障公共安全、促进资源管理和环境保护的重要工具。其中,水位雨量在线监测系统作为自然灾害预警、水资源管理及水利工程运行的关键技术,其重要性不言而喻。 一、水位雨量在线监测系统的基本原理 水位雨量在线监测系统主要由数据采集单元、数据传输网络、数据处理中心及用户终端四大部分构成,形成了一个完整的闭环系统。 数据采集单元:这是系统的“眼睛”,

电力系统中的A类在线监测装置—APView400

随着电力系统的日益复杂和人们对电能质量要求的提高,电能质量在线监测装置在电力系统中得到广泛应用。目前,市场上的在线监测装置主要分为A类和B类两种类型,A类和B类在线监测装置主要区别在于应用场景、技术参数、通讯协议和扩展性。选择时应根据实际需求和应用场景综合考虑,并定期维护和校准。电能质量在线监测装置是用于实时监测电力系统中的电能质量参数的设备。 APView400电能质量A类在线监测装置以其多核

JavaFX应用更新检测功能(在线自动更新方案)

JavaFX开发的桌面应用属于C端,一般来说需要版本检测和自动更新功能,这里记录一下一种版本检测和自动更新的方法。 1. 整体方案 JavaFX.应用版本检测、自动更新主要涉及一下步骤: 读取本地应用版本拉取远程版本并比较两个版本如果需要升级,那么拉取更新历史弹出升级控制窗口用户选择升级时,拉取升级包解压,重启应用用户选择忽略时,本地版本标志为忽略版本用户选择取消时,隐藏升级控制窗口 2.

Go Playground 在线编程环境

For all examples in this and the next chapter, we will use Go Playground. Go Playground represents a web service that can run programs written in Go. It can be opened in a web browser using the follow

12C 新特性,MOVE DATAFILE 在线移动 包括system, 附带改名 NID ,cdb_data_files视图坏了

ALTER DATABASE MOVE DATAFILE  可以改名 可以move file,全部一个命令。 resue 可以重用,keep好像不生效!!! system照移动不误-------- SQL> select file_name, status, online_status from dba_data_files where tablespace_name='SYSTEM'

css选择器和xpath选择器在线转换器

具体前往:Css Selector(选择器)转Xpath在线工具

C/C++ 网络聊天室在线聊天系统(整理重传)

知识点: TCP网络通信 服务端的流程: 1.创建socket套接字 2.给这个socket绑定一个端口号 3.给这个socket开启监听属性 4.等待客户端连接 5.开始通讯 6.关闭连接 解释: socket:类似于接口的东西,只有通过这个才能跟对应的电脑通信。 每一台电脑都有一个IP地址,一台电脑上有多个应用,每个应用都会有一个端口号。 socket一般分为两种类型,一种是通讯,一种是监听

【最新华为OD机试E卷-支持在线评测】机器人活动区域(100分)多语言题解-(Python/C/JavaScript/Java/Cpp)

🍭 大家好这里是春秋招笔试突围 ,一枚热爱算法的程序员 ✨ 本系列打算持续跟新华为OD-E/D卷的三语言AC题解 💻 ACM金牌🏅️团队| 多次AK大厂笔试 | 编程一对一辅导 👏 感谢大家的订阅➕ 和 喜欢💗 🍿 最新华为OD机试D卷目录,全、新、准,题目覆盖率达 95% 以上,支持题目在线评测,专栏文章质量平均 94 分 最新华为OD机试目录: https://blog.

Linux下vi编辑器命令

UNIX下的编辑器有ex,sed和vi等,其中,使用最为广泛的是vi。vi是一个创建、修改文本和数据对象的程序。他和字处理程序和桌面出版程序的区别是他只处理 plain ASCII 文本,没有格式信息。 vi 编辑器有三种处理文本的基本模式: ●一般模式:以vi处理文件时,一进入该文件就是一般模式了。在这个模式中,您可以使用上下左右按键来移动光标,可以使用“删除字符”或“删除整行”来处理文

pdf文件编辑器有哪些?分享适合新手用的5个PDF编辑器(解锁教程)

pdf是一种通用文件格式,也是一种夸操作系统平台的文件格式。 好用的PDF文件编辑器可以让您更改和添加文本、编辑图像、添加图形、签署签名、填写表单数据等。下面整理了关于pdf文件编辑方法介绍,以及一些好用的pdf编辑器,有需要的可以了解下。 一、pdf编辑软件 pdf编辑器1:金舟PDF编辑器——专业的pdf编辑 专业的pdf文件编辑工具,适用于Windows7以上的操作系统。能够完成