/*
* Copyright 2007-2009 非也
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation。
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses.
*/
package org.fireflow.engine;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.fireflow.engine.persistence.IPersistenceService;
import org.fireflow.engine.taskinstance.CurrentUserAssignmentHandlerMock;
import org.fireflow.engine.test.support.FireFlowAbstractTests;
import org.fireflow.kernel.IToken;
import org.fireflow.kernel.KernelException;
import org.junit.Test;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallback;
/**
*
* @author 非也
* @version 1.0
* Created on Apr 11, 2009
*/
public class WithdrawAndRejectTest extends FireFlowAbstractTests {
//--------constant----------------------
//本流程用到
private final static Integer flag = 0;//"123123123123";
//-----variables-----------------
static IProcessInstance currentProcessInstance = null;
static String workItem1Id = null;
static String workItem2Id = null;
static String workItem3Id = null;
static String workItem4Id = null;
static String workItem5Id = null;
static String workItem6Id = null;
static String workItem7Id = null;
static String workItem8Id = null;
static String workItem9Id = null;
@Test
public void testStartProcessAndCompleteWorkItem1() {
currentProcessInstance = (IProcessInstance) transactionTemplate.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus arg0) {
try {
IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();
IProcessInstance processInstance = workflowSession.createProcessInstance("WithdrawAndReject","fireflowTester");
processInstance.run();
return processInstance;
} catch (EngineException ex) {
Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
} catch (KernelException ex) {
Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
});
assertNotNull(currentProcessInstance);
IPersistenceService persistenceService = runtimeContext.getPersistenceService();
List taskInstanceList = persistenceService.findTaskInstancesForProcessInstance(currentProcessInstance.getId(), "WithdrawAndReject.Activity1");
assertNotNull(taskInstanceList);
assertEquals(1, taskInstanceList.size());
assertEquals(new Integer(ITaskInstance.RUNNING), ((ITaskInstance) taskInstanceList.get(0)).getState());
assertEquals(1, ((ITaskInstance) taskInstanceList.get(0)).getStepNumber().intValue());
List tokenList = persistenceService.findTokensForProcessInstance(currentProcessInstance.getId(), null);
assertNotNull(tokenList);
assertEquals(1, tokenList.size());
IToken token = (IToken) tokenList.get(0);
assertEquals(1, token.getStepNumber().intValue());
List workItemList = persistenceService.findTodoWorkItems(CurrentUserAssignmentHandlerMock.ACTOR_ID, "WithdrawAndReject", "WithdrawAndReject.Activity1.Task1");
assertNotNull(workItemList);
assertEquals(1, workItemList.size());
assertEquals(new Integer(IWorkItem.INITIALIZED), ((IWorkItem) workItemList.get(0)).getState());
workItem1Id = ((IWorkItem) workItemList.get(0)).getId();
transactionTemplate.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus arg0) {
try {
IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();
IWorkItem workItem = workflowSession.findWorkItemById(workItem1Id);
workItem.claim();
workItem.complete();
} catch (EngineException ex) {
Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
} catch (KernelException ex) {
Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
});
workItemList = persistenceService.findTodoWorkItems(CurrentUserAssignmentHandlerMock.ACTOR_ID, "WithdrawAndReject", "WithdrawAndReject.Activity2.Task2");
assertNotNull(workItemList);
assertEquals(1, workItemList.size());
assertEquals(new Integer(IWorkItem.INITIALIZED), ((IWorkItem) workItemList.get(0)).getState());
workItem2Id = ((IWorkItem) workItemList.get(0)).getId();
}
/**
*
*/
@Test
public void testWithdrawFromWorkItem1() {
currentProcessInstance = (IProcessInstance) transactionTemplate.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus arg0) {
try {
IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();
IProcessInstance processInstance = workflowSession.createProcessInstance("WithdrawAndReject","fireflowTester");
processInstance.run();
return processInstance;
} catch (EngineException ex) {
Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
} catch (KernelException ex) {
Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
});
assertNotNull(currentProcessInstance);
IPersistenceService persistenceService = runtimeContext.getPersistenceService();
List taskInstanceList = persistenceService.findTaskInstancesForProcessInstance(currentProcessInstance.getId(), "WithdrawAndReject.Activity1");
assertNotNull(taskInstanceList);
assertEquals(1, taskInstanceList.size());
assertEquals(new Integer(ITaskInstance.RUNNING), ((ITaskInstance) taskInstanceList.get(0)).getState());
assertEquals(1, ((ITaskInstance) taskInstanceList.get(0)).getStepNumber().intValue());
List tokenList = persistenceService.findTokensForProcessInstance(currentProcessInstance.getId(), null);
assertNotNull(tokenList);
assertEquals(1, tokenList.size());
IToken token = (IToken) tokenList.get(0);
assertEquals(1, token.getStepNumber().intValue());
List workItemList = persistenceService.findTodoWorkItems(CurrentUserAssignmentHandlerMock.ACTOR_ID, "WithdrawAndReject", "WithdrawAndReject.Activity1.Task1");
assertNotNull(workItemList);
assertEquals(1, workItemList.size());
assertEquals(new Integer(IWorkItem.INITIALIZED), ((IWorkItem) workItemList.get(0)).getState());
workItem1Id = ((IWorkItem) workItemList.get(0)).getId();
transactionTemplate.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus arg0) {
try {
IWorkflowSession workflowSession = runtimeContext.getWor
java工作流引擎,带流程绘制工具
5星 · 超过95%的资源 需积分: 0 66 浏览量
更新于2023-05-16
收藏 61.13MB ZIP 举报
Java工作流引擎是一种用于自动化业务流程的技术,它能够帮助开发者设计、执行和管理复杂的业务流程。在Java领域,有许多著名的工作流引擎,如Activiti、jbpm和Flowable等。这些引擎提供了强大的功能,包括流程定义、任务分配、流程监控以及与其他系统的集成。
流程绘制工具是工作流引擎的重要组成部分,它使得业务流程的设计变得更加直观和易懂。通过图形化界面,用户可以拖放各种流程元素,如开始事件、结束事件、用户任务、服务任务、网关等,以构建出符合企业需求的业务流程图。这些图形化的流程模型可以导出为BPMN(Business Process Modeling Notation)标准格式,便于理解和交流。
在Java软件或插件中,一个完整的工作流解决方案通常包括以下核心组件:
1. **流程定义工具**:提供图形化的流程设计界面,用户可以通过拖拽方式构建流程模型。这些模型可以包含决策点、分支、并行处理等多种流程控制结构。
2. **流程引擎**:执行流程定义,根据流程模型进行任务调度和流转。引擎解析BPMN模型,管理和执行流程实例,处理各种流程活动。
3. **任务管理**:为用户提供任务列表,展示当前待办任务,并允许用户完成任务、转发任务或者添加额外信息。
4. **监控和报表**:实时展示流程状态,提供统计分析,帮助管理层了解流程执行情况,发现瓶颈,优化流程。
5. **集成能力**:工作流引擎通常需要与企业其他系统(如ERP、CRM)进行集成,实现数据共享和业务联动。
6. **版本控制**:支持流程定义的版本管理,方便在不同版本间切换,适应业务变更。
7. **API和扩展**:提供丰富的API和插件机制,允许开发者自定义行为,扩展引擎功能。
在“fireflow”这个压缩包文件中,可能包含了上述的一些组件或示例代码。为了更好地利用这个工具,你需要了解Java编程,熟悉BPMN规范,以及如何配置和使用工作流引擎。通过阅读文档、查看源码和运行示例,你可以学习如何创建和管理自己的业务流程。
Java工作流引擎和流程绘制工具是企业信息化建设中的关键组件,它们有助于提高工作效率,减少人为错误,同时提供了流程透明度和可追溯性。如果你正在寻找一种方式来规范和自动化企业的业务流程,那么深入了解和应用这类工具将是至关重要的。