You can download tomcat-flowable to configure the mysql data source, first modify the configuration file flowable-defauilt.properties and then copy the database driver package to the lib folder
Automatically create table after success
Related to the data sheet
Staff organization | ||
---|---|---|
ACT_ID_USER | user table | You can create your own table as a view, the view name is the same |
ACT_ID_GROUP | Group table/role | |
ACT_ID_MEMBERSHIP | User role table | |
ACT_ID_INFO | Personnel details table | idm temporarily not used |
ACT_ID_PRIV | Permission table (five modules) | Remove idm login |
ACT_ID_PRIV_MAPPING | Five modules and users, role relationship table | |
ACT_ID_BYTEARRAY | Binary data table | idm temporarily not used |
ACT_ID_PROPERTY | Attribute table | The data in it is maintained by flowable, don’t move |
ACT_ID_TOKEN | System login log table |
New projects operate various APIs on idm engine
import org.flowable.idm.api.Group;
import org.flowable.idm.api.IdmIdentityService;
import org.flowable.idm.api.IdmManagementService;
import org.flowable.idm.api.User;
import org.flowable.idm.engine.IdmEngine;
import org.flowable.idm.engine.IdmEngineConfiguration;
import org.flowable.idm.engine.impl.persistence.entity.GroupEntityImpl;
import org.flowable.idm.engine.impl.persistence.entity.UserEntityImpl;
import org.junit.Before;
import org.junit.Test;
import java.io.InputStream;
public class IdmTest {
IdmEngine idmEngine;
IdmIdentityService idmIdentityService;
IdmEngineConfiguration idmEngineConfiguration;
IdmManagementService idmManagementService;
@Before
public void init() {
InputStream resourceAsStream = IdmTest.class.getClassLoader().getResourceAsStream("flowable.idm.cfg.xml");
idmEngine = IdmEngineConfiguration.createIdmEngineConfigurationFromInputStream(resourceAsStream).buildIdmEngine();
idmIdentityService = idmEngine.getIdmIdentityService();
idmEngineConfiguration = idmEngine.getIdmEngineConfiguration();
idmManagementService = idmEngine.getIdmManagementService();
String engineName = idmEngine.getName();
System.out.println("引擎的名称" + engineName);
}
@Test
public void addUser() {
UserEntityImpl user = new UserEntityImpl();
user.setEmail("[email protected]");
user.setId("test");
user.setPassword("test");
//0代表新增 默认为1 会报空指针异常
user.setRevision(0);
idmIdentityService.saveUser(user);
}
@Test
public void addGroup() {
GroupEntityImpl group = new GroupEntityImpl();
group.setId("dep_yanfa");
group.setName("开发部");
//0代表新增 默认为1 会报空指针异常
group.setRevision(0);
idmIdentityService.saveGroup(group);
}
@Test
public void createMembership() {
String userId = "test";
String groupId = "dep_yanfa";
idmIdentityService.createMembership(userId, groupId);
}
@Test
public void createUserQuery() {
idmIdentityService.createUserQuery().list().forEach(u -> {
System.out.println(u.getId() + " " + u.getPassword());
});
}
@Test
public void createGroupQuery() {
idmIdentityService.createGroupQuery().list().forEach(u -> {
System.out.println(u.getId() + " " + u.getName());
});
}
@Test
public void createPrivilegeQuery() {
idmIdentityService.createPrivilegeQuery().list().forEach(p -> System.out.println(p.getId() + " " + p.getName()));
}
@Test
public void addUserPrivilegeMapping() {
idmIdentityService.addUserPrivilegeMapping("e3ac7826-c730-11ea-89f5-005056c00008", "test");
}
@Test
public void addGroupPrivilegeMapping() {
idmIdentityService.addGroupPrivilegeMapping("e3ac7826-c730-11ea-89f5-005056c00008", "dep_yanfa");
}
@Test
public void getTableCount() {
idmManagementService.getTableCount().forEach((s, aLong) -> System.out.println(s + " " + aLong));
}
}
Configuration file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="idmEngineConfiguration" class="org.flowable.idm.engine.IdmEngineConfiguration">
<property name="dataSource" ref="dataSource"></property>
<property name="databaseSchemaUpdate" value="true"></property>
</bean>
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://127.0.0.1:3306/flowable?useUnicode=true&characterEncoding=UTF-8
</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password" value="123456"/>
</bean>
</beans>
maven
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>idm-junit</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<slf4j.version>1.7.25</slf4j.version>
</properties>
<dependencies>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.flowable/flowable-spring -->
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring</artifactId>
<version>6.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.flowable/flowable-engine -->
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-engine</artifactId>
<version>6.4.0</version>
</dependency>
<!-- dbpool的jar -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.2</version>
</dependency>
<!-- mysql驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.28</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
</project>