深圳戈麦斯网站开发,电子商务网站规划与建设的论文,移动互联网开放合作联盟,全国哪个餐饮品牌的网站做的好处因公司需求需要将flowable的流程设计器集成到项目中#xff0c;下面将最近的研究成果记录一下。 文章目录一、下载flowable-modeler源码二、添加相关maven包三、调用idm服务重新接口四、配置类五、启动类跳过登陆拦截六、配置文件一、下载flowable-modeler源码
把flowable-ui… 因公司需求需要将flowable的流程设计器集成到项目中下面将最近的研究成果记录一下。 文章目录一、下载flowable-modeler源码二、添加相关maven包三、调用idm服务重新接口四、配置类五、启动类跳过登陆拦截六、配置文件一、下载flowable-modeler源码
把flowable-ui-modeler-app\src\main\resources\static下面的代码拷贝至我们自己的工程
二、添加相关maven包
?xml version1.0 encodingUTF-8?
project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.0.7.RELEASE/versionrelativePath/ !-- lookup parent from repository --/parentgroupIdcom.gblfy/groupIdartifactIdflowable/artifactIdversion0.0.1-SNAPSHOT/versionnameflowable_modeler/namedescriptionDemo project for Spring Boot/descriptionpropertiesjava.version1.8/java.version/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId!--去除本身的logback使用log4j如果想要使用logback需要添加commons-logging--exclusions!-- 去除旧log依赖 --exclusiongroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-logging/artifactId/exclusion/exclusions/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdexclusions!--去除本身的logback使用log4j如果想要使用logback需要添加commons-logging--exclusiongroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-logging/artifactId/exclusion/exclusionsscopetest/scope/dependency!-- https://mvnrepository.com/artifact/commons-io/commons-io --dependencygroupIdcommons-io/groupIdartifactIdcommons-io/artifactIdversion2.6/version/dependencydependencygroupIdorg.flowable/groupIdartifactIdflowable-groovy-script-static-engine/artifactIdversion6.4.1/version/dependencydependencygroupIdorg.codehaus.groovy/groupIdartifactIdgroovy-all/artifactIdversion2.5.4/versiontypepom/type/dependency!-- https://mvnrepository.com/artifact/commons-io/commons-io --dependencygroupIdcommons-io/groupIdartifactIdcommons-io/artifactIdversion2.6/version/dependencydependencygroupIdorg.mybatis.spring.boot/groupIdartifactIdmybatis-spring-boot-starter/artifactIdversion2.0.0/version/dependency!-- https://mvnrepository.com/artifact/org.liquibase/liquibase-core --dependencygroupIdorg.liquibase/groupIdartifactIdliquibase-core/artifactIdversion3.6.2/version/dependency!-- Logging --dependencygroupIdorg.slf4j/groupIdartifactIdslf4j-api/artifactIdversion${slf4j.version}/version/dependencydependencygroupIdorg.slf4j/groupIdartifactIdslf4j-log4j12/artifactIdversion${slf4j.version}/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-test/artifactId/dependencydependencygroupIdjunit/groupIdartifactIdjunit/artifactId/dependency!-- https://mvnrepository.com/artifact/org.springframework/spring-test --dependencygroupIdorg.springframework/groupIdartifactIdspring-test/artifactIdversion5.0.9.RELEASE/version/dependency!-- https://mvnrepository.com/artifact/org.flowable/flowable-spring-boot-starter-process --dependencygroupIdorg.flowable/groupIdartifactIdflowable-spring-boot-starter-process/artifactIdversion6.4.1/version/dependencydependencygroupIdorg.flowable/groupIdartifactIdflowable-ui-modeler-rest/artifactIdversion6.4.1/version/dependency!-- dbpool的jar --dependencygroupIdcom.alibaba/groupIdartifactIddruid/artifactIdversion1.1.12/version/dependency!-- mysql驱动包 --dependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactIdversion5.1.28/version/dependency/dependenciesbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build/project
三、调用idm服务重新接口
flowable获取用户是调用idm服务这里前端修改获取用户信息接口自己实现接口
package com.gblfy.flowable.controller;import org.flowable.idm.api.User;
import org.flowable.idm.engine.impl.persistence.entity.UserEntityImpl;
import org.flowable.ui.common.model.UserRepresentation;
import org.flowable.ui.common.security.SecurityUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;import java.util.ArrayList;
import java.util.List;/*** ClassName GblfyRemoteAccountResource* Description 內置用户登录* Author gblfy* Date 2019/11/17 20:12*/
RestController
RequestMapping(/gblfy)
public class GblfyRemoteAccountResource {/*** GET /rest/account - get the current user.*/RequestMapping(value /rest/account, method RequestMethod.GET, produces application/json)public UserRepresentation getAccount() {User usernew UserEntityImpl();user.setId(gblfy);SecurityUtils.assumeUser(user);UserRepresentation userRepresentation new UserRepresentation();userRepresentation.setId(gblfy);userRepresentation.setFirstName(gblfy);ListString privilegesnew ArrayList();privileges.add(flowable-idm);privileges.add(flowable-modeler);privileges.add(flowable-task);userRepresentation.setPrivileges(privileges);return userRepresentation;}
}四、配置类
package com.gblfy.flowable.config;import liquibase.Liquibase;
import liquibase.database.Database;
import liquibase.database.DatabaseConnection;
import liquibase.database.DatabaseFactory;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.DatabaseException;
import liquibase.resource.ClassLoaderResourceAccessor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.flowable.common.engine.api.FlowableException;
import org.flowable.spring.SpringProcessEngineConfiguration;
import org.flowable.ui.common.service.exception.InternalServerErrorException;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.ResourcePatternUtils;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.Properties;/*** ClassName ZhuangzProcessEngine* Description TODO 构造流程引擎配置类* Author gblfy* Date 2019/11/17 20:12*/
Configuration
public class GblfyProcessEngine {private static final Logger LOGGER LoggerFactory.getLogger(GblfyProcessEngine.class);//TODO 解决创建流程时报act_re_model找不到protected static final String LIQUIBASE_CHANGELOG_PREFIX ACT_DE_;Autowiredprivate DataSource dataSource;Autowiredprotected ResourceLoader resourceLoader;//事务管理器Beanpublic DataSourceTransactionManager dataSourceTransactionManager(DataSource dataSource){DataSourceTransactionManager dataSourceTransactionManager new DataSourceTransactionManager(dataSource);return dataSourceTransactionManager;}Beanpublic SpringProcessEngineConfiguration springProcessEngineConfiguration(){SpringProcessEngineConfiguration springProcessEngineConfiguration new SpringProcessEngineConfiguration();springProcessEngineConfiguration.setDataSource(dataSource);springProcessEngineConfiguration.setDatabaseSchemaUpdate(true);springProcessEngineConfiguration.setTransactionManager(dataSourceTransactionManager(dataSource));return springProcessEngineConfiguration;}Beanpublic SqlSessionFactory sqlSessionFactory(DataSource dataSource) {SqlSessionFactoryBean sqlSessionFactoryBean new SqlSessionFactoryBean();sqlSessionFactoryBean.setDataSource(dataSource);String databaseType initDatabaseType(dataSource);if (databaseType null) {throw new FlowableException(couldnt deduct database type);}try {Properties properties new Properties();properties.put(prefix, );properties.put(blobType, BLOB);properties.put(boolValue, TRUE);properties.load(this.getClass().getClassLoader().getResourceAsStream(properties/ databaseType .properties));sqlSessionFactoryBean.setConfigurationProperties(properties);sqlSessionFactoryBean.setMapperLocations(ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources(classpath:/META-INF/modeler-mybatis-mappings/*.xml));sqlSessionFactoryBean.afterPropertiesSet();return sqlSessionFactoryBean.getObject();} catch (Exception e) {throw new FlowableException(Could not create sqlSessionFactory, e);}}protected String initDatabaseType(DataSource dataSource) {String databaseType null;Connection connection null;try {connection dataSource.getConnection();DatabaseMetaData databaseMetaData connection.getMetaData();String databaseProductName databaseMetaData.getDatabaseProductName();LOGGER.info(database product name: {}, databaseProductName);databaseType databaseTypeMappings.getProperty(databaseProductName);if (databaseType null) {throw new FlowableException(couldnt deduct database type from database product name databaseProductName );}LOGGER.info(using database type: {}, databaseType);} catch (SQLException e) {LOGGER.error(Exception while initializing Database connection, e);} finally {try {if (connection ! null) {connection.close();}} catch (SQLException e) {LOGGER.error(Exception while closing the Database connection, e);}}return databaseType;}protected static Properties databaseTypeMappings getDefaultDatabaseTypeMappings();public static final String DATABASE_TYPE_MYSQL mysql;public static final String DATABASE_TYPE_ORACLE oracle;public static Properties getDefaultDatabaseTypeMappings() {Properties databaseTypeMappings new Properties();databaseTypeMappings.setProperty(MySQL, DATABASE_TYPE_MYSQL);databaseTypeMappings.setProperty(Oracle, DATABASE_TYPE_ORACLE);return databaseTypeMappings;}Beanpublic Liquibase liquibase(DataSource dataSource) {LOGGER.info(Configuring Liquibase);Liquibase liquibase null;try {DatabaseConnection connection new JdbcConnection(dataSource.getConnection());Database database DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection);//TODO 解决创建流程时报act_re_model找不到database.setDatabaseChangeLogTableName(LIQUIBASE_CHANGELOG_PREFIX database.getDatabaseChangeLogTableName());database.setDatabaseChangeLogLockTableName(LIQUIBASE_CHANGELOG_PREFIX database.getDatabaseChangeLogLockTableName());liquibase new Liquibase(META-INF/liquibase/flowable-modeler-app-db-changelog.xml, new ClassLoaderResourceAccessor(), database);liquibase.update(flowable);return liquibase;} catch (Exception e) {throw new InternalServerErrorException(Error creating liquibase database, e);} finally {closeDatabase(liquibase);}}private void closeDatabase(Liquibase liquibase) {if (liquibase ! null) {Database database liquibase.getDatabase();if (database ! null) {try {database.close();} catch (DatabaseException e) {LOGGER.warn(Error closing database, e);}}}}
}
五、启动类跳过登陆拦截
package com.gblfy.flowable;import org.flowable.ui.modeler.properties.FlowableModelerAppProperties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;/*** SpringBoot启动类** Description跳过登陆拦截* Author gblfy* Date 2019/11/17 20:12*/
SpringBootApplication(exclude {SecurityAutoConfiguration.class})
ComponentScan(basePackages {com.gblfy.flowable,org.flowable.ui.modeler,org.flowable.ui.common})
public class FlowableApplication {public static void main(String[] args) {SpringApplication.run(FlowableApplication.class, args);}Beanpublic FlowableModelerAppProperties flowableModelerAppProperties(){FlowableModelerAppProperties flowableModelerAppProperties new FlowableModelerAppProperties();return flowableModelerAppProperties;}
}六、配置文件
server:port: 80
spring:datasource:url: jdbc:mysql://localhost:3306/flowable_boot?zeroDateTimeBehaviorconvertToNulluseUnicodetrueuseSSLfalserewriteBatchedStatementstruedriver-class-name: com.mysql.jdbc.Driverusername: rootpassword: roottype: com.alibaba.druid.pool.DruidDataSourceflowable:#关闭定时任务JOBasync-executor-activate: false将databaseSchemaUpdate设置为true。当Flowable发现库与数据库表结构不一致时,会自动将数据库表结构升级至新版本。database-schema-update: truecommon:app:idm-url: http://127.0.0.1://80/flowable-idm项目源码下载 https://gitee.com/gb_90/flow-modeler-sduty