JBoss Community

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

created by Sandra Renaud in jBPM - View the full discussion

Hello,

 

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

 

My scenario is as explain bellow :

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>();
                              groups.add(requestor.getRole());
                              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.

 

Regards,

Reply to this message by going to Community

Start a new discussion in jBPM at Community