Human task : assign the good task to the launcher of a processInstance
joploya Nov 9, 2012 6:02 AMHello,
I have a confusion between the processInstance and the Task with Jbpm5.
My scenario is as explain bellow :
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 :
It must be a very simple question but I will be very happy if someone can explain me this concept.
Regards,