IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();
List myWorkItemsList = workflowSession.findMyTodoWorkItems(CurrentUserAssignmentHandler.APPLICANT);
System.out.println("我(zhang)的待办workitem列表如下:");
for (int i=0;myWorkItemsList!=null && i<myWorkItemsList.size();i++){
IWorkItem wi = (IWorkItem)myWorkItemsList.get(i);
System.out.println("序号:"+i+"; id="+wi.getId()+"; name="+wi.getTaskInstance().getDisplayName()+"; actorId="+wi.getActorId()+"; state="+wi.getState());
}
//选择第一个workitem进行操作
if (myWorkItemsList!=null && myWorkItemsList.size()>0){
IWorkItem wi = (IWorkItem)myWorkItemsList.get(0);
//1、首先签收
wi.claim();
//2、然后设置流程变量
//在实际业务中,申请人应该需要填写一个表单,在这个简单的测试中就省略了……
IProcessInstance processInstance =
((TaskInstance)wi.getTaskInstance()).getAliveProcessInstance();
processInstance.setProcessInstanceVariable("applicant",
CurrentUserAssignmentHandler.APPLICANT);//申请人
processInstance.setProcessInstanceVariable("leaveDays",
LEAVE_DAYS);//请假天数
//3、结束WorkItem
//结束workItem会触发流程实例向下一个环节流转,
wi.complete();
}
return null;
} catch (EngineException ex) {
Logger.getLogger(LeaveApplicationTester.class.getName()).log(Level.SEVERE, null, ex);