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

    (一)  开始一个请假流程
       //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();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值