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

Sandra Renaud do-not-reply at jboss.com
Fri Nov 9 08:30:48 EST 2012


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

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

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

--------------------------------------------------------------
I think I find a way to retrieve the good task for my Requestor, but an upstream problem appears :

First the way to start the good task :

                               //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();
                              TaskSummary requestorTask = null;
                              for(TaskSummary task : potentialTasks){
                                        System.out.println("PM_PL can execute task " + task.getName() + " (" + task.getId() + " : " + task.getDescription() + ")");
                                        if(process.getId() == task.getProcessInstanceId()){
                                                  System.out.println("The task "+task.getId()+" "+task.getName()+" is the one the requestor have to take");
                                                  requestorTask = task;;
                                        }
                              }
                              BlockingTaskOperationResponseHandler taskOperationResponseHandler = new BlockingTaskOperationResponseHandler();
                              amsKnowledgeSession.getClient().start(requestorTask.getId(), requestor.getName(), taskOperationResponseHandler);
                              Thread.sleep(60000);
                              System.out.println("The PM_PL has well finish his task : call to complete");
                              amsKnowledgeSession.getClient().complete(requestorTask.getId(), requestor.getName(), null, taskOperationResponseHandler);


The problem now is that each task has the same processInstanceId, processSessionId and workItemId in the database. However I start a new KnowledgeSession and a new process each time :

            KnowledgeBase kbase = readKnowledgeBase();
            StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
            KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "/log/loggerFile.log", 1000);
            HornetQHTWorkItemHandler hornetQHTWorkItemHandler = new HornetQHTWorkItemHandler(ksession);
            ksession.getWorkItemManager().registerWorkItemHandler("Human Task", hornetQHTWorkItemHandler);
            
            // start a new process instance
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("userId", requestor.getName());
            params.put("userGroup", requestor.getRole());
            params.put("flowId", getFlowEntity().getFlowId());
  
            ProcessInstance process = ksession.startProcess("com.st.ams.flow.npl", params);
            System.out.println("process = "+process.getProcessId()+" : "+process.getProcessName()+" : state("+process.getState()+")");
            SystemEventListenerFactory.setSystemEventListener(new SystemEventListener());


If you have a little clue to help me progress...

Thanks
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://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/20121109/acdd54bc/attachment-0001.html 


More information about the jboss-user mailing list