public class TestActivitiFlow {
/**
* @param args
*/
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext(
"classpath:activiti/activiti-context.xml");
// ProcessEngine processEngine = (ProcessEngine) context.getBean("processEngine");
BizActiviti bizActiviti = (BizActiviti) context.getBean("bizActiviti");
ProcessEngine processEngine = bizActiviti.getProcessEngine();
RuntimeService runtimeService;
RepositoryService repositoryService;
TaskService taskService;
repositoryService = processEngine.getRepositoryService();
runtimeService = processEngine.getRuntimeService();
taskService = processEngine.getTaskService();
repositoryService.createDeployment().addClasspathResource("activiti/createcase-context.bpmn20.xml").deploy();
String proId = runtimeService.startProcessInstanceByKey("createcasebyactiviti").getId();
System.out.println("process id: " + proId);
List<Task> tasks = null;
tasks = taskService.createTaskQuery().taskCandidateGroup("io").list();
for (Task task : tasks) {
System.out.println("Following task is available for io group: " + task.getName());
taskService.claim(task.getId(), "io");
// taskService.setAssignee(task.getId(), "hiss");
}
// Verify hiss can now retrieve the task
tasks = taskService.createTaskQuery().taskAssignee("io").list();
for (Task task : tasks) {
System.out.println("Task for io: " + task.getName());
taskService.complete(task.getId());
System.out.println("now status is: " + task.getDescription());
// System.out.println(runtimeService.getVariables("nextstatus"));
}
tasks = taskService.createTaskQuery().taskCandidateGroup("hiss").list();
for (Task task : tasks) {
System.out.println("Following task is available for hiss group: " + task.getName());
taskService.claim(task.getId(), "hiss");
}
tasks = taskService.createTaskQuery().taskAssignee("hiss").list();
for (Task task : tasks) {
System.out.println("Task for hiss: " + task.getName());
taskService.complete(task.getId());
System.out.println("now status is: " + task.getDescription());
}
tasks = taskService.createTaskQuery().taskCandidateGroup("hunit").list();
for (Task task : tasks) {
System.out.println("Following task is available for hunit group: " + task.getName());
taskService.claim(task.getId(), "hunit");
}
tasks = taskService.createTaskQuery().taskAssignee("hunit").list();
for (Task task : tasks) {
System.out.println("Task for hunit: " + task.getName());
taskService.complete(task.getId());
System.out.println("now status is: " + task.getDescription());
}
HistoryService historyService = processEngine.getHistoryService();
HistoricProcessInstance historicProcessInstance =
historyService.createHistoricProcessInstanceQuery().processInstanceId(proId).singleResult();
System.out.println("Process instance end time: " + historicProcessInstance.getEndTime());
}
custom-persistence.xml
<persistence 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"
version="1.0"
>
<persistence-unit name="activiti-jpa-pu">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<class>org.activiti.spring.test.jpa.LoanRequest</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"/>
<property name="openjpa.LockTimeout " value="30000"/>
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(SchemaAction='add,deleteTableContents')"/>
</properties>
</persistence-unit>
</persistence>
activiti-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
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
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<property name="driverClass" value="oracle.jdbc.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@//***" />
<property name="username" value="***" />
<property name="password" value="***" />
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="persistenceXmlLocation">
<value>classpath:activiti/custom-persistence.xml</value>
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter">
<property name="databasePlatform" value="org.apache.openjpa.jdbc.sql.OracleDictionary" />
</bean>
</property>
</bean>
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="jpaEntityManagerFactory" ref="entityManagerFactory" />
<property name="databaseSchemaUpdate" value="true" />
<property name="mailServerHost" value="192.168***" />
<property name="mailServerPort" value="**" />
<property name="jpaHandleTransaction" value="true" />
<property name="jpaCloseEntityManager" value="true" />
<property name="jobExecutorActivate" value="false" />
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
<bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
<bean id="userBean" class="com.ncs.UserBean"/>
<bean id="bizActiviti" class="com.ncs.BizActiviti">
<property name="processEngine" ref="processEngine"/>
<property name="userBean" ref="userBean"/>
</bean>
</beans>
createcase-context.bpmn20.xml
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="test">
<process id="createcasebyactiviti">
<startEvent id="start" />
<sequenceFlow id="flow1" sourceRef="start" targetRef="createfirstinfo" />
<userTask id="createfirstinfo" name="create first information">
<documentation>1</documentation>
<potentialOwner>
<resourceAssignmentExpression>
<formalExpression>io</formalExpression>
</resourceAssignmentExpression>
</potentialOwner>
</userTask>
<sequenceFlow id="flow11" sourceRef="createfirstinfo" targetRef="egtask" />
<exclusiveGateway id="egtask" name="exclusive gateway task"/>
<sequenceFlow id="flow2" sourceRef="egtask" targetRef="verifyfirstinfo" >
<conditionExpression xsi:type="tFormalExpression">
${userBean.userId != ''}
</conditionExpression>
</sequenceFlow>
<userTask id="verifyfirstinfo" name="verify first information">
<documentation>3</documentation>
<potentialOwner>
<resourceAssignmentExpression>
<formalExpression>hiss</formalExpression>
</resourceAssignmentExpression>
</potentialOwner>
</userTask>
<sequenceFlow id="flow21" sourceRef="verifyfirstinfo" targetRef="end" />
<sequenceFlow id="flow3" sourceRef="egtask" targetRef="approvefirstinfo" >
<conditionExpression xsi:type="tFormalExpression">
${userBean.userId == ''}
</conditionExpression>
</sequenceFlow>
<userTask id="approvefirstinfo" name="approve first information, generate ip">
<documentation>5</documentation>
<potentialOwner>
<resourceAssignmentExpression>
<formalExpression>hunit</formalExpression>
</resourceAssignmentExpression>
</potentialOwner>
</userTask>
<sequenceFlow id="flow31" sourceRef="approvefirstinfo" targetRef="end" />
<endEvent id="end" />
</process>
</definitions>
分享到:
相关推荐
赠送jar包:activiti-engine-5.21.0.jar; 赠送原API文档:activiti-engine-5.21.0-javadoc.jar; 赠送源代码:activiti-engine-5.21.0-sources.jar; 赠送Maven依赖信息文件:activiti-engine-5.21.0.pom; 包含...
在Activiti中,连线(SequenceFlow)是流程图中的重要元素,用于定义活动之间的转移路径。本篇学习笔记将深入探讨SequenceFlow的概念、作用以及如何在流程设计中使用。 一、SequenceFlow简介 SequenceFlow 是 ...
适配了人大金仓和达梦
在本文中,我们将深入探讨Activiti Engine API 5.13版本的核心概念、功能以及如何利用它来实现高效的工作流管理。 首先,我们要了解什么是Activiti Engine API。它是Activiti框架的核心组件,提供了一系列接口和类...
activiti-engine-7.1.0.M1
activiti6.0.0 jar 添加对达梦数据库整合
《深入理解Activiti Engine 5.7:基于jar.zip包的探索》 Activiti Engine 5.7是一款功能强大的业务流程管理(BPM)引擎,它以Java编程语言为基础,为开发者提供了高度灵活且易于使用的工具,用于设计、执行和管理...
1. **Activiti Engine**: Activiti Engine 是 Activiti 的核心组件,负责执行流程定义,管理流程实例,以及处理与流程相关的各种任务。它提供了一个API,开发者可以通过这个API来启动流程实例,查询任务,完成任务等...
kingbase适配activiti重写jar包
赠送jar包:activiti-engine-5.21.0.jar; 赠送原API文档:activiti-engine-5.21.0-javadoc.jar; 赠送源代码:activiti-engine-5.21.0-sources.jar; 赠送Maven依赖信息文件:activiti-engine-5.21.0.pom; 包含...
activiti-engine-5.17.0.jar包缺失会引起The import org.activiti.engine.history.HistoricTaskInstance cannot be resolved
activiti-engine-5.16.4-sources.jar-小彭源码免费下载
activiti-engine-5.18.0-sources.jar
activiti-engine-5.9.jar
《Activiti Engine 5.4 源码分析与应用》 Activiti 是一个开源的工作流引擎,它基于模型驱动的架构(Model Driven Architecture, MDA),为业务流程自动化提供了一个强大的工具。该引擎的设计目标是易于使用、可...
对Activiti进行二次开发需要将Activiti/modules下的activiti-engine项目导入到开发工具中。在编辑这个文件时,需要增加两行代码,添加dm对应的sql文件。新的文件可以从Oracle对应文件拷贝过来,然后将全部的NVARCHAR...
3、已经对该流程引擎的activiti-engine-7.1.0.M3.1.jar进行了源码修改,下载直接使用即可,同时支持达梦数据库服务器多个数据库实例的场景,网上大多修改的方法只适合单个数据库实例(多个数据库实例下流程引擎的数据...
activiti-engine-5.21.0(神通).jar