[jboss-user] [jBPM] - Re: How to use task and state in jbpm 4.4

Samrat Roy do-not-reply at jboss.com
Tue May 10 05:43:01 EDT 2011


Samrat Roy [http://community.jboss.org/people/whizkid.samrat] created the discussion

"Re: How to use task and state in jbpm 4.4"

To view the discussion, visit: http://community.jboss.org/message/604404#604404

--------------------------------------------------------------
There are multiple ways of doing it .. the way i have tackled it is :

Here is some sample code from my project.. I thought the best way was sharing related code. 


*// Controller code for .. notice approval or rejects comes from the same jsp in a parameter. :  The task Id is the is id of the task created for the user .. {lookup taskservice.. } you will need this taskid to track actions performed on a task ..* 


protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws ServletException {
        String requestId = request.getParameter("requestId");
 *String status = request.getParameter("status");     // approved OR rejected captured from JSP
*
*  String taskId = request.getParameter("taskId");*
        String taskType=request.getParameter("taskType");
        LoginUser loginUser =(LoginUser)request.getSession().getAttribute(MasterUtil.LOGGED_USER);
 *lmsService.approval(requestId,status,taskId,taskType,loginUser.getUsername());   // service method*


        Map retMap = new HashMap();
        try {
        retMap.putAll(referenceData(request));
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        //return new ModelAndView("redirect:/approveLeave.htm",retMap);
        return new ModelAndView(getFormView(),retMap);
    }


// This is a method from lmsservice.. *lmsService.approval()* which takes care of the inputs from the controller.

public void approval(String requestID, String status ,String taskId,String taskType,String userId) {
        if(status.equals("rejected")){
            ApproveLeaveModel aml =leaveModuleDao.getLeaveRequestbyId(requestID); 
            leaveModuleDao.manageLC(aml.getDays(),aml.getRequestorEmpCode(),aml.getDetails());
        }
        //leaveModuleDao.changeLeaveStatus(requestID, status);
        Map<String,Object> variables = new HashMap<String,Object>();
 *variables.put("decision", status);                 // this is where you setup a variable in the process .. let a decision state decide on the //basis of this variable and take the appropriate route .. attached my jpdl image*
 *taskService.setVariables(taskId, variables); // assign variable to the process instance.* 
        if(taskType.equals("g")){
            taskService.takeTask(taskId, userId);
        }
*  taskService.completeTask(taskId);   // This completes a task marked by a  specific task id*
    }
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/604404#604404]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110510/5c0d852b/attachment-0001.html 


More information about the jboss-user mailing list