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

          Posted on 2005-12-16 16:58 蝦米老 閱讀(709) 評論(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 © 蝦米老

          主站蜘蛛池模板: 历史| 静宁县| 革吉县| 麻江县| 尉氏县| 察雅县| 永济市| 平和县| 电白县| 合川市| 桃江县| 阳江市| 九江县| 凤阳县| 吴桥县| 遵义县| 太白县| 增城市| 介休市| 松潘县| 饶阳县| 鹤山市| 松江区| 大城县| 汤阴县| 吉林市| 积石山| 揭东县| 四平市| 桃江县| 丰台区| 阳曲县| 岳西县| 桐梓县| 类乌齐县| 静乐县| 内丘县| 介休市| 依安县| 浙江省| 全椒县|