activiti入门六集成新版activitimodeler与rest服务.docx
- 文档编号:12870127
- 上传时间:2023-04-22
- 格式:DOCX
- 页数:11
- 大小:17.39KB
activiti入门六集成新版activitimodeler与rest服务.docx
《activiti入门六集成新版activitimodeler与rest服务.docx》由会员分享,可在线阅读,更多相关《activiti入门六集成新版activitimodeler与rest服务.docx(11页珍藏版)》请在冰豆网上搜索。
activiti入门六集成新版activitimodeler与rest服务
activiti入门六(集成新版ActivitiModeler与Rest服务)
目前activiti提供的ActivitiModeler有两套,从Activiti5.17后,发布了新的ActivitiModeler组件。
本文主要介绍如何在项目中集成最新的ActivitiModeler.
新版的效果
相比于上一版,个人感觉更加的简洁,优美。
并且在Activiti5.20后,完善了很多上版本的bug。
ActivitiModeler内部的实现上还是以oryx为图形组件为内核,用angular.js作为界面基本元素的基础组件以及调度oryx的API。
Activitiexplorer的集成方式
首先,从github下载Activiti源码.在第一章已经列出具体地址:
ActivitiExploer的内部结构-Java
├──assembly
├──java
│└──org
│└──activiti
├──resources
│└──org
│└──activiti
└──webapp
├──META-INF
├──VAADIN
│├──themes
│└──widgetsets
├──WEB-INF
├──diagram-viewer
│├──images
│└──js
└──editor-app
├──configuration
├──css
├──editor
├──fonts
├──i18n
├──images
├──libs
├──partials
├──popups
└──stencilsets123456789101112131415161718192021222324252627
我们需要关注的目录是webapp/editor-app,以及java/org/activiti
新版的ActivitiExplorer放弃了XML方式的配置,采用Beanconfiguration的方式代替。
在org/activiti/explore/conf包中就是各种的配置代码,在org/activiti/explore/servlet/WebConfigurer类采用Servlet方式配置Servlet映射关系,映射路径为/service/*
ActivitiExploer的内部结构-Web
新版本ActivitiModeler的Web资源不再像旧版那么散乱,新版本只需要关注:
src/main/webapp/editor-app:
目录中包含设计器里面所有的资源:
angular.js、oryx.js以及配套的插件及css
src/main/webapp/modeler.html:
设计器的主页面,用来引入各种web资源
src/main/resources/stencilset.json:
bpmn标准里面各种组件的json定义,editor以import使用。
与项目的实际整合
ActivitiRest接口与SpringMVC配置
Maven依赖
ActivitiModeler对后台服务的调用通过SpringMVC方式实现,所有的Rest资源统一使用注解RestController标注,所以在整合到自己项目的时候需要依赖SpringMVC,Modeler模块使用的后台服务都存放在activiti-modeler模块中,在自己的项目中添加依赖:
org.activiti
activiti-modeler
5.19.0
org.activiti
activiti-diagram-rest
5.19.0
12345678910
模块作用:
activiti-modeler模块提供模型先关的操作:
创建、保存、转换json与xml格式等
activiti-diagram-rest模块用来处理流程图有关的功能:
流程图布局(layout)、节点高亮等
准备基础服务类
复制文件(h里面的java文件到自己项目中。
(参考咖啡兔的工作流代码)
ActivitiSpring配置
12345678910111213141516171819202122232425262728293031323334353637383940414243
SpringMVC配置
创建文件spring-mvc-rest.xml:
//www.springframework.org/schema/beans"xmlns: xsi="http: //www.w3.org/2001/XMLSchema-instance" xmlns: context="http: //www.springframework.org/schema/context" xmlns: mvc="http: //www.springframework.org/schema/mvc" xsi: schemaLocation="http: //www.springframework.org/schema/beanshttp: //www.springframework.org/schema/beans/spring-beans-3.1.xsd http: //www.springframework.org/schema/contexthttp: //www.springframework.org/schema/context/spring-context-3.1.xsd http: //www.springframework.org/schema/mvchttp: //www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"> 123456789101112131415 web.xml配置Servlet服务 在web.xml中配置下面的Servlet ModelRestServlet org.springframework.web.servlet.DispatcherServlet contextConfigLocation /WEB-INF/spring-mvc-modeler.xml 1 ModelRestServlet /service/* 12345678910111213 添加JSONP的过滤器 JSONPFilter org.activiti.explorer.JsonpCallbackFilter JSONPFilter /* 12345678 模型设置器web资源的整合 直接从ActivitiExplorer中复制文件modeler.html文件到src/main/webapp目录即可,该文件会引入定义基本的布局(div)、引入css以及js文件。 修改editor-app/app-cfg.js文件的contextRoot属性为自己的应用名称,例如/项目名/service 我个人是在webapp下创建了个activiti的文件夹,然后一股脑把上面的文件全部扔进去。 不一定需要直接放到webapp下,注意路径即可。 模型控制器 create方法中在创建完Model后跳转页面为modeler.html? modelId= 当从模型列表编辑某一个模型时也需要把路径修改为modeler.html? modelId= 如果像我上面放到activiti文件夹下,此处注意需要修改对应的路径。 整合ActivitiRest maven依赖 org.activiti activiti-rest 5.19.0 12345 activiti组件包扫描 在activiti的Spring配置文件中增加org.activiti.rest.service包的扫描,具体如下(在上面已经加了进来,此步骤可以忽略。 ): 1234 添加Rest安全认证组件 packageorg.activiti.conf; importorg.activiti.rest.security.BasicAuthenticationProvider; importorg.springframework.context.annotation.Bean; importorg.springframework.context.annotation.Configuration; importorg.springframework.security.authentication.AuthenticationProvider; importorg.springframework.security.config.annotation.web.builders.HttpSecurity; importorg.springframework.security.config.annotation.web.configuration.EnableWebSecurity; importorg.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; importorg.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity; importorg.springframework.security.config.http.SessionCreationPolicy; @Configuration @EnableWebSecurity @EnableWebMvcSecurity publicclassSecurityConfigurationextendsWebSecurityConfigurerAdapter{ @Bean publicAuthenticationProviderauthenticationProvider(){ returnnewBasicAuthenticationProvider(); } @Override protectedvoidconfigure(HttpSecurityhttp)throwsException{ http.authenticationProvider(authenticationProvider()) .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() .csrf().disable() .authorizeRequests() .anyRequest().authenticated() .and() .httpBasic(); } } 12345678910111213141516171819202122232425262728293031323334 Spingmvc配置文件 创建文件spring-mvc-rest.xml: //www.springframework.org/schema/beans"xmlns: xsi="http: //www.w3.org/2001/XMLSchema-instance" xmlns: context="http: //www.springframework.org/schema/context" xmlns: mvc="http: //www.springframework.org/schema/mvc" xsi: schemaLocation="http: //www.springframework.org/schema/beanshttp: //www.springframework.org/schema/beans/spring-beans-3.1.xsd http: //www.springframework.org/schema/contexthttp: //www.springframework.org/schema/context/spring-context-3.1.xsd http: //www.springframework.org/schema/mvchttp: //www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"> 123456789101112131415 配置Servlet映射 RestServlet org.springframework.web.servlet.DispatcherServlet contextConfigLocation /WEB-INF/spring-mvc-rest.xml 1 RestServlet /rest/* 12345678910111213 访问Rest接口 现在启动应用可以访问http: //localhost: 8080/your-app/rest/management/properties以Rest方式查看引擎的属性列表. 整合过程中的某些优化 去掉ActivitiAfresco的logo标题栏,并且把样式上的空白栏去掉 修改modeler.html中的以下内容,注意不要把该文本删除,建议加style=”display: none”,删除后其会造成底层下的一些内容有40个像数的东西显示不出来。 {{'GENERAL.MAIN-TITLE'|translate}} 1234567 在editor-app/css/style-common.css中,把以下样式的padding-top部分改为0px; .wrapper.full{ padding: 40px0px0px0px; overflow: hidden; max-width: 100%; min-width: 100%; }123456 在modeler.html中加上CloseWindow的函数,默认编辑器关闭后是加载项目主页的,以下代码是直接关闭该tab页面。 functionCloseWindow(action){ if(window.CloseOwnerWindow)returnwindow.CloseOwnerWindow(action); elsewindow.close(); } 123456 在editor-app/configuration/toolbar-default-actions.js中,修改以下代码,注释为原有代码 closeEditor: function(services){ CloseWindow('ok'); //window.location.href="./"; },1234 $scope.saveAndClose=function(){ $scope.save(function(){ CloseWindow('ok'); //window.location.href="./"; }); };123456
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- activiti 入门 集成 新版 activitimodeler rest 服务