- 浏览: 3420859 次
- 性别:
- 来自: 珠海
文章分类
- 全部博客 (1633)
- Java (250)
- Android&HTML5 (111)
- Struts (10)
- Spring (236)
- Hibernate&MyBatis (115)
- SSH (49)
- jQuery插件收集 (55)
- Javascript (145)
- PHP (77)
- REST&WebService (18)
- BIRT (27)
- .NET (7)
- Database (105)
- 设计模式 (16)
- 自动化和测试 (19)
- Maven&Ant (43)
- 工作流 (36)
- 开源应用 (156)
- 其他 (16)
- 前台&美工 (119)
- 工作积累 (0)
- OS&Docker (83)
- Python&爬虫 (28)
- 工具软件 (157)
- 问题收集 (61)
- OFbiz (6)
- noSQL (12)
最新评论
-
HEZR曾嶸:
你好博主,这个不是很理解,能解释一下嘛//左边+1,上边+1, ...
java 两字符串相似度计算算法 -
天使建站:
写得不错,可以看这里,和这里的这篇文章一起看,有 ...
jquery 遍历对象、数组、集合 -
xue88ming:
很有用,谢谢
@PathVariable映射出现错误: Name for argument type -
jnjeC:
厉害,困扰了我很久
MyBatis排序时使用order by 动态参数时需要注意,用$而不是# -
TopLongMan:
非常好,很实用啊。。
PostgreSQL递归查询实现树状结构查询
pom.xml
-----------------------------------
src/main/resources/ehcache.xml
-----------------------------------
src/main/resources/jdbc.properties
-----------------------------------
jdbc.driver=net.sf.log4jdbc.DriverSpy
jdbc.url=jdbc:log4jdbc:mysql://localhost:3306/jbpmtest?createDatabaseIfNotExist=true
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://localhost:3306/jbpmtest?createDatabaseIfNotExist=true
jdbc.username=root
jdbc.password=root
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
src/main/resources/log4j.properties
-----------------------------------
#log4j.rootLogger=info, stdout, logfile
log4j.rootLogger=info, stdout, HUB
# log4jdbc
log4j.logger.jdbc.sqlonly=INFO
log4j.logger.jdbc.sqltiming=INFO
log4j.logger.jdbc.audit=OFF
log4j.logger.jdbc.resultset=OFF
log4j.logger.jdbc.connection=OFF
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yy-MM-dd HH:mm} %5p %c{1}:%L - %m%n
#log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.logfile.File=c:/deimos.log
#log4j.appender.logfile.DatePattern='.'yyyy-MM-dd
#log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
#log4j.appender.logfile.layout.ConversionPattern=%d{yy-MM-dd HH:mm} %5p %c{1}:%L - %m%n
log4j.logger.com.mosso=debug
log4j.logger.org.springframework.batch=DEBUG
log4j.logger.org.springframework.transaction=INFO
log4j.logger.org.springframework=error
log4j.category.org.springframework.beans.factory=DEBUG
log4j.appender.HUB=org.apache.log4j.net.SocketHubAppender
log4j.appender.HUB.layout=org.apache.log4j.PatternLayout
log4j.appender.HUB.layout.ConversionPattern=[cc]%d{MMM-dd HH:mm:ss} %-14.14c{1}- %m%n
log4j.appender.HUB.port=4445
src/main/resources/META-INF/JBPMorm.xml(没使用到)
-----------------------------------
src/main/resources/META-INF/Taskorm.xml
-----------------------------------
src/main/resources/META-INF/persistence.xml
-----------------------------------
src/main/java/com/gds/jbpm/JBPMUserGroupCallback.java
-----------------------------------
src/main/java/com/gds/jbpm/MyLocalTaskService.java
-----------------------------------
src/main/java/com/gds/web/OrderController.java
-----------------------------------
src/main/resources/applicationContext.xml
-----------------------------------
先不说jbpm和activiti以后的发展谁更好,但很难否定,这个阶段activit比较成熟,毕竟activiti是沿着jbpm的前身前进, jbpm5变成一个全新的东西,抛弃了所有以前的东西,转而全新开始,稳定性还没足够好把。
附件有源码 可以试试
-----------------------------------
<?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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.jbpm</groupId> <artifactId>jbpm-maven-example</artifactId> <name>jBPM Maven Project</name> <version>1.0-SNAPSHOT</version> <properties> <spring.version>3.1.4.RELEASE</spring.version> <aspectj.version>1.6.2</aspectj.version> <jboss.netty.version>3.2.0.Final</jboss.netty.version> <mysql.version>5.1.10</mysql.version> <hibernate.version>4.2.1.Final</hibernate.version> <hibernateCommAnn.version>3.2.0.Final</hibernateCommAnn.version> <hibernateAnn.version>3.5.6-Final</hibernateAnn.version> <cglib.version>2.2.2</cglib.version> <slf4j.version>1.6.1</slf4j.version> <log4j.version>1.2.16</log4j.version> <jbpm.version>5.4.0.Final</jbpm.version> <drools.version>5.5.0.Final</drools.version> </properties> <repositories> <!-- use this repository for stable releases --> <repository> <id>jboss-public-repository-group</id> <name>JBoss Public Maven Repository Group</name> <url>https://repository.jboss.org/nexus/content/groups/public/</url> <layout>default</layout> <releases> <enabled>true</enabled> <updatePolicy>never</updatePolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> <!-- use this repository for snapshot releases --> <repository> <id>jboss-snapshot-repository-group</id> <name>JBoss SNAPSHOT Maven Repository Group</name> <url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url> <layout>default</layout> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>never</updatePolicy> </snapshots> </repository> </repositories> <dependencies> <!-- Spring 3 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-asm</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> <optional>true</optional> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> <dependency> <groupId>org.apache.openjpa</groupId> <artifactId>openjpa-persistence</artifactId> <version>2.2.2</version> </dependency> <!-- Hibernate --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-commons-annotations</artifactId> <version>${hibernateCommAnn.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-annotations</artifactId> <version>${hibernateAnn.version}</version> </dependency> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>${cglib.version}</version> </dependency> <dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.0-api</artifactId> <version>1.0.1.Final</version> </dependency> <!-- JBOSS Cache & Hibernate --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-ehcache</artifactId> <version>4.2.1.Final</version> </dependency> <dependency> <groupId>hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>1.8.0.4</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-testing</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache-core</artifactId> <version>2.4.3</version> </dependency> <!-- JBPM5.4 --> <dependency> <groupId>org.drools</groupId> <artifactId>drools-spring</artifactId> <version>${drools.version}</version> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-bpmn2</artifactId> <version>${jbpm.version}</version> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-human-task-core</artifactId> <version>${jbpm.version}</version> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-persistence-jpa</artifactId> <version>${jbpm.version}</version> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-bam</artifactId> <version>${jbpm.version}</version> </dependency> <!-- Log4j --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>org.lazyluke</groupId> <artifactId>log4jdbc-remix</artifactId> <version>0.2.7</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> </dependency> </dependencies> <build> <finalName>JBPM54sh</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.5</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <archive> <manifest> <!--<addClasspath>true</addClasspath> --> </manifest> <manifestEntries> <Built-By>org-builder</Built-By> <Build-Jdk>${java.version}</Build-Jdk> </manifestEntries> </archive> </configuration> </plugin> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.20</version> <configuration> <contextPath>/JBPM54sh</contextPath> <!--<webDefaultXml>webdefault.xml</webDefaultXml> --> <scanIntervalSeconds>0</scanIntervalSeconds> <scanTargetPatterns> <scanTargetPattern> <directory>src/main/webapp/WEB-INF</directory> <excludes> <exclude>**/*.jsp</exclude> </excludes> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> </scanTargetPattern> </scanTargetPatterns> </configuration> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.0.2</version> <configuration> <archive> <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> </manifest> <manifestEntries> <Implementation-Build>${buildNumber}</Implementation-Build> </manifestEntries> </archive> <dependentWarExcludes> **/jdbc.properties,**/web.xml,WEB-INF/classes/META-INF/** </dependentWarExcludes> </configuration> </plugin> </plugins> </build> </project>
src/main/resources/ehcache.xml
-----------------------------------
<?xml version="1.0" encoding="UTF-8"?> <ehcache> <!--如果缓存中的对象存储超过指定的缓存数量的对象存储的磁盘地址 --> <diskStore path="D:/ehcache" /> <!-- 默认cache:如果没有对应的特定区域的缓存,就使用默认缓存 --> <defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="false" /> <!-- 指定区域cache:通过name指定,name对应到Hibernate中的区域名即可 --> <cache name="cn.javass.h3test.model.UserModel" eternal="false" maxElementsInMemory="100" timeToIdleSeconds="1200" timeToLiveSeconds="1200" overflowToDisk="false"> </cache> </ehcache>
src/main/resources/jdbc.properties
-----------------------------------
jdbc.driver=net.sf.log4jdbc.DriverSpy
jdbc.url=jdbc:log4jdbc:mysql://localhost:3306/jbpmtest?createDatabaseIfNotExist=true
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://localhost:3306/jbpmtest?createDatabaseIfNotExist=true
jdbc.username=root
jdbc.password=root
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
src/main/resources/log4j.properties
-----------------------------------
#log4j.rootLogger=info, stdout, logfile
log4j.rootLogger=info, stdout, HUB
# log4jdbc
log4j.logger.jdbc.sqlonly=INFO
log4j.logger.jdbc.sqltiming=INFO
log4j.logger.jdbc.audit=OFF
log4j.logger.jdbc.resultset=OFF
log4j.logger.jdbc.connection=OFF
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yy-MM-dd HH:mm} %5p %c{1}:%L - %m%n
#log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.logfile.File=c:/deimos.log
#log4j.appender.logfile.DatePattern='.'yyyy-MM-dd
#log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
#log4j.appender.logfile.layout.ConversionPattern=%d{yy-MM-dd HH:mm} %5p %c{1}:%L - %m%n
log4j.logger.com.mosso=debug
log4j.logger.org.springframework.batch=DEBUG
log4j.logger.org.springframework.transaction=INFO
log4j.logger.org.springframework=error
log4j.category.org.springframework.beans.factory=DEBUG
log4j.appender.HUB=org.apache.log4j.net.SocketHubAppender
log4j.appender.HUB.layout=org.apache.log4j.PatternLayout
log4j.appender.HUB.layout.ConversionPattern=[cc]%d{MMM-dd HH:mm:ss} %-14.14c{1}- %m%n
log4j.appender.HUB.port=4445
src/main/resources/META-INF/JBPMorm.xml(没使用到)
-----------------------------------
<?xml version="1.0" encoding="UTF-8"?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd" version="1.0"> <named-query name="ProcessInstancesWaitingForEvent"> <query> select processInstanceInfo.processInstanceId from ProcessInstanceInfo processInstanceInfo join processInstanceInfo.eventTypes eventTypes where eventTypes = :type </query> </named-query> </entity-mappings>
src/main/resources/META-INF/Taskorm.xml
-----------------------------------
<?xml version="1.0" encoding="UTF-8"?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd" version="1.0"> <named-query name="TasksAssignedAsBusinessAdministrator"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity businessAdministrator where t.archived = 0 and businessAdministrator.id = :userId and businessAdministrator in elements ( t.peopleAssignments.businessAdministrators ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsExcludedOwner"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity excludedOwners where t.archived = 0 and excludedOwners.id = :userId and excludedOwners in elements ( t.peopleAssignments.excludedOwners ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsPotentialOwner"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where t.archived = 0 and potentialOwners.id = :userId and potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in ('Created', 'Ready', 'Reserved', 'InProgress', 'Suspended') and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsPotentialOwnerByStatus"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where t.archived = 0 and potentialOwners.id = :userId and potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in (:status) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsPotentialOwnerWithGroups"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where t.archived = 0 and ( potentialOwners.id = :userId or potentialOwners.id in (:groupIds) ) and potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in ('Created', 'Ready', 'Reserved', 'InProgress', 'Suspended') and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsPotentialOwnerByStatusWithGroups"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where t.archived = 0 and ( potentialOwners.id = :userId or potentialOwners.id in (:groupIds) ) and potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in (:status) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsPotentialOwnerByGroup"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where t.archived = 0 and potentialOwners.id = :groupId and potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in ('Created', 'Ready', 'Reserved', 'InProgress', 'Suspended') and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="SubTasksAssignedAsPotentialOwner"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where t.archived = 0 and t.taskData.parentId = :parentId and (potentialOwners.id = :userId or potentialOwners.id in (:groupIds)) and potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in ('Created', 'Ready', 'Reserved', 'InProgress', 'Suspended') and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="GetSubTasksByParentTaskId"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.archived = 0 and t.taskData.parentId = :parentId and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in ('Created', 'Ready', 'Reserved', 'InProgress', 'Suspended') and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsRecipient"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity recipients where t.archived = 0 and recipients.id = :userId and recipients in elements ( t.peopleAssignments.recipients ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsTaskInitiator"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity taskInitiator where t.archived = 0 and taskInitiator.id = :userId and taskInitiator = t.peopleAssignments.taskInitiator and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsTaskStakeholder"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity taskStakeholder where t.archived = 0 and taskStakeholder.id = :userId and taskStakeholder in elements ( t.peopleAssignments.taskStakeholders ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksOwned"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.archived = 0 and t.taskData.actualOwner.id = :userId and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksByStatus"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.archived = 0 and t.taskData.status = :status and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksByStatusByProcessId"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.actualOwner as actualOwner left join t.taskData.createdBy as createdBy left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.archived = 0 and t.taskData.processInstanceId = :processInstanceId and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in (:status) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksByStatusByProcessIdByTaskName"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.actualOwner as actualOwner left join t.taskData.createdBy as createdBy left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.archived = 0 and t.taskData.processInstanceId = :processInstanceId and name.shortText = :taskName and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in (:status) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksByStatusSince"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.archived = 0 and t.taskData.status = :status and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null and t.taskData.activationTime < :since </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="ArchivedTasks"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.archived = 1 and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksOwnedWithParticularStatus"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.taskData.actualOwner.id = :userId and t.taskData.status in (:status) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="UnescalatedDeadlines"> <query> select new org.jbpm.task.query.DeadlineSummary( t.id, d.id, d.date) from Task t, Deadline d where t.archived = 0 and (d in elements( t.deadlines.startDeadlines ) or d in elements( t.deadlines.endDeadlines ) ) and d.escalated = 0 order by d.date </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TaskByWorkItemId"> <query> select t from Task t where t.archived = 0 and t.taskData.workItemId = :workItemId </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> </entity-mappings>
src/main/resources/META-INF/persistence.xml
-----------------------------------
<?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="org.jbpm.persistence.local" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <!-- <non-jta-data-source>jdbc/jbpm-ds</non-jta-data-source> --> <!-- Use this if you are using JPA1 / Hibernate3 --> <!-- <mapping-file>META-INF/JBPMorm.xml</mapping-file> --> <!-- <mapping-file>META-INF/Taskorm.xml</mapping-file> --> <!-- Use this if you are using JPA2 / Hibernate4 --> <mapping-file>META-INF/JBPMorm-JPA2.xml</mapping-file> <mapping-file>META-INF/ProcessInstanceInfo.hbm.xml</mapping-file> <mapping-file>META-INF/Taskorm.xml</mapping-file> <class>org.jbpm.task.Attachment</class> <class>org.jbpm.task.Content</class> <class>org.jbpm.task.BooleanExpression</class> <class>org.jbpm.task.Comment</class> <class>org.jbpm.task.Deadline</class> <class>org.jbpm.task.Comment</class> <class>org.jbpm.task.Deadline</class> <class>org.jbpm.task.Delegation</class> <class>org.jbpm.task.Escalation</class> <class>org.jbpm.task.Group</class> <class>org.jbpm.task.I18NText</class> <class>org.jbpm.task.Notification</class> <class>org.jbpm.task.EmailNotification</class> <class>org.jbpm.task.EmailNotificationHeader</class> <class>org.jbpm.task.PeopleAssignments</class> <class>org.jbpm.task.Reassignment</class> <class>org.jbpm.task.Status</class> <class>org.jbpm.task.Task</class> <class>org.jbpm.task.TaskData</class> <class>org.jbpm.task.SubTasksStrategy</class> <class>org.jbpm.task.OnParentAbortAllSubTasksEndStrategy</class> <class>org.jbpm.task.OnAllSubTasksEndParentEndStrategy</class> <class>org.jbpm.task.User</class> <class>org.drools.persistence.info.SessionInfo</class> <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class> <class>org.drools.persistence.info.WorkItemInfo</class> <class>org.jbpm.process.audit.ProcessInstanceLog</class> <class>org.jbpm.process.audit.NodeInstanceLog</class> <class>org.jbpm.process.audit.VariableInstanceLog</class> <properties> <property name="hibernate.max_fetch_depth" value="3" /> <property name="hibernate.hbm2ddl.auto" value="update" /> <property name="hibernate.show_sql" value="false" /> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /> <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.EhCacheRegionFactory"/> <property name="hibernate.cache.use_query_cache" value="true"/> <property name="hibernate.cache.use_second_level_cache" value="true"/> <property name="hibernate.generate_statistics" value="true"/> <property name="hibernate.use_sql_comments" value="true"/> <property name="hibernate.generate_statistics" value="true"/> </properties> </persistence-unit> </persistence>
src/main/java/com/gds/jbpm/JBPMUserGroupCallback.java
-----------------------------------
package com.gds.jbpm; import java.util.ArrayList; import java.util.List; import org.jbpm.task.identity.UserGroupCallback; public class JBPMUserGroupCallback implements UserGroupCallback { @Override public boolean existsGroup(String groupId) { return true; } @Override public boolean existsUser(String userId) { return true; } @Override public List<String> getGroupsForUser(String userId, List<String> groupIds, List<String> allExistingGroupIds) { if (groupIds != null) { List<String> retList = new ArrayList<String>(groupIds); // merge all groups if (allExistingGroupIds != null) { for (String grp : allExistingGroupIds) { if (!retList.contains(grp)) { retList.add(grp); } } } return retList; } else { // // return empty list by default // please note: there are different return value for different // version of jPBM // List<String> retList = new ArrayList<String>(); // retList.add("user"); // return retList; // return new ArrayList<String>(); //for jBPM5.3.0.Final return null; // for jBPM5.4.0.CR1 } } }
src/main/java/com/gds/jbpm/MyLocalTaskService.java
-----------------------------------
package com.gds.jbpm; import javax.annotation.PostConstruct; import org.drools.runtime.StatefulKnowledgeSession; import org.jbpm.task.service.local.LocalTaskService; /** * 提供这个类,是为了设定jbpm.usergroup.callback, * 但是如何注解呢? * @author pandy * */ public class MyLocalTaskService { private StatefulKnowledgeSession ksession; private LocalTaskService localTaskService; @PostConstruct public void init() { // set user group callback System.setProperty("jbpm.usergroup.callback", "com.gds.jbpm.JBPMUserGroupCallback"); } public StatefulKnowledgeSession getKsession() { return ksession; } public void setKsession(StatefulKnowledgeSession ksession) { this.ksession = ksession; } public org.jbpm.task.service.local.LocalTaskService getLocalTaskService() { return localTaskService; } public void setLocalTaskService( org.jbpm.task.service.local.LocalTaskService localTaskService) { this.localTaskService = localTaskService; } }
src/main/java/com/gds/web/OrderController.java
-----------------------------------
package com.gds.web; import static org.springframework.web.bind.annotation.RequestMethod.GET; import static org.springframework.web.bind.annotation.RequestMethod.POST; import static org.springframework.web.bind.annotation.RequestMethod.PUT; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.annotation.Resource; import org.apache.log4j.Logger; import org.drools.command.Context; import org.drools.command.impl.GenericCommand; import org.drools.command.impl.KnowledgeCommandContext; import org.drools.runtime.StatefulKnowledgeSession; import org.drools.runtime.process.WorkflowProcessInstance; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.process.instance.context.variable.VariableScopeInstance; import org.jbpm.process.workitem.wsht.LocalHTWorkItemHandler; import org.jbpm.task.Task; import org.jbpm.task.TaskData; import org.jbpm.task.TaskService; import org.jbpm.task.query.TaskSummary; import org.jbpm.task.service.ContentData; import org.jbpm.task.utils.ContentMarshallerHelper; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import com.gds.jbpm.MyLocalTaskService; import com.gds.jbpm.Order; @Controller public class OrderController { private Logger log = Logger.getLogger(this.getClass()); @Resource @Qualifier("myLocalTaskService") private MyLocalTaskService myLocalTaskService; @Resource @Qualifier("ksession") private StatefulKnowledgeSession ksession; @RequestMapping("/") public String test() { log.info("this is the index"); return "index"; } @RequestMapping(value = "{user}/create", method = GET) public String create(@PathVariable("user") String user) { // log.info(user + " prepare to create"); System.out.println("用户[" + user + "]进入创建界面,准备创建流程。"); return "create"; } @RequestMapping(value = "{user}/create", method = { POST, PUT }) public String doCreate(@PathVariable("user") String user, Model model) { // log.info(user + " create an order"); System.out.println("用户[" + user + "]提交了流程单据"); ksession = myLocalTaskService.getKsession(); LocalHTWorkItemHandler humanTaskHandler = new LocalHTWorkItemHandler( myLocalTaskService.getLocalTaskService(), ksession); humanTaskHandler.setLocal(true); humanTaskHandler.connect(); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanTaskHandler); Map<String, Object> params = new HashMap<String, Object>(); params.put("priority", "High"); params.put("modelNumber", "179"); params.put("quantity", "100"); System.out.println("用户[" + user + "]赋初始值,并准备启动流程......."); ksession.startProcess("com.gds.jbpm.sample", params); ksession.fireAllRules(); System.out.println("用户[" + user + "]创建流程,等待处理......"); model.addAttribute("message", "process created!"); System.out .println("---------------------------------------------------单据提交完成:" + user); return "create"; } @RequestMapping("{user}/list") public String list(@PathVariable("user") String user, Model model) { // log.info(user + " list his tasks"); System.out.println("用户[" + user + "]读取任务列表."); TaskService taskService = myLocalTaskService.getLocalTaskService(); List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner( user, "en-UK"); log.info("\n***Task size::" + tasks.size() + "***\n"); for (TaskSummary taskSummary : tasks) { log.info(taskSummary.getId() + " :: " + taskSummary.getActualOwner()); } model.addAttribute("tasks", tasks); model.addAttribute("tasksCount", tasks.size()); model.addAttribute("user", user); System.out .println("---------------------------------------------------列表读取完成:" + user); return "list"; } @RequestMapping(value = "{user}/work/{task}", method = GET) public String work(@PathVariable("user") String user, @PathVariable("task") long taskId, Model model) { // log.info(user + " prepare to work on task " + taskId); System.out.println("用户[" + user + "]读取任务以便处理,任务ID=" + taskId); StatefulKnowledgeSession ksession = myLocalTaskService.getKsession(); TaskService taskService = myLocalTaskService.getLocalTaskService(); Task task = taskService.getTask(taskId); TaskData taskData = task.getTaskData(); WorkflowProcessInstance process = (WorkflowProcessInstance) ksession .getProcessInstance(taskData.getProcessInstanceId()); model.addAttribute("taskData", taskData); model.addAttribute("order", new Order(user, taskId, process)); System.out .println("---------------------------------------------------任务读取完成:" + user); return "work"; } @RequestMapping(value = "{user}/work/{task}", method = { POST, PUT }) public String doWork(@ModelAttribute Order order) { System.out.println("处理任务信息:" + order.toString()); String user = order.getUser(); long taskId = order.getTaskId(); log.info(user + " complete work on task " + taskId); TaskService taskService = myLocalTaskService.getLocalTaskService(); System.out.println("用户[" + user + "]启动人工任务, taskId=" + taskId); taskService.start(taskId, user); Map<String, Object> data = new HashMap<String, Object>(); data.put("priority", order.getPriority()); data.put("modelNumber", order.getModelNumber()); data.put("quantity", order.getQuantity()); // setProcessVariables(taskId, data); ContentData contentData = null; if (data != null) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream outs; try { outs = new ObjectOutputStream(bos); outs.writeObject(data); outs.close(); contentData = new ContentData(); //contentData.setContent(bos.toByteArray()); //contentData.setAccessType(AccessType.Inline); contentData = ContentMarshallerHelper.marshal(data, null); //contentData.setAccessType(AccessType.Inline); } catch (IOException e) { e.printStackTrace(); } } System.out.println("参数:"+data.toString()); //taskService.complete(taskId, user, contentData); taskService.completeWithResults(taskId, user, data); // ksession.fireAllRules(); // ksession.getWorkItemManager().completeWorkItem(taskService.getTask(taskId).getTaskData().getWorkItemId(), // data); System.out.println("用户[" + user + "]完成人工任务"); System.out .println("---------------------------------------------------处理任务完成:" + user); return "redirect:/" + user + "/list"; } public void setProcessVariables(final long intProcessInstId, final Map<String, Object> hshVariableMap) { try { ksession.execute(new GenericCommand<Map<String, Object>>() { public Map<String, Object> execute(Context objContext) { StatefulKnowledgeSession objKSession = ((KnowledgeCommandContext) objContext) .getStatefulKnowledgesession(); org.jbpm.process.instance.ProcessInstance objProcessInstance = (org.jbpm.process.instance.ProcessInstance) objKSession .getProcessInstance(intProcessInstId); VariableScopeInstance objVariableScope = (VariableScopeInstance) objProcessInstance .getContextInstance(VariableScope.VARIABLE_SCOPE); Iterator<Map.Entry<String, Object>> objIterator = hshVariableMap .entrySet().iterator(); while (objIterator.hasNext()) { Map.Entry<String, Object> objPairs = (Map.Entry<String, Object>) objIterator .next(); objVariableScope.setVariable(objPairs.getKey(), objPairs.getValue()); } return null; } }); } catch (Exception e) { e.printStackTrace(); } } }
src/main/resources/applicationContext.xml
-----------------------------------
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xmlns:drools="http://drools.org/schema/drools-spring" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://drools.org/schema/drools-spring http://drools.org/schema/drools-spring-1.3.0.xsd"> <context:component-scan base-package="com"> <context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation" /> </context:component-scan> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <value>classpath:jdbc.properties</value> </property> </bean> <!-- Spring + Hibernate --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${jdbc.driver}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" p:packagesToScan="com.pandy.ssh4.domian"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> ${hibernate.dialect} </prop> <prop key="hibernate.show_sql">false</prop> <prop key="hibernate.format_sql">false</prop> <prop key="hibernate.cache.use_query_cache">true</prop> <prop key="hibernate.cache.use_second_level_cache">true</prop> <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory </prop> <prop key="hibernate.cache.use_structured_entries">true</prop> <prop key="hibernate.generate_statistics">true</prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" /> <!-- JBPM 5.4 --> <bean id="xDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://127.0.0.1:3306/jbpmtest?characterEncoding=UTF-8" /> <property name="username" value="root" /> <property name="password" value="root" /> </bean> <bean id="jbpmEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="xDataSource" /> <property name="persistenceUnitName" value="org.jbpm.persistence.local" /> </bean> <bean id="jbpmTxManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="jbpmEntityManagerFactory" /> <!-- 这里要是为false的话,提交事物的时候,容易报错 --> <property name="nestedTransactionAllowed" value="true" /> </bean> <drools:grid-node id="node1" /> <drools:kstore id="kstore1" /> <drools:kbase id="kbase" node="node1"> <drools:resources> <drools:resource type="BPMN2" source="classpath:Sample.bpmn" /> </drools:resources> </drools:kbase> <drools:ksession id="ksession" type="stateful" kbase="kbase" node="node1"> <drools:configuration> <drools:jpa-persistence> <drools:transaction-manager ref="jbpmTxManager" /> <drools:entity-manager-factory ref="jbpmEntityManagerFactory" /> </drools:jpa-persistence> </drools:configuration> </drools:ksession> <bean id="systemEventListener" class="org.drools.SystemEventListenerFactory" factory-method="getSystemEventListener" /> <bean id="internalTaskService" class="org.jbpm.task.service.TaskService"> <property name="systemEventListener" ref="systemEventListener" /> </bean> <bean id="htTxManager" class="org.drools.container.spring.beans.persistence.HumanTaskSpringTransactionManager"> <constructor-arg ref="jbpmTxManager" /> </bean> <bean id="springTaskSessionFactory" class="org.jbpm.task.service.persistence.TaskSessionSpringFactoryImpl" init-method="initialize" depends-on="internalTaskService"> <property name="entityManagerFactory" ref="jbpmEntityManagerFactory" /> <property name="transactionManager" ref="htTxManager" /> <property name="useJTA" value="true" /> <property name="taskService" ref="internalTaskService" /> </bean> <bean id="taskService" class="org.jbpm.task.service.local.LocalTaskService" depends-on="internalTaskService"> <constructor-arg ref="internalTaskService" /> </bean> <bean id="myLocalTaskService" class="com.gds.jbpm.MyLocalTaskService"> <property name="ksession" ref="ksession" /> <property name="localTaskService" ref="taskService" /> </bean> </beans>
- JBPM54sh.zip (239.3 KB)
- 下载次数: 652
评论
11 楼
lijiangt
2014-04-05
localTaskService 是单例,多线程会有问题吧?
10 楼
pyzheng
2013-09-24
kinorsi 写道
这个jbpm确实很蛋疼。。。官网的资料都写的有点乱。。。
各种搞不清楚:
........................
各种搞不清楚:
........................
先不说jbpm和activiti以后的发展谁更好,但很难否定,这个阶段activit比较成熟,毕竟activiti是沿着jbpm的前身前进, jbpm5变成一个全新的东西,抛弃了所有以前的东西,转而全新开始,稳定性还没足够好把。
9 楼
kinorsi
2013-09-24
这个jbpm确实很蛋疼。。。官网的资料都写的有点乱。。。
各种搞不清楚:
1.集成spring之后,session的dispose问题:基本上是不会去dispose的.然后数据库也会产生很我的session,每一次启动jbpm就会新生一个。
2.手动实现 usergroupcallback的问题,那几个接口在使用的时候会很迷惑。
3.eclipse的bmpn插件产生的bpmn图有各种情况:1)老是说没有taskname,2)图里的schema可能不正确。3)中文乱码的问题。
4.installer产生的jboss环境运行起来那一个慢。。。
。。。总之好难用。。。
感觉也是activiti比较容易集成和使用。
各种搞不清楚:
1.集成spring之后,session的dispose问题:基本上是不会去dispose的.然后数据库也会产生很我的session,每一次启动jbpm就会新生一个。
2.手动实现 usergroupcallback的问题,那几个接口在使用的时候会很迷惑。
3.eclipse的bmpn插件产生的bpmn图有各种情况:1)老是说没有taskname,2)图里的schema可能不正确。3)中文乱码的问题。
4.installer产生的jboss环境运行起来那一个慢。。。
。。。总之好难用。。。
感觉也是activiti比较容易集成和使用。
8 楼
kinorsi
2013-09-23
楼主,我运行起来你的项目了。然后就是当mysql的wait_timeout到了之后,就会出问题。能不能帮忙整改一下~
7 楼
pyzheng
2013-09-23
我现在已经不用这东西了 感觉jbpm太麻烦 官方的一个demo就如此麻烦的 包能否找到 先不说,先说它在整合上一点严谨性都没有。不久工作流么,非要依赖按么多东西干嘛?
如果找不到包的就留言,把包名写上来,我会上传给大家。csdn很多人说找不到包,我也忘记那些包找不到了,所以留言后我会上传。
现在转去用activiti了。我先不管activiti和jbpm哪个好,但是activiti足够我用了,而且很容易整合,也比较稳定,jbpm5之后,估计还要很久,才能稳定下来,想用的要考虑清楚哦......
jbpm以前的设计者离开后,继续他的思想,出了activiti5.找一下就能找到这些文章
如果找不到包的就留言,把包名写上来,我会上传给大家。csdn很多人说找不到包,我也忘记那些包找不到了,所以留言后我会上传。
现在转去用activiti了。我先不管activiti和jbpm哪个好,但是activiti足够我用了,而且很容易整合,也比较稳定,jbpm5之后,估计还要很久,才能稳定下来,想用的要考虑清楚哦......
jbpm以前的设计者离开后,继续他的思想,出了activiti5.找一下就能找到这些文章
6 楼
kinorsi
2013-09-22
楼主在不?我自己也搭建过环境。用的是spring data jpa + hibernate + mysql.出现的最大问题是jbpm的连接当超过mysql的wait_timeout时,就会报错。即使我用c3p0配置了常用来处理wait_timeout的连接池,这个问题仍然没有好转。想想看看楼主有没有时间,想和你讨论下。如果楼主方便加我QQ或者微信:172440249
5 楼
pyzheng
2013-07-01
tanpujing 写道
哥,
能把Spring3.1 + Hibernate4.2.1 + JBPM5.4 + Ehache整合例子的数据库建表脚本和记录发我参考一下吗,
我的邮箱是tanpujing@gmail.com
拜谢
能把Spring3.1 + Hibernate4.2.1 + JBPM5.4 + Ehache整合例子的数据库建表脚本和记录发我参考一下吗,
我的邮箱是tanpujing@gmail.com
拜谢
附件有源码 可以试试
4 楼
tanpujing
2013-06-30
哥,
能把Spring3.1 + Hibernate4.2.1 + JBPM5.4 + Ehache整合例子的数据库建表脚本和记录发我参考一下吗,
我的邮箱是tanpujing@gmail.com
拜谢
能把Spring3.1 + Hibernate4.2.1 + JBPM5.4 + Ehache整合例子的数据库建表脚本和记录发我参考一下吗,
我的邮箱是tanpujing@gmail.com
拜谢
3 楼
pyzheng
2013-06-09
如何控制流程流转的角色权限
--------
这个我还没做 现在只是选型阶段 这个例子只是测试能否把5.4版本的运行起来。以后才去学这些东西 现在没办法告诉你哦
至于包的问题 还是让maven来帮你找吧 否则自己手动找包 太浪费时间了 还不一定能找到
我的pom.xml就已经说明用到哪些包了。
--------
这个我还没做 现在只是选型阶段 这个例子只是测试能否把5.4版本的运行起来。以后才去学这些东西 现在没办法告诉你哦
至于包的问题 还是让maven来帮你找吧 否则自己手动找包 太浪费时间了 还不一定能找到
我的pom.xml就已经说明用到哪些包了。
2 楼
chenzhm3
2013-06-09
您好,我也是刚开始学习jbpm.下载的也是5.4版的,我想把到集成到spring3中去,要导入哪些包呀?还有就是如何控制流程流转的角色权限,谢谢。
1 楼
Franciswmf
2013-06-07
先赞一个
发表评论
-
Spring Boot 属性配置
2016-06-24 11:04 1181Spring Boot 属性配置和使用 http://blog ... -
Spring Boot 集成MyBatis
2016-06-24 10:55 2025Spring Boot 集成MyBatis http://bl ... -
Spring MVC防重复提交
2016-06-17 15:47 1644http://my.oschina.net/zyqjustin ... -
Spring容器加载完之后执行特定任务
2016-06-17 15:36 2282http://my.oschina.net/simpleton ... -
使用spring-session和shiro来代理session的配置
2016-06-16 11:21 12056使用spring-session和redis来代理sessio ... -
JSTL 的 if else : 有 c:if 没有 else 的处理
2016-06-14 09:52 1333http://blog.csdn.net/xiyuan1999 ... -
spring mvc 请求转发和重定向
2016-06-14 09:48 1397http://blog.csdn.net/jackpk/art ... -
mvc:view-controller
2016-05-18 10:26 1081http://blog.csdn.net/lzwglory/a ... -
spring配置事物的方式:注解和aop配置
2016-05-14 00:26 4101参考: Spring AOP中pointcut express ... -
分布式任务调度组件 Uncode-Schedule
2016-05-13 14:47 2286http://www.oschina.net/p/uncode ... -
Mybatis分库分表扩展插件
2016-05-12 15:47 1620http://fangjialong.iteye.com/bl ... -
spring+mybatis+atomikos 实现JTA事务
2016-05-11 22:00 5522sping配置多个数据源 不同用户操作不同数据库 http:/ ... -
Spring中使用注解 @Scheduled执行定时任务
2016-05-10 09:39 1566原文:http://dwf07223.blog.51cto.c ... -
Spring中配置Websocket
2016-05-05 16:55 1276spring+websocket整合(springMVC+sp ... -
redis 集群中Session解决方案之Spring Session
2016-05-04 08:54 1314集群中Session解决方案之Spring Session h ... -
使用Spring-data进行Redis操作
2016-05-04 08:54 4791使用Spring-data进行Redis操作 http://z ... -
Spring4新特性——集成Bean Validation 1.1(JSR-349)到SpringMVC
2016-05-03 13:35 1060Spring4新特性——集成Bean Validation 1 ... -
SpringMVC介绍之Validation
2016-05-03 13:10 983SpringMVC介绍之Validation http://h ... -
spring 注解方式下使用commons-validator 验证表单
2016-05-03 11:08 3075原文: http://www.programgo.com/ar ... -
Spring MVC学习详解
2016-04-28 09:13 1003原文 http://blog.csdn.net/alsocod ...
相关推荐
Struts 2.3.24.1、Spring 4.2.1 和 Hibernate 5.0 是三个在 Java 开发领域中广泛使用的开源框架,它们分别负责 Web 应用的 MVC(Model-View-Controller)架构、依赖注入与服务管理以及对象关系映射(ORM)。...
12.6 整合Struts、Spring和Hibernate实现用户管理 12.6.1 Struts、Spring和Hibernate的整合方式 12.6.2 编写用户注册画面regedit.jsp 12.6.3 编写用户登录画面login.jsp 12.6.4 编写注册控制器RegeditAction.java ...
12.6 整合Struts、Spring和Hibernate实现用户管理 12.6.1 Struts、Spring和Hibernate的整合方式 12.6.2 编写用户注册画面regedit.jsp 12.6.3 编写用户登录画面login.jsp 12.6.4 编写注册控制器RegeditAction.java ...
GIF+动画制作软件-GIF+Movie+Gear+V4.2.1汉化绿色特别版
7. **事务管理**:Hibernate支持编程式和声明式事务管理,可以结合Spring等框架进行更高级的事务控制。 8. **延迟加载**:Hibernate的懒加载(Lazy Loading)机制可以按需加载关联对象,提高性能。 9. **事件监听*...
资源名字:基于JSP+Spring+Hibernate+Struts+mysql的家庭理财收支系统设计与实现(源码+文档).zip 资源内容:项目全套源码+完整文档 源码说明: 全部项目源码都是经过测试校正后百分百成功运行。 包含模块: 4.1 ...
资源名字:基于JSP+Spring+Hibernate+Struts+mysql的机票订购系统设计与实现(源码+文档).zip 资源内容:项目全套源码+完整文档 源码说明: 全部项目源码都是经过测试校正后百分百成功运行。 包含模块: 4.1前台...
资源名字:基于JSP+Spring+Hibernate+Struts+mysql的网上在线客车售票系统设计与实现(源码+文档).zip 资源内容:项目全套源码+完整文档 源码说明: 全部项目源码都是经过测试校正后百分百成功运行。 包含模块: ...
资源名字:基于JSP+Spring+Hibernate+Struts2+mysql的校园二手交易系统设计与实现(源码+文档).zip 资源内容:项目全套源码+完整文档 源码说明: 全部项目源码都是经过测试校正后百分百成功运行。 包含模块: 4.1 ...
标题中的"Router+Tools+V4.2.1_ddwrt_router_"暗示了这是一个与路由器相关的软件工具包,特别地,是DD-WRT固件的一个版本。DD-WRT是一款流行的开源路由器固件,它提供了比许多出厂固件更丰富的功能和自定义选项,...
spring-framework-4.2.1jar包完整版,spring-framework-4.2.1jar包完整版,spring-framework-4.2.1jar包完整版,spring-framework-4.2.1jar包完整版,spring-framework-4.2.1jar包完整版,spring-framework-4.2.1jar...
本文将围绕"Hibernate4.2.1完整jar包",深入探讨其核心组件、C3P0连接池的整合以及MySQL数据库的连接配置。 1. Hibernate4.2.1核心组件: Hibernate4.2.1的核心组件包括SessionFactory、Session、Query等。...
12.6 整合Struts、Spring和Hibernate实现用户管理 12.6.1 Struts、Spring和Hibernate的整合方式 12.6.2 编写用户注册画面regedit.jsp 12.6.3 编写用户登录画面login.jsp 12.6.4 编写注册控制器RegeditAction.java ...
苹果狮子(BT)+xcode4.2.1(官方)下载地址主要涉及到的是苹果公司的操作系统OS X Lion(10.7版本)以及Xcode 4.2.1开发工具的相关内容。这两个软件对于Mac用户,尤其是苹果开发者来说,是至关重要的。 首先,OS X ...
"【WordPress主题】2022年最新版完整功能demo+插件4.2.1 ClassiPress - The bestselling classifieds theme for WordPress Classipress - WordPress的Bestselling分类主题" ---------- 泰森云每天更新发布最新...
《Hibernate 4.2.1:企业级持久化框架的深度解析》 Hibernate,作为Java领域最著名的对象关系映射(ORM)框架之一,一直以来都是开发者们的重要工具。本文将聚焦于Hibernate 4.2.1版本,深入探讨其特性、安装与配置...
hibernate4.2.1final英文版技术文档
FFmpeg 4.2.1 Windows 开发环境搭建与 QT 集成 FFmpeg 是一个免费、开源的多媒体处理工具,可以进行视频和音频的编解码、转换、流媒体处理等操作。为了在 Windows 平台上搭建 FFmpeg 4.2.1 开发环境,并集成到 QT ...