前几天整合了flowable-modeler 6.4.2的版本,记录下整个集成过程:
1、复制前端源码到自己工程。原有【flowable-ui-modeler-app】下的【resources/static】;
2、增加jar依赖。修改pom文件,增加如下内容:
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-process-rest</artifactId>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-rest</artifactId>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-conf</artifactId>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-logic</artifactId>
</dependency>
具体版本号以实际使用为准,例如:
<version>6.4.2</version>
3、增加DispatcherServlet配置,可以参考源码【org.flowable.ui.modeler.servlet.AppDispatcherServletConfiguration】;
4、将配置的Servlet注册进来,可以参考源码【org.flowable.ui.modeler.conf.ApplicationConfiguration】;
5、配置【SqlSessionFactory】,可以参考源码【org.flowable.ui.modeler.conf.DatabaseConfiguration】;
配置mybatis xml路径:
mybatis.mapper-locations = classpath:/META-INF/modeler-mybatis-mappings/*.xml
6、可选配置【SecurityConfiguration】,如果自由框架本身使用【spring security】进行权限管理,则无需配置;如果没有,则需要改造权限配置,具体配置可以参考源码:【org.flowable.ui.modeler.conf.SecurityConfiguration】;
完成以上操作,基本功能应该能正常运行起来了,如果报【SqlSessionFactory】的错误,请增加【mybatis】依赖,好像是需要手动引入;
由于【flowable-modeler】是依赖idm的用户管理的,要正常使用还需要改造为自己的用户管理;
7、自定义接口实现用户账号查询实现。可以参考源码【org.flowable.ui.idm.rest.app.AccountResource】的【getAccount()】方法;
8、查看【resources\static\scripts\configuration\url-config.js】,方法【getAccountUrl】获取账号的URL,修改为自定义的用户账号查询实现接口;
9、【flowable-modeler】在后续活动中,是根据【org.flowable.ui.common.security.SecurityUtils.getCurrentUserObject()】获取当前用户,该方法源码如下:
private static User assumeUser;
public static User getCurrentUserObject() {
if (assumeUser != null) {
return assumeUser;
}
User user = null;
FlowableAppUser appUser = getCurrentFlowableAppUser();
if (appUser != null) {
user = appUser.getUserObject();
}
return user;
}
方式一:很多人是通过相同包名覆写的方式处理(不推荐);
方式二:建议在合适的位置通过调用【SecurityUtils.assumeUser()】方法set【assumeUser】的值来进行处理;(推荐)
通过以上步骤,【flowable-modeler】已经完全整合,最后流程发布需要调用流程引擎服务接口,处理方式如下:
1、新增流程发布接口。可以参考源码:【org.flowable.app.rest.service.api.repository.AppDeploymentCollectionResource】的【uploadDeployment】方法;
2、配置远程URL;
flowable.modeler.app.deployment-api-url={具体的流程发布接口URL}
注意:此处的URL是【flowable-modeler】后端调用的,方法的Mapping URL无需包含到配置中;
通过以上,【flowable-modeler】已经全部整合进来,可以灵活定制;