10 Replies Latest reply on Jan 23, 2013 2:31 AM by TC ONG

    Task Human - Parameter Mapping

    Natalia Lucero Newbie

      Hi,

       

      How I can get the values of Parameter Mapping in a human task using a taskClient?

       

       

      How to map the values of Result Mapping of a human task in a variables of the process?

       

      Thanks,

       

      Natalia

        • 1. Task Human - Parameter Mapping
          Mauricio Salatino Master

          Hi, are you using BPMN2 processes?

          If you are using the new version you need to create the output and input mappings to each workitem/human task. which version of the eclipse plugin are you using?

          Greetings

          • 2. Task Human - Parameter Mapping
            Natalia Lucero Newbie

            Hi,

            Yes, I'm using BPMN2 processes.

            The eclipse plugin version is 5.0.0.SNAPSHOT.

            I need to know how to obtain these parameters from java. Will this be done with the taskClient?  How can I do it?

             

            Thanks,

             

            Natalia

            • 3. Re: Task Human - Parameter Mapping
              TC ONG Newbie

              Hello jBPM team~? Anyone? Is this even possible?

              How to obtain the parameters from Java?

              You need another year to solve this?

              • 4. Re: Task Human - Parameter Mapping
                Mauricio Salatino Master

                Are you using the TaskClient? with that you can get the content of the task and get the parameters. Which alternatives did you try already? Or are you waiting here until someone respond?

                What errors are you getting? Can you give us more background about what are you trying to do?

                 

                Cheers

                • 5. Re: Task Human - Parameter Mapping
                  Arun V G Newbie

                  Hint to get the content of the task

                   

                  //Retrieve task

                  taskclient.getTask(taskId, responseHandler);

                  Task task = responseHandler.getTask();

                   

                  long documentContentId = task.getTaskData().getDocumentContentId();

                   

                  //Retrieve content using content id

                  taskclient.getContent(documentContentId, contentResponseHandler);

                  byte[] objectinBytes = contentResponseHandler.getContent().getContent();

                   

                   

                  From this byte you can get the object which is a map of input parameters to the human task.

                   

                  Hope this helps..

                  • 6. Re: Task Human - Parameter Mapping
                    TC ONG Newbie

                    I cannot use the Parameter Mapping in the Human Task and pass value to my Java program.

                     

                    However

                     

                    I can use Content to pass value to my Java program.

                     

                    Correct?

                     

                    Thanks Arun for the sample code.

                    • 7. Re: Task Human - Parameter Mapping
                      TC ONG Newbie

                      I figured it out now.

                       

                      Step 1: Create a variable in your process. (I use userComms, it's my POJO)

                      Screen shot 2012-04-13 at 1.27.17 PM.png

                      Step 2: In the Human Task Parameter Mapping, map my variable to "Content".

                      (I always have this problem doing this. See https://community.jboss.org/message/729763#729763 )

                      Screen shot 2012-04-13 at 1.29.21 PM.png

                       

                      Step 3: [Optional] In the On Entry Action of the Human Task, I set the value of my POJO. You can do it any way you like.

                      Question: is the kcontext.setVariable() necessary?

                      userComms = new UserComms();

                      userComms.setQuestion("Hello World~!");

                       

                      kcontext.setVariable("userComms", userComms);

                       

                      Step 4: Compile and run our process.

                       

                      Step 5: Accessing your variable from the task's "Content"

                                                    BlockingGetTaskResponseHandler taskResponseHandler = new BlockingGetTaskResponseHandler();

                                                    taskClient.getTask(task1.getId(), taskResponseHandler);

                                                    Task task = taskResponseHandler.getTask();

                                                    long documentContentId = task.getTaskData().getDocumentContentId();

                       

                                                    UserComms userComms = new UserComms();

                                                    BlockingGetContentResponseHandler contentResponseHandler = new BlockingGetContentResponseHandler();

                                                    taskClient.getContent(documentContentId, contentResponseHandler);

                                                    Content content = contentResponseHandler.getContent();

                                 

                                  if (content != null){

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

                                      ObjectInputStream ois;

                       

                                      try {

                                          ois = new ObjectInputStream(bais);

                                          Object obj = ois.readObject();

                                          System.out.println("Object = " + obj.getClass());  // will return an empty string if not mapped properly

                                          if(obj instanceof UserComms) {

                                              userComms =(UserComms) obj;

                                              System.out.println(userComms.getQuestion());

                                          }

                                      } catch (IOException e) {

                                          e.printStackTrace();

                                     } catch (ClassNotFoundException e) {

                                          e.printStackTrace();

                       

                                      }

                                  }

                       

                      And I got my POJO from the Content.

                      Happy.

                      • 8. Re: Task Human - Parameter Mapping
                        Mantu Singh Newbie

                        Hi TC ONG,

                         

                        i am getting an error on running the same example........................can u help me out on this?

                        is same example working for u?

                         

                        thanks

                         

                        error is....

                         

                        Loading knowledge base.

                        Registering Human Task..

                        Hellooooo~~~!

                        no_male = null

                        Hello World~!?

                        org.jbpm.workflow.instance.WorkflowRuntimeException: [humanTaskFlow:1 - Scan no of male:2] -- null

                                  at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:132)

                                  at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:279)

                                  at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:238)

                                  at org.jbpm.workflow.instance.node.JoinInstance.triggerCompleted(JoinInstance.java:152)

                                  at org.jbpm.workflow.instance.node.JoinInstance.internalTrigger(JoinInstance.java:52)

                                  at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:126)

                                  at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:279)

                                  at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:238)

                                  at org.jbpm.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:49)

                                  at org.jbpm.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:41)

                                  at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:126)

                                  at org.jbpm.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:35)

                                  at org.jbpm.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:194)

                                  at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:309)

                                  at org.jbpm.process.instance.ProcessRuntimeImpl.startProcessInstance(ProcessRuntimeImpl.java:170)

                                  at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:140)

                                  at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1098)

                                  at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:320)

                                  at com.utsav.poc.LocalTaskClientTest.main(LocalTaskClientTest.java:68)

                        Caused by: java.lang.NullPointerException

                                  at org.jbpm.process.workitem.wsht.SyncWSHumanTaskHandler.executeWorkItem(SyncWSHumanTaskHandler.java:270)

                                  at org.drools.process.instance.impl.DefaultWorkItemManager.internalExecuteWorkItem(DefaultWorkItemManager.java:70)

                                  at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:107)

                                  at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:126)

                                  ... 18 more

                        • 9. Re: Task Human - Parameter Mapping
                          Mantu Singh Newbie

                          Hi ,

                           

                          i have solved this problem , your https://community.jboss.org/thread/200045 post helped me on this.....thanks!!

                          but i still have one problem ... after completion of two user task it throws exception in Diverging getway.

                          this code is there for Diverging getway...

                           

                          <conditionExpression xsi:type="tFormalExpression" language="http://www.java.com/java" >System.out.println("no_male = " + no_male);

                          System.out.println("no_female = " + no_female);

                          System.out.println("actual_male = " + actual_male);

                          System.out.println("actual_female = " + actual_female);

                           

                          System.out.println("compare = " + (

                              ( no_male.equals( actual_male )) &amp;&amp;

                              ( no_female.equals( actual_female ))

                          ));

                           

                          return (

                              no_male.equals( actual_male ) &amp;&amp;

                              no_female.equals( actual_female )

                          );</conditionExpression>

                           

                          a.bmp

                          exception................!!!!!!

                          org.jbpm.workflow.instance.WorkflowRuntimeException: [humanTaskFlow:1 - Gateway:6] -- Exception when trying to evaluate constraint Match in split Gateway

                              at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:132)

                              at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:279)

                              at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:238)

                              at org.jbpm.workflow.instance.impl.ExtendedNodeInstanceImpl.triggerCompleted(ExtendedNodeInstanceImpl.java:47)

                              at org.jbpm.workflow.instance.node.StateBasedNodeInstance.triggerCompleted(StateBasedNodeInstance.java:216)

                              at org.jbpm.workflow.instance.node.StateBasedNodeInstance.triggerCompleted(StateBasedNodeInstance.java:196)

                              at org.jbpm.workflow.instance.node.WorkItemNodeInstance.triggerCompleted(WorkItemNodeInstance.java:247)

                              at org.jbpm.workflow.instance.node.HumanTaskNodeInstance.triggerCompleted(HumanTaskNodeInstance.java:90)

                              at org.jbpm.workflow.instance.node.WorkItemNodeInstance.workItemCompleted(WorkItemNodeInstance.java:309)

                              at org.jbpm.workflow.instance.node.WorkItemNodeInstance.signalEvent(WorkItemNodeInstance.java:285)

                              at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(WorkflowProcessInstanceImpl.java:342)

                              at org.drools.process.instance.impl.DefaultWorkItemManager.completeWorkItem(DefaultWorkItemManager.java:116)

                              at org.jbpm.process.workitem.wsht.SyncWSHumanTaskHandler$TaskCompletedHandler.handleCompletedTask(SyncWSHumanTaskHandler.java:361)

                              at org.jbpm.process.workitem.wsht.SyncWSHumanTaskHandler$TaskCompletedHandler.execute(SyncWSHumanTaskHandler.java:325)

                              at org.jbpm.task.service.local.LocalTaskService$SimpleEventTransport.trigger(LocalTaskService.java:329)

                              at org.jbpm.task.event.MessagingTaskEventListener.triggerPayload(MessagingTaskEventListener.java:76)

                              at org.jbpm.task.event.MessagingTaskEventListener.handleEvent(MessagingTaskEventListener.java:92)

                              at org.jbpm.task.event.MessagingTaskEventListener.taskCompleted(MessagingTaskEventListener.java:109)

                              at org.jbpm.task.event.TaskEventSupport.fireTaskCompleted(TaskEventSupport.java:49)

                              at org.jbpm.task.service.TaskServiceSession.postTaskCompleteOperation(TaskServiceSession.java:569)

                              at org.jbpm.task.service.TaskServiceSession.taskOperation(TaskServiceSession.java:495)

                              at org.jbpm.task.service.local.LocalTaskService.complete(LocalTaskService.java:83)

                              at com.utsav.poc.LocalTaskClientTest.main(LocalTaskClientTest.java:121)

                          Caused by: java.lang.RuntimeException: Exception when trying to evaluate constraint Match in split Gateway

                              at org.jbpm.workflow.instance.node.SplitInstance.internalTrigger(SplitInstance.java:79)

                              at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:126)

                              ... 22 more

                          Caused by: java.lang.RuntimeException: unable to execute ReturnValueEvaluator:

                              at org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator.evaluate(ReturnValueConstraintEvaluator.java:132)

                              at org.jbpm.workflow.instance.node.SplitInstance.internalTrigger(SplitInstance.java:72)

                              ... 23 more

                          Caused by: java.lang.NullPointerException

                              at com.geneoz.flow.Process_com_geneoz_flow_HumanTaskFlow_b_a0f515366213482980bd0febe418f32c.returnValueEvaluator5(Process_com_geneoz_flow_HumanTaskFlow_b_a0f515366213482980bd0febe418f32c.java:48)

                              at com.geneoz.flow.Process_com_geneoz_flow_HumanTaskFlow_b_a0f515366213482980bd0febe418f32cReturnValueEvaluator5Invoker.evaluate(Process_com_geneoz_flow_HumanTaskFlow_b_a0f515366213482980bd0febe418f32cReturnValueEvaluator5Invoker.java:18)

                              at org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator.evaluate(ReturnValueConstraintEvaluator.java:130)

                              ... 24 more

                          • 10. Re: Task Human - Parameter Mapping
                            TC ONG Newbie

                            Check the split node.