4 Replies Latest reply on Dec 1, 2014 1:05 PM by Darren Osten

    How to start human task for all processInstance

    Domenico Schiavone Newbie

      Hi to all, I have any doubts,

      I have a workflow with 3 task:"service-human-service"

       

      KieServices ks = KieServices.Factory.get();

              KieContainer kContainer = ks.getKieClasspathContainer();

              KieBase kbase = kContainer.getKieBase("kbase");

       

              RuntimeManager manager = createRuntimeManager(kbase);

           RuntimeEngine engine = manager.getRuntimeEngine(null);

              KieSession ksession = engine.getKieSession();

              TaskService taskService = engine.getTaskService();

       

                ksession.getWorkItemManager().registerWorkItemHandler("Smile",(WorkItemHandler) new Smile());

       

                Map<String, Object> params = new HashMap<String, Object>();

              params.put("variable1", "Saluti a tutti");

       

      Now I make any start process:

         

      ksession.startProcess("com.sample.bpmn.hello", params);

          ksession.startProcess("com.sample.bpmn.hello", params);
          ksession.startProcess("com.sample.bpmn.hello", params);

       

      Now if I make this:

       

      // let john execute Task 1

              List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");

              TaskSummary task = list.get(0);

              System.out.println("John is executing task " + task.getName());

              taskService.start(task.getId(), "john");

              taskService.complete(task.getId(), "john", null);

              // let mary execute Task 2

              list = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK");

              task = list.get(0);       

              System.out.println("Mary is executing task " + task.getName());

              taskService.start(task.getId(), "mary");

              taskService.complete(task.getId(), "mary", null);

       

      In this way I complete the all human task of different processInstancess?????

      if it's no how I must do????