[jboss-user] [jBPM] - Re: Task Human - Parameter Mapping

TC ONG do-not-reply at jboss.com
Fri Apr 13 01:42:07 EDT 2012


TC ONG [https://community.jboss.org/people/devilkazuya99] created the discussion

"Re: Task Human - Parameter Mapping"

To view the discussion, visit: https://community.jboss.org/message/729764#729764

--------------------------------------------------------------
I figured it out now. 

Step 1: Create a variable in your process. (I use userComms, it's my POJO)
 https://community.jboss.org/servlet/JiveServlet/showImage/2-729764-18391/Screen+shot+2012-04-13+at+1.27.17+PM.png  https://community.jboss.org/servlet/JiveServlet/downloadImage/2-729764-18391/310-158/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#729763 https://community.jboss.org/message/729763#729763 )
 https://community.jboss.org/servlet/JiveServlet/showImage/2-729764-18392/Screen+shot+2012-04-13+at+1.29.21+PM.png  https://community.jboss.org/servlet/JiveServlet/downloadImage/2-729764-18392/450-113/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.  :)
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/729764#729764]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120413/1dbbaaf3/attachment-0001.html 


More information about the jboss-user mailing list