0 Replies Latest reply on Jun 30, 2014 6:15 AM by kondzik

    jBPM 6.0.1 problem with task.complete and params

    kondzik Newbie

      i am writing workflow with human tasks:

       

      start -> HT1 with object/variables input -> HT2 with object/variables input -> end

       

      when i try with http request:

      start proces with params (but not objects) is working http://localhost:8080/jbpm-console/rest/runtime/io.xxx.io:ioproject:1.0/process/ioproject.iobp3/start?map_x=5&map_y=4

      start task is working http://localhost:8080/jbpm-console/rest/task/55/start

      but when i send complete task http://localhost:8080/jbpm-console/rest/task/24/complete?map_a=78 there is problem. My human task 2 loose all data.

       

      i used rest api too and it is bigger problem:

       

                  
      public class ProcessTest {
        public static void main(String[] args) throws MalformedURLException {
        String deploymentId = "org.jbpm:epg:1.0";
        URL appUrl = new URL("http://localhost:8080/jbpm-console/");
        String user = "admin";
        String password = "admin";
      
      
        String nazwaProcesu = "epg.Proces1";
        ProcessTest pt = new ProcessTest();
      
        Map<String, Object> params = new HashMap<String, Object>();
        Dokument p = new Dokument();
        p.name = "1 K ";
        p.state = "2 K ";
        p.value = 55;
      
      
        params.put("dokument", p);
      
        String zmienna;
        System.out.println(" wybierz 1,2,3:");
              Scanner scanIn = new Scanner(System.in);
        zmienna = scanIn.nextLine();
              scanIn.close();  
      
         switch (zmienna) {
           case "1":
             System.out.println(zmienna + " rozpocznijProces");
      
      
        pt.rozpocznijProces(nazwaProcesu, params, deploymentId, appUrl, user,
        password);
             break;
        
           case "2":
             System.out.println(zmienna + " wystartujTaska");
      
        System.out.println(" podaj id procesu:");
        long proces_id=22;
        pt.wystartujTaska(proces_id,nazwaProcesu, deploymentId, appUrl, user, password);
             break;
            
           case "3":
             System.out.println(zmienna + " zamknijTaska");yy
        p.name = "3 K ";
        p.state = "4 K ";
        p.value = 77;
        params.put("dokument", p);
        System.out.println(" podaj id procesu:");
        long proces_id2=22;
             pt.zamknijTaska(proces_id2, nazwaProcesu, params, deploymentId, appUrl, user, password);
             break;
        
           default:
             System.out.println("nieprzewidziana sytuacja");
         }
        }
      
      
        // Map<String, Object> variables = ksession.execute(new
        // GenericCommand<Map<String, Object>>() {
        //
        // public Map<String, Object> execute(Context context) {
        // StatefulKnowledgeSession ksession = ((KnowledgeCommandContext)
        // context).getStatefulKnowledgesession();
        // ProcessInstance processInstance = (ProcessInstance)
        // ksession.getProcessInstance(piId);
        // VariableScopeInstance variableScope = (VariableScopeInstance)
        // processInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
        // Map<String, Object> variables = variableScope.getVariables();
        // return variables;
        // }
        // });
      
      
      
      
        // ProcessInstanceIdContext.get().
        // VariableScopeInstance variableScope = (VariableScopeInstance)
        // processInstance.(VariableScope.VARIABLE_SCOPE);
        // Map<String, Object> variables = variableScope.getVariables();
        // //
      
      
        public long rozpocznijProces(String nazwaProcesu,
        Map<String, Object> params, String deploymentId, URL appUrl,
        String user, String password) {
      
      
        RemoteRestRuntimeFactory restSessionFactory = new RemoteRestRuntimeFactory(
        deploymentId, appUrl, user, password);
        RemoteRuntimeEngine engine = restSessionFactory.newRuntimeEngine();
      
      
        KieSession ksession = engine.getKieSession();
        TaskService taskService = engine.getTaskService();
        AuditLogService auditLogService = engine.getAuditLogService();
      
      
        ProcessInstance processInstance = ksession.startProcess(nazwaProcesu,
        params);
        List<ProcessInstanceLog> findProcessInstances = auditLogService
        .findProcessInstances();
      // for (ProcessInstanceLog pi : findProcessInstances) {
      // System.out.println("Process Instance: "+pi.getProcessName() +
      // " - Version: "+pi.getProcessVersion() +
      // " - Started at: "+pi.getStart()+
      // " pi.getProcessId "+pi.getProcessId()+ " getId "+pi.getId()+
      // " getIdentity "+pi.getIdentity()+
      // " getExternalId "+pi.getExternalId()+
      // " getOutcome "+pi.getOutcome());
      // }
        return processInstance.getId();
        }
      
      
        public long wystartujTaska(long processInstance_id,String nazwaProcesu,
        String deploymentId, URL appUrl, String user, String password) {
        RemoteRestRuntimeFactory restSessionFactory = new RemoteRestRuntimeFactory(
        deploymentId, appUrl, user, password);
        RemoteRuntimeEngine engine = restSessionFactory.newRuntimeEngine();
      
      
        KieSession ksession = engine.getKieSession();
        TaskService taskService = engine.getTaskService();
      
      
      
      
        int i = 0;
        long task_id = 0;
      
      
        List<TaskSummary> tasksAssignedAsPotentialOwner = taskService
        .getTasksAssignedAsPotentialOwner(user, "en-UK");
        for (TaskSummary task : tasksAssignedAsPotentialOwner) {
      
      
        i++;
        System.out.println(" processInstance_id"+processInstance_id);
        System.out.println(" task.getProcessInstanceId()"+task.getProcessInstanceId());
        if ((processInstance_id == task.getProcessInstanceId())) {
      
        if (task.getStatus() == Status.Reserved) {
        taskService.start(task.getId(), user);
      task_id=task.getId();
        }
        }
        }
        return task_id;
        }
      
        public void zamknijTaska(long processInstance_id,String nazwaProcesu, Map<String, Object> params,
        String deploymentId, URL appUrl, String user, String password) {
        RemoteRestRuntimeFactory restSessionFactory = new RemoteRestRuntimeFactory(
        deploymentId, appUrl, user, password);
        RemoteRuntimeEngine engine = restSessionFactory.newRuntimeEngine();
      
      
        KieSession ksession = engine.getKieSession();
        TaskService taskService = engine.getTaskService();
      
      
        List<TaskSummary> tasksAssignedAsPotentialOwner = taskService
        .getTasksAssignedAsPotentialOwner(user, "en-UK");
        for (TaskSummary task : tasksAssignedAsPotentialOwner) {
      
      
        System.out.println(" processInstance_id"+processInstance_id);
        System.out.println(" task.getProcessInstanceId()"+task.getProcessInstanceId());
        if ((processInstance_id == task.getProcessInstanceId())) {
        System.out.println(" s1");
        if (task.getStatus() == Status.InProgress) {
        System.out.println(" s2");
        taskService.complete(task.getId(), user,params);
        System.out.println(" s3");
      
      
        }
        }
        }
        }
      
      }
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      

      and after taskService.complete(id,user,params)

      i have marshall error

       

      i found solution(with completetaskcommand) how to make task close but object in my human task and variables are empty:

       

      solutions and errors:

      #1

      blad1.PNG

       

      #2

       

      blad2.PNG

       

      i just want to get object with values, send to my ht1 ,then, after close HT1 make magic with script, fork, etc and finally send modified object to HT2 and then end.

      Why i can send object with start proces? Why i can get what i want in kie workbench? When i send my data to human tasks with tasksum.complete i have some errors or HT values empty?