ITeye博客

activity5的集成记录

zhyi_12 · 2013-09-03 18:51 · 工作流 · 编程语言 · Markdown

1       集成环境

  • Spring3.2
  • Activity 5.13

2       请假流程实例

2.1     业务流程

  • 员工发起请假请求,并且员工在请假完成前的任何阶段都可以销假。
  • 项目经理审批首先审批流程,1天以上的需要部门经理审批,不同意时退回员工重新调整假期。

 

2.2     activity流程图

 

3       流程集成点

3.1     流程部署

测试中使用数据库存储流程定义文件,通过界面来部署流程。

 

Deployment deployment = processEngine.getRepositoryService()

        .createDeployment().name(dbFlow.getFlowName())

        .addInputStream(dbFlow.getFlowName()+".bpmn20.xml",

               new ByteArrayInputStream(content.getBytes())).deploy();

 

3.2     流程运行

3.2.1  启动流程

在启动流程的时候可以根据实际需要做相关处理.

//任务节点上定义的formProperty可以集成到启动变量里面

/*

List<FormProperty> formProperties = startFormData.getFormProperties();

if(formProperties!=null){

         for(FormProperty formProperty:formProperties){

                   variables.put(formProperty.getId(), formProperty.getValue());

         }

}

*/

//initiator相关实现  processEngine.getIdentityService().setAuthenticatedUserId(initiator);

processEngine.getRuntimeService().startProcessInstanceByKey(processDefinitionKey, variables);

 

/*

如果想在流程中加入业务表数据,可以启用businessKey

processEngine.getRuntimeService().startProcessInstanceByKey(processDefinitionKey,businessObject.getBusinessKey(), variables);

*/

 

 

3.2.2  执行任务

参数处理和启动时类似

processEngine.getTaskService().complete(taskId, taskVariables);

3.3     任务查询

//使用TaskService,可以完成大部分的查询要求。

TaskService taskService = processEngine.getTaskService();

 

3.4     流程表单

使用spring mvc发布表单地址,借用task中的formKey属性。

3.4.1  启动表单

使用spring mvc,约定界面的jsp查找位置:

比如WEB-INF/pages/workflow/run/flow1/startForm.jsp

 

ModelAndView model = new ModelAndView();

 

StartFormData startForm = flowRunManager.getStartFormData(flowKey);

String formKey = startForm.getFormKey();

 

List<FormProperty> formProperties = startForm.getFormProperties();

for(FormProperty formProperty:formProperties){

         model.addObject(formProperty.getId(),formProperty.getValue());

}

 

Object processDefinitionIdVar = startForm.getProcessDefinition().getKey();

String processDefinitionId = processDefinitionIdVar.toString();

 

model.addObject("processDefinitionId", processDefinitionId);

model.setViewName("workflow/run/"+processDefinitionId+"/"+formKey);

3.4.2  任务表单

和启动表单处理类似

 

3.5     自动任务

通过delegateExpression属性可以直接调用spring环境中实现了org.activiti.engine.delegate.JavaDelegate接口的bean。

<serviceTask id="userTask_node3" name="请假完成服务" activiti:delegateExpression="${vacationComplete}"/>

3.6     多结束

如果流程有多个结束,需要在endEvent里面配置terminateEventDefinition。

<endEvent id="endEvent_node1">

<terminateEventDefinition/>

</endEvent>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。