[轉(zhuǎn)]一個JBPM工作流管理示例(四)

          Posted on 2005-12-16 16:58 蝦米老 閱讀(709) 評論(0)  編輯  收藏 所屬分類: flow學習
          (一)  開始一個請假流程
                 //user是請假人的actorId
                 ExecutionService es=JbpmServiceFactory.getInstance().openExecutionService(user);
                  HashMap vs=new HashMap();
                 //一些參數(shù)
                  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();
                  }
          (二)當前執(zhí)行任務(wù)
              對于部門經(jīng)理或者老板,找到要處理的請假。
                 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("任務(wù): " + tasks);
                      log.debug("當前可以執(zhí)行的請求: " + 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");//進行轉(zhuǎn)換的transition
                      executionService.endOfState(tokenId,hm,act);
                      executionService.close();

          posts - 5, comments - 3, trackbacks - 0, articles - 0

          Copyright © 蝦米老

          主站蜘蛛池模板: 苗栗县| 阳高县| 柳河县| 乃东县| 玛沁县| 昌邑市| 黄陵县| 诸城市| 昌都县| 高平市| 珲春市| 宁强县| 涞源县| 泰顺县| 黄浦区| 大新县| 固阳县| 塘沽区| 嘉义县| 扶风县| 陆川县| 怀集县| 开化县| 隆尧县| 高雄市| 镇康县| 连江县| 会同县| 桦甸市| 剑河县| 边坝县| 南丰县| 尖扎县| 瑞金市| 潞西市| 芷江| 石楼县| 绩溪县| 陆河县| 沙坪坝区| 黄龙县|