1、4 工作流客户端文档
Business Key
Business Key是业务系统中用来标识一个流程实例的标识,工作流系统使用该标识可以找到相应的流程实例。例如在检察院系统中,是案件编号。业务系统在创建流程实例时将将值赋予创建的流程实例,以后每次都使用该值于工作流交互,工作流可以找到对应的流程实例。
Business Key在工作流中,作为一个流程实例变量存储在数据库中。工作流中的变量包括变量名、类型和值这些属性。配置一个作为Business Key的变量,需要指定变量名称和类型,供工作流系统使用。
配置business key示例如下:
3、 Double 接口说明: 接口列表中,对流程依赖比较严重而不建议使用的接口排在后面。 获取工作流接口: 嵌入式工作流接口: com.thunisoft.wf.embedded. WorkflowFacade; 这个接口是嵌入式工作流的一个门面,集成了嵌入式工作流提供的相关服务集合。 可以通过下面这个静态方法获取工作流façade: com.thunisoft.wf.embedded.WorkflowHelper.getWorkflowFacade(); 关于工作流接口的准确定义和详细情况,请参考javadoc,在这里指出的是一个概要情况。UML图示如下: 流程实例相
4、关接口:
开始新流程实例
/**
* create a new process instance, if instance has no start task, signal instance
* to leave the start state.
*
* if contextVariables contains a key equals Business key, it should be covered.
*
* @param workflowName Process Definition name to create new inst
5、ance * @param keyValue Value of the new ProcessInstance Business key * @param contextVariables Context variables for the new process instance * @return Id of the new process instance , If failed, return null * @throws WorkflowException * @throws {@link IllegalArgumentException} If wor
6、kflowName or keyValue is null, * or key value's type is error. */ public Long startProcessInstance(String workflowName, Object keyValue, Map contextVariables) throws WorkflowException; 流程实例变量管理 存放在流程实例Context内的变量,在整个流程实例范围内可见。 获取给定流程实例全流程范围内的变量 /** * Get all variables stored
7、 in process instance context * @param keyValue * @return * @throws WorkflowException */ public Map getProcessContextVarialbes(Object keyValue) throws WorkflowException; 增加变量到流程实例Context中: 一次增加多个流程变量: /** * Add variables to process context. If a variable is already exists, rep
8、lace it * @param keyValue * @param variables Variables map, use key as variable name, value as variable value * @throws WorkflowException */ public void addProcessVariable(Object keyValue, Map variables) throws WorkflowException; 增加一个流程变量:(不要调用多次来代替上一个接口的功能) /** * Add a va
9、riable to process instance context * @param keyValue Business key value * @param name Variable name * @param value Variable value * @throws WorkflowException * @throws IllegalArgumentException If name or value is null */ public void addProcessVarialbe(Object keyValue, String nam
10、e, Object value) throws WorkflowException; 暂停执行流程实例 /** * resume a process instance * @param keyValue * @throws WorkflowException */ public void resumeProcessInstance(Object keyValue) throws WorkflowException; 获取当前流程实例状态名称 /** * Get name of current state * @param keyValue
11、 Business key value * @return Name of current state, or null if no matched process instance * @throws WorkflowException */ public String getCurrentStateName(Object keyValue) throws WorkflowException; 流程跳转:【不建议使用】 通常情况下,流程跳转一般应该采用工作流中配置来完成,而不适宜通过业务系统调用下面的接口来完成。因为这使得业务系统代码强制性依赖于工作流程,从而显示流
12、程流转逻辑的变化。相似的功能,可以通过在工作流定义中增加Action来完成。 沿默认路径跳转 /** * singal process instance to next state, taking default transition * * @param keyValue Value of business key * @return if no trace, return empty list */ public void singalProcessInstance(Object keyValue) throws WorkflowExcepti
13、on; 沿给定路径跳转 /** * signal process instance to next state, taking gived transition * * @param keyValue * @param transition Transition name, if null, taking default transition * @throws WorkflowException If transition is inexistent */ public void signalProcessInstance(Object
14、keyValue, String transition) throws WorkflowException; 分支沿默认路径跳转 /** * signal a branch of process instance, taking default transition * @param keyValue * @param token Token path of the branch, If null ,take root token as default * @throws WorkflowException */ public void s
15、ignalProcessInstanceBranch(Object keyValue, String token) throws WorkflowException; 分支沿着给定路径跳转 /** * signal a branch of process instance, take gived transition * @param keyValue * @param token Token path of branch * @param transition Transition name, if null, taking default t
16、ransition * @throws WorkflowException If transition is inexistent */ public void signalProcessInstanceBranch(Object keyValue, String token, String transition) throws WorkflowException; 任务管理相关接口方法: 获取给定流程当前状态可以创建实例的任务: 返回的是可以创建的任务名称组成的列表。 /** * Get task name of tasks on curr
17、ent state * @param keyValue * @return To do tasks on current state * @throws WorkflowException */ public List getTodoTasks(Object keyValue) throws WorkflowException; 获取给定流程的历史任务实例: /** * get process instance history trace, all the task instance be wrapped with * {@link Tr
18、ace} object,any task instance has been started should be loaded * order by create-time ASC * @param keyValue Value of business key * @return if no trace, return empty list */ public List getHistoryTraces(Object keyValue) throws WorkflowException; 在给定流程当前状态上创建新任务实例: /**
19、 Create a new task of given task on current state. * @param keyValue * @param taskName Task name * @return Id of created task instance * @throws WorkflowException If current state has no gived task */ public Long createTaskInstance(Object keyValue, String taskName) throws Wor
20、kflowException; 结束一个任务(保存任务实例变量) /** * End given task instance, and save variables for given task instance * @param taskInstanceId * @param variable Variables to save * @throws WorkflowException */ public void commitTaskInstance(Long taskInstanceId, Map variable) throws W
21、orkflowException; 结束一个任务(无变量) /** * End given task instance * @param taskInstanceId */ public void commitTaskInstance(Long taskInstanceId); 保存任务实例 /** * save the taskInstanceId, and add the variables to taskInstance * @param taskInstanceId * @param variables * @thr
22、ows WorkflowException * @throws If taskInstanceId is null */ public void saveTaskInstance(Long taskInstanceId, Map variables) throws WorkflowException; 取消任务实例 /** * Cancel a unfinished task instance * @param taskInstanceId * @param variable * @throws WorkflowException I
23、f task instance is finished */ public void cancelTaskInstance(Long taskInstanceId) throws WorkflowException; 删除任务实例(不提供) /** * Delete given task instance * * @param taskInstanceId * @return * @throws WorkflowException */ public Long deleteTaskInstance(Long taskIn
24、stanceId) throws WorkflowException; 在任意状态上创建任务实例【不建议使用】 /** * Create a new instance of given task on given state * * @param keyValue Business key value * @param stateName State name * @param taskName Task name * @param variable Variables to store in the new task instance * @return Id of created task instance * @throws WorkflowException */ public Long commitSpecialTaskInstance(Object keyValue, String stateName, String taskName, Map variable) throws WorkflowException; }
©2010-2025 宁波自信网络信息技术有限公司 版权所有
客服电话:4009-655-100 投诉/维权电话:18658249818