Skip to content

Commit 01e70f4

Browse files
committed
jbpm 实例
1 parent 4553d6a commit 01e70f4

File tree

7 files changed

+721
-49
lines changed

7 files changed

+721
-49
lines changed

.idea/workspace.xml

Lines changed: 446 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pom.xml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,20 @@
2222
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2323
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2424
<java.version>1.8</java.version>
25+
<jbpm4.version>4.3</jbpm4.version>
2526
</properties>
2627

28+
<repositories>
29+
<repository>
30+
<id>maven</id>
31+
<url>http://repo1.maven.org/maven2/</url>
32+
</repository>
33+
<repository>
34+
<id>jboss</id>
35+
<url>https://repository.jboss.org/nexus/content/repositories/releases</url>
36+
</repository>
37+
</repositories>
38+
2739
<dependencies>
2840
<dependency>
2941
<groupId>org.springframework.boot</groupId>
@@ -35,6 +47,125 @@
3547
<artifactId>spring-boot-starter-test</artifactId>
3648
<scope>test</scope>
3749
</dependency>
50+
51+
<!-- jBPM4.4 -->
52+
<dependency>
53+
<groupId>org.jbpm.jbpm4</groupId>
54+
<artifactId>jbpm-api</artifactId>
55+
<version>4.4</version>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.jbpm.jbpm4</groupId>
59+
<artifactId>jbpm-log</artifactId>
60+
<version>4.4</version>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.jbpm.jbpm4</groupId>
64+
<artifactId>jbpm-bpmn</artifactId>
65+
<version>4.4</version>
66+
<exclusions>
67+
<exclusion>
68+
<groupId>junit</groupId>
69+
<artifactId>junit</artifactId>
70+
</exclusion>
71+
<exclusion>
72+
<groupId>org.beanshell</groupId>
73+
<artifactId>bsh</artifactId>
74+
</exclusion>
75+
</exclusions>
76+
</dependency>
77+
<dependency>
78+
<groupId>org.jbpm.jbpm4</groupId>
79+
<artifactId>jbpm-db</artifactId>
80+
<version>4.4</version>
81+
<exclusions>
82+
<exclusion>
83+
<groupId>hsqldb</groupId>
84+
<artifactId>hsqldb</artifactId>
85+
</exclusion>
86+
<exclusion>
87+
<groupId>mysql</groupId>
88+
<artifactId>mysql-connector-java</artifactId>
89+
</exclusion>
90+
<exclusion>
91+
<groupId>postgresql</groupId>
92+
<artifactId>postgresql</artifactId>
93+
</exclusion>
94+
</exclusions>
95+
</dependency>
96+
<dependency>
97+
<groupId>org.jbpm.jbpm4</groupId>
98+
<artifactId>jbpm-jpdl</artifactId>
99+
<version>4.4</version>
100+
<exclusions>
101+
<exclusion>
102+
<groupId>junit</groupId>
103+
<artifactId>junit</artifactId>
104+
</exclusion>
105+
</exclusions>
106+
</dependency>
107+
<dependency>
108+
<groupId>org.jbpm.jbpm4</groupId>
109+
<artifactId>jbpm-pvm</artifactId>
110+
<version>4.4</version>
111+
<exclusions>
112+
<exclusion>
113+
<groupId>org.slf4j</groupId>
114+
<artifactId>slf4j-api</artifactId>
115+
</exclusion>
116+
<exclusion>
117+
<groupId>org.slf4j</groupId>
118+
<artifactId>slf4j-jdk14</artifactId>
119+
</exclusion>
120+
<exclusion>
121+
<groupId>org.hibernate</groupId>
122+
<artifactId>hibernate-core</artifactId>
123+
</exclusion>
124+
</exclusions>
125+
</dependency>
126+
<dependency>
127+
<groupId>xerces</groupId>
128+
<artifactId>xercesImpl</artifactId>
129+
<version>2.9.1</version>
130+
</dependency>
131+
132+
<!-- slf4j -->
133+
<dependency>
134+
<groupId>org.slf4j</groupId>
135+
<artifactId>slf4j-api</artifactId>
136+
<version>1.6.1</version>
137+
</dependency>
138+
<dependency>
139+
<groupId>org.slf4j</groupId>
140+
<artifactId>slf4j-log4j12</artifactId>
141+
<version>1.6.1</version>
142+
</dependency>
143+
<dependency>
144+
<groupId>log4j</groupId>
145+
<artifactId>log4j</artifactId>
146+
<version>1.2.16</version>
147+
</dependency>
148+
149+
<!-- Hibernate -->
150+
<dependency>
151+
<groupId>org.hibernate</groupId>
152+
<artifactId>hibernate-core</artifactId>
153+
<version>3.6.10.Final</version>
154+
</dependency>
155+
156+
<!-- mysql-jdbc -->
157+
<dependency>
158+
<groupId>mysql</groupId>
159+
<artifactId>mysql-connector-java</artifactId>
160+
<version>5.1.18</version>
161+
</dependency>
162+
163+
<dependency>
164+
<groupId>javax.mail</groupId>
165+
<artifactId>javax.mail-api</artifactId>
166+
<version>1.4.7</version>
167+
</dependency>
168+
38169
</dependencies>
39170

