How to set Parameter in WorkItem to be reached within BPMN Process in jbpm-WorkBench

佐手、 提交于 2019-12-12 01:25:02

问题


I have created a custom WorkItem with some parameters, which I have registered in WorkDefinitions.wid file. Then in Business Process I also create Variable Definitions for the entire Process and reference those from WD.wid of my custom WorkItem to those created in BP.

WorkItem execute the code, which takes those parameters from the form after starting the process. For this purpose I use getParameter()- method; It looks as follows:

public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {

String payload = workItem.getParameter("id") + ... ;
...
manager.completeWorkItem(workItem.getId(), null);
}

Everything looks and works ok, cause WorkItem will be successfully executed and I get the result (on the server side after executing workItem in BP); But now I need to get Response after executing POST method with entered parameters. In the code I've created a new variable, which gets parameter from response body and I can see result in the IDE's console, when I execute pure code (without BPMN - process), but I need also register this variable within WorkItem to use it further for the next Task in my BProcess.

SO My Question is: is there something similar to getParameter() - method, but something as setParameter()? How could I register it within WorkItem and how could I get/reach those parameter/variable within BProcess in jbpm (something as global variable I believe).

Thank you very much!


回答1:


Look at the Javadoc of WorkItemManager and see the parameters of completeWorkItem method. You can pass your results in a map. You will then get those values as output parameters of the task that is being executed and can map them to some process variables so the next task can use them.




回答2:


I don't know which version do you use, but for jBPM 6.3, I used to do the same by defining a custom java workitem with a different execute method definition. For me it looks like this:

public Map<String, Object> execute(WorkItem workItem) throws Exception {
    Map<String, Object> result = new HashMap<String, Object>();
    result.put("outputparam", "hello world");
    return result;
}

Using this, I can reference the "outputparam" as a Data Output assignment in the workflow Process for my custom service node.



来源:https://stackoverflow.com/questions/39292802/how-to-set-parameter-in-workitem-to-be-reached-within-bpmn-process-in-jbpm-workb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!