Remote Rest Api - Evaluation Example
damien.s Mar 12, 2014 6:37 AM@
Hi everybody,
I'm trying to execute the Evaluation example with the remote rest api (deploying jbpm 6.0).
When i'm using the jbpm console to create new instance of this wf, it's works fine. I view each task for each use (krisv, john, mary) in the good order.
But when i'm using a junit test calling jbpm with REST API i cant retrieve the tasks for john or mary. The first task for krisv works.
Here is my code :
URL baseURl = new URL("http", "localhost", 8080, "/jbpm-console/"); RemoteRestRuntimeFactory restSessionFactory = new RemoteRestRuntimeFactory("org.jbpm:Evaluation:1.0", baseURl, "krisv", "krisv"); RuntimeEngine engine = restSessionFactory.newRuntimeEngine(); KieSession ksession = engine.getKieSession(); // start a new process instance Map params = new HashMap(); params.put("employee", "krisv"); params.put("reason", "Yearly performance evaluation"); ProcessInstance processInstance = ksession.startProcess("evaluation", params); System.out.println("Process started ..."); // complete Self Evaluation TaskService taskService = engine.getTaskService(); List tasks = taskService.getTasksAssignedAsPotentialOwner("krisv", "en-UK"); TaskSummary task = tasks.get(0); for(TaskSummary tasksummarry : tasks) { if (tasksummarry.getProcessInstanceId() == processInstance.getId()) { task = tasksummarry; break; } } System.out.println("'krisv' completing task " + task.getName() + ": " + task.getDescription()); taskService.start(task.getId(), "krisv"); Map results = new HashMap(); results.put("performance", "exceeding"); taskService.complete(task.getId(), "krisv", results); // john from HR taskService = engine.getTaskService(); tasks = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK"); task = null; for(TaskSummary tasksummarry : tasks) { if (tasksummarry.getProcessInstanceId() == processInstance.getId()) { task = tasksummarry; break; } } System.out.println("'john' completing task " + task.getName() + ": " + task.getDescription()); taskService.claim(task.getId(), "john"); taskService.start(task.getId(), "john"); results = new HashMap(); results.put("performance", "acceptable"); taskService.complete(task.getId(), "john", results); // mary from PM tasks = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK"); task = null; for(TaskSummary tasksummarry : tasks) { if (tasksummarry.getProcessInstanceId() == processInstance.getId()) { task = tasksummarry; break; } } System.out.println("'mary' completing task " + task.getName() + ": " + task.getDescription()); taskService.claim(task.getId(), "mary"); taskService.start(task.getId(), "mary"); results = new HashMap(); results.put("performance", "outstanding"); taskService.complete(task.getId(), "mary", results); assertProcessInstanceCompleted(processInstance.getId(), ksession); System.out.println("Process instance completed");
May be i missed an call ? or anything else ? or there is a problem in the remote api.
Thanks for your help.