[jboss-user] [jBPM] - Human task : assign the good task to the launcher of a processInstance

Sandra Renaud do-not-reply at jboss.com
Fri Nov 9 06:02:09 EST 2012

Sandra Renaud [https://community.jboss.org/people/joploya] created the discussion

"Human task : assign the good task to the launcher of a processInstance"

To view the discussion, visit: https://community.jboss.org/message/775721#775721


I have a confusion between the processInstance and the Task with Jbpm5. 

My scenario is as explain bellow :
 https://community.jboss.org/servlet/JiveServlet/showImage/2-775721-19863/N_PL.png  https://community.jboss.org/servlet/JiveServlet/downloadImage/2-775721-19863/195-279/N_PL.png 
1/ A user enters in the application and starts a new processInstance of a jbpm process.
                                ProcessInstance process = ksession.startProcess("com.st.ams.flow.npl", params);
                                System.out.println("process = "+process.getProcessId()+" : "+process.getProcessName()+" : state("+process.getState()+")");

2/ A new task is created in the database in the state Ready with the name "startNPLRequest_PM_PL", and with this code I am abble to see that my user can claim this task and complete it :
                                //Now the PM_PL process his task (it is already complete in reality)
                              List<String> groups = new ArrayList<String>();
                              System.out.println("Groups : ");
                              for(String grp : groups){
                                        System.out.println(" - "+grp);
                              BlockingTaskSummaryResponseHandler taskSummaryResponseHandler = new BlockingTaskSummaryResponseHandler();
                              amsKnowledgeSession.getClient().getTasksAssignedAsPotentialOwner(requestor.getName(), groups, "en-UK", taskSummaryResponseHandler);
                              List<TaskSummary> potentialTasks = taskSummaryResponseHandler.getResults();
                              for(TaskSummary task : potentialTasks){
                                        System.out.println("PM_PL can execute task " + task.getName() + " (" + task.getId() + " : " + task.getDescription() + ")");

3/ The problem is that several users with the role PM_PL will launch this process at the same time, so how can I assign the good task (of the good process but I know the processId) to my user?
     I have not find the link between processId and taskId. And I need the taskId to start the task :
                    amsKnowledgeSession.getClient().start( taskId, requestorId, taskSummaryResponseHandler );

In the documentation we have this explanation but I don't really understand it :
> // adding a task
> BlockingAddTaskResponseHandler addTaskResponseHandler = new BlockingAddTaskResponseHandler();
> Task task = ...;
> client.addTask( task, null, addTaskResponseHandler );
> long taskId = addTaskResponseHandler.getTaskId();
It must be a very simple question but I will be very happy if someone can explain me this concept.


Reply to this message by going to Community

Start a new discussion in jBPM at Community

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

More information about the jboss-user mailing list