4 Replies Latest reply on Apr 8, 2011 10:16 PM by bpmn2user

    TaskClient (Parameter mapping - Result mapping)

    lgimenez

      Hi! I'm new in jBPM5 and i have a problem with human tasks...

      I need to know how to map between process variables and task parameters...

       

      I get parameter mapping data with the next code:

       

      BlockingGetContentResponseHandler getContentResponseHandler = new BlockingGetContentResponseHandler();

      taskClient.getContent(contentId, getContentResponseHandler);

      ByteArrayInputStream bis = new ByteArrayInputStream(getContentResponseHandler.getContent().getContent());

      Object data = null;

      try {

                                    ObjectInputStream in = new ObjectInputStream(bis);

                                    data = in.readObject();

                                    System.out.println("====> User Task Data " + data);

                                    in.close();

                          } catch (IOException e) {

                                    System.out.println("Error: " + e.getMessage());

                                    e.printStackTrace();

                                    return;

                          } catch (ClassNotFoundException e) {

                                    System.out.println("Error: " + e.getMessage());

                                    e.printStackTrace();

                                    return;

                          }

       

      In this code, data is always String type... Is it possible to transfer complex data types? How can I do it?

      How to get parameter values from parameter mapping and set result mapping?

      Regards

      Leandro

        • 1. TaskClient (Parameter mapping - Result mapping)
          sasir

          Yes you can transfer complex data types as well..You just have to type cast it as below and you can read the paramter values from that

           

                         HashMap taskinfo1=new HashMap();

                         BlockingGetContentResponseHandler handlerC = new BlockingGetContentResponseHandler();

                         client.getContent(taskData.getDocumentContentId(), handlerC);

                         Content content = handlerC.getContent();

                        

                          if (content != null){

                              ByteArrayInputStream bais = new ByteArrayInputStream(content.getContent());

                              ObjectInputStream ois;

           

                              try {

                                  ois = new ObjectInputStream(bais);

                                  taskinfo1 =(HashMap) ois.readObject();

                              } catch (IOException e) {

                                  e.printStackTrace();

                             } catch (ClassNotFoundException e) {

                                  e.printStackTrace();

           

                              }

                          }

          • 2. TaskClient (Parameter mapping - Result mapping)
            lgimenez

            Hi Sasi, thanks for your answer.

            I tried your solution, but get an error: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.HashMap.

            What is the difference between Content field and parameter mapping properties in task human?

            How can get the information of the parameters using taskClient?

            Regards

            Leandro

            • 3. TaskClient (Parameter mapping - Result mapping)
              fabiowg

              Hi,

               

              I'm still trying to figure out some stuff about jbpm5, but here's what I've got so far concerning your question.

               

              In order to insert the content data in a task, start a process (which has a variable declared "somevalue") passing the map of parameters populated with it (let's say params.put("somevalue", somevalue)), and the human task field "Content" (using the Properties view of eclipse) configured to be "#{somevalue}".

               

              This 'somevalue' is (it seems) what is retrieved when you call client.getContent(taskData.getDocumentContentId(), handler).

              • 4. Re: TaskClient (Parameter mapping - Result mapping)
                bpmn2user

                Here is a simple example where parameters (using Map) are passed to human task.

                http://community.jboss.org/people/bpmn2user/blog/2011/04/03/jbpm5-human-task-api-usage-example