40171
<build>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.code.repository;
2+
import org.jbpm.api.Configuration;
3+
import org.jbpm.api.ProcessEngine;
4+
import org.jbpm.api.RepositoryService;
5+
import org.jbpm.api.task.Task;
6+
import org.junit.Test;
7+
import org.junit.runner.RunWith;
8+
import org.springframework.boot.test.context.SpringBootTest;
9+
import org.springframework.test.context.junit4.SpringRunner;
10+
11+
import java.util.List;
12+
13+
@RunWith(SpringRunner.class)
14+
@SpringBootTest
15+
public class JbpmTest {
16+
17+
@Test
18+
public void test(){
19+
System.out.println("test");
20+
}
21+
22+
@Test
23+
public void createSchema() { // hbm2ddl.auto=update
24+
new org.hibernate.cfg.Configuration().configure("jbpm.hibernate.cfg.xml").buildSessionFactory();
25+
}
26+
27+
// 一、部署流程定义
28+
@Test
29+
public void deployProcessDefinition() {
30+
ProcessEngine processEngine = Configuration.getProcessEngine();
31+
RepositoryService repositoryService = processEngine.getRepositoryService();
32+
repositoryService.createDeployment().addResourceFromClasspath("jbpm.jpdl.xml").deploy();
33+
}
34+
35+
@Test
36+
public void startProcessInstance() {
37+
ProcessEngine processEngine = Configuration.getProcessEngine();
38+
processEngine.getExecutionService().startProcessInstanceByKey("test");
39+
}
40+
41+
@Test
42+
public void findMyTaskList() {
43+
ProcessEngine processEngine = Configuration.getProcessEngine();
44+
// 查询任务
45+
String userId = "员工";
46+
List<Task> list = processEngine.getTaskService().findPersonalTasks(userId);
47+
48+
// 显示任务
49+
System.out.println("========= 【"+userId+"】的未办理的任务列表 =========");
50+
for (Task task : list) {
51+
System.out.println("id=" + task.getId()//
52+
+ ", name=" + task.getName()//
53+
+ ", assignee=" + task.getAssignee()//
54+
+ ", createTime=" + task.getCreateTime());
55+
}
56+
}
57+
58+
@Test
59+
public void completeTask() {
60+
ProcessEngine processEngine = Configuration.getProcessEngine();
61+
String taskId = "20002";
62+
processEngine.getTaskService().completeTask(taskId);
63+
}
64+
65+
66+
67+
}

src/test/java/jbpm.cfg.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<jbpm-configuration>
4+
5+
<import resource="jbpm.default.cfg.xml" />
6+
<import resource="jbpm.businesscalendar.cfg.xml" />
7+
<import resource="jbpm.tx.hibernate.cfg.xml" />
8+
<import resource="jbpm.jpdl.cfg.xml" />
9+
<import resource="jbpm.bpmn.cfg.xml" />
10+
<import resource="jbpm.identity.cfg.xml" />
11+
12+
<!-- Job executor is excluded for running the example test cases. -->
13+
<!-- To enable timers and messages in production use, this should be included. -->
14+
<!--
15+
<import resource="jbpm.jobexecutor.cfg.xml" />
16+
-->
17+
18+
</jbpm-configuration>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<!DOCTYPE hibernate-configuration PUBLIC
4+
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
5+
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
6+
7+
<hibernate-configuration>
8+
<session-factory>
9+
10+
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
11+
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/jbpm</property>
12+
<property name="hibernate.connection.username">root</property>
13+
<property name="hibernate.connection.password">root</property>
14+
<property name="hibernate.hbm2ddl.auto">update</property>
15+
<property name="hibernate.format_sql">true</property>
16+
17+
<mapping resource="jbpm.repository.hbm.xml" />
18+
<mapping resource="jbpm.execution.hbm.xml" />
19+
<mapping resource="jbpm.history.hbm.xml" />
20+
<mapping resource="jbpm.task.hbm.xml" />
21+
<mapping resource="jbpm.identity.hbm.xml" />
22+
23+
</session-factory>
24+
</hibernate-configuration>

src/test/java/jbpm.jpdl.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<process name="test" xmlns="http://jbpm.org/4.4/jpdl">
4+
<start g="247,9,48,48" name="start1">
5+
<transition g="-69,-22" name="to 员工提交申请" to="员工提交申请"/>
6+
</start>
7+
<end g="244,326,48,48" name="end1"/>
8+
<task assignee="员工" g="223,84,92,52" name="员工提交申请">
9+
<transition g="-93,-22" name="to 部门经理审批" to="部门经理审批"/>
10+
</task>
11+
<task assignee="部门经理" g="226,161,92,52" name="部门经理审批">
12+
<transition g="-81,-22" name="to 总经理审批" to="总经理审批"/>
13+
</task>
14+
<task assignee="总经理" g="222,244,92,52" name="总经理审批">
15+
<transition g="-50,-22" name="to end1" to="end1"/>
16+
</task>
17+
</process>

src/test/java/logging.properties

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
handlers= java.util.logging.ConsoleHandler
2+
redirect.commons.logging = enabled
3+
4+
java.util.logging.ConsoleHandler.level = FINEST
5+
java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
6+
7+
org.jbpm.level=FINE
8+
# org.jbpm.pvm.internal.tx.level=FINE
9+
# org.jbpm.pvm.internal.wire.level=FINE
10+
# org.jbpm.pvm.internal.util.level=FINE
11+
12+
org.hibernate.level=INFO
13+
org.hibernate.cfg.SettingsFactory.level=SEVERE
14+
org.hibernate.cfg.HbmBinder.level=SEVERE
15+
org.hibernate.SQL.level=FINEST
16+
org.hibernate.type.level=FINEST
17+
# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
18+
# org.hibernate.transaction.level=FINEST

0 commit comments

Comments
 (0)