一个JBPM工作流管理示例(四)

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

(一) 开始一个请假流程

//user是请假人的actorId

ExecutionService es=JbpmServiceFactory.getInstance().openExecutionService(user);

HashMap vs=new HashMap();

//一些参数

vs.put(Constants.REQUEST_STATUS,String.valueOf(0));

vs.put(Constants.REQUEST_RETURN_INFO,"No info!");

vs.put(Constants.USER_NAME,EncodeTransfer.toISO(user));

vs.put(Constants.REQUEST_DAYS,String.valueOf(rea.getDays()));

try {

//开启请假流程

es.startProcessInstance(Constants.WORK_NAME, vs);

log.info("["+user+"]"+"申请假期开始!请假"+rea.getDays()+"天!");

return am.findForward("main");

} catch (ExecutionException ex) {

ex.printStackTrace();

log.error("请假进程无法开始!");

return am.findForward("error");

}finally{

es.close();

}

(二)当前执行任务

对于部门经理或者老板,找到要处理的请假。

String actorId = (String) req.getSession().getAttribute(Constants.USER);

if(actorId.equals("wang")){

actorId="boss";

}else if(actorId.equals("bigli")){

actorId="chief";

}

// get the execution service

ExecutionService executionService = JbpmServiceFactory.getInstance().

openExecutionService(actorId);

// get the tasklist from jbpm for user

List tasks = new ArrayList();

// add the jbpm tasks

tasks.addAll(executionService.getTaskList(actorId));

// put the tasklist into the form

mf.setTasks(tasks);

// get the tasklist from jbpm for user

List definitions = new ArrayList();

// add the jbpm definitions

definitions.addAll(executionService.getLatestDefinitions());

// put the tasklist into the form

mf.setRequests(definitions);

// close the execution service

executionService.close();

req.getSession().setAttribute("mainForm",mf);

log.debug("任务: " + tasks);

log.debug("当前可以执行的请求: " + definitions);

(三)处理请假

String actorId = (String) reqrest.getSession().getAttribute(Constants.

USER);

Long tokenId=new Long(req.getParameter("tokenId"));

// get the execution service

ExecutionService executionService = JbpmServiceFactory.getInstance().

openExecutionService(actorId);

Map hm=executionService.getVariables(tokenId);//变量

String act=req.getParameter("action");//进行转换的transition

executionService.endOfState(tokenId,hm,act);

executionService.close();

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航