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

          Posted on 2005-12-16 16:58 蝦米老 閱讀(714) 評論(0)  編輯  收藏 所屬分類: flow學習
          (一)  開始一個請假流程
                 //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();

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

          Copyright © 蝦米老

          主站蜘蛛池模板: 泌阳县| 色达县| 正阳县| 塘沽区| 贵州省| 灵丘县| 沅陵县| 鄯善县| 盖州市| 岳阳市| 隆回县| 达州市| 大庆市| 调兵山市| 三明市| 凤阳县| 吴桥县| 萍乡市| 南宫市| 乃东县| 密山市| 汉阴县| 柘城县| 朔州市| 荥经县| 邢台市| 富顺县| 崇礼县| 奉节县| 牙克石市| 祁阳县| 环江| 依兰县| 天峨县| 兴海县| 城固县| 昌江| 措美县| 庄浪县| 麦盖提县| 鸡西市|