Discussion:
[jboss-user] [jBPM] - Pass the result of a workitem to the next workitem with a workitemhandler
hansi007
2012-05-30 15:03:23 UTC
Permalink
hansi007 [https://community.jboss.org/people/hansi007] created the discussion

"Pass the result of a workitem to the next workitem with a workitemhandler"

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

--------------------------------------------------------------
Is it possible to pass the results of a workitem to the next workitem with a workitemhandler:


public  class MyHandlerWorkItemTypeA implements WorkItemHandler{
 
       @Override
          public final void executeWorkItem(WorkItem wItem, WorkItemManager wItemManager) {
                     Map<String,Object> objectToPassToTheNextWorkItem = ...
                     wItemManager.completeWorkItem(wItem.getId(), objectToPassToTheNextWorkItem ); //That doesnt work 
          }
 
          @Override
          public final void abortWorkItem(WorkItem wItem, WorkItemManager wItemManager) {
 
          }      
}
 
public  class MyHandlerWorkItemTypeB implements WorkItemHandler{
 
       @Override
          public final void executeWorkItem(WorkItem wItem, WorkItemManager wItemManager) {
                     Map<String,Object> objectToGetFromThePreviousWorkItem = wItem.getResults(); //That doesnt work
          }
 
          @Override
          public final void abortWorkItem(WorkItem wItem, WorkItemManager wItemManager) {
 
          }
}
 
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Esteban Aliverti
2012-06-01 07:21:57 UTC
Permalink
Esteban Aliverti [https://community.jboss.org/people/eaa] created the discussion

"Re: Pass the result of a workitem to the next workitem with a workitemhandler"

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

--------------------------------------------------------------
The wItem parameter that you have in the handlers is a reference to the curren Work Item and not to the previous one.
What you have to do is to return a Map<String,Object> in WorkItemA (just like you are doing), then map the results of that Work Item as process variables, and then map those variables (just the one you will need) as input parameters of WorkItemB. In WorkItemB you can get those values using wItem.getParameter(...).
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
David Harris
2013-05-02 22:19:52 UTC
Permalink
David Harris [https://community.jboss.org/people/dmwpepper] created the discussion

"Re: Pass the result of a workitem to the next workitem with a workitemhandler"

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

--------------------------------------------------------------
My question is similar.  In my executeWorkItem, I have

Map<String,Object> results = new HashMap<String,Object>();
results.put("Source_IP", "333.33.333.33");
results.put("Start_Date", "1999 01 01");
results.put("End_Date", "2000 01 01");

Chapter 14 of the User Guide says:
Result Mapping: Allows you to map a result (returned once a work item has been executed) to a variable of the process.  This allows you to use results in the remainder of the process.

In Eclipse, there is a "Result Mapping" attribute associated with the service task.  Do I create an association between the results variable and the process variable by using the "Result Mapping" attribute?  The association seems to go in backwards.  In other words, the Parameter (work item) and Variable (process) only go in one way, so I can't put the work item result into the process variable.  I can only put the process variable into a work item result, which is the opposite of what I need to do.  What am I doing wrong? Thanks.
--------------------------------------------------------------

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

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