-
1. Re: passing data to nodes
calca Sep 5, 2011 1:18 PM (in response to d.y.)You define process variables and then, in a task node, you receive parameters and put results. You map these parameters and results to process variables. So you share information between nodes with the process variables.
In the work item handler, you retrieve the parameters from workItem.getParameters(), and you put the results in the way you mentioned (.completeWorkItem).
If you are in a gateway, you can access directly to a process variable by its name. (you can use it in a constraint for example).
Regards,
Demian
-
2. Re: passing data to nodes
d.y. Sep 6, 2011 11:57 AM (in response to calca)I dont get it.
When i start my process i can start it with some params stored in a map, like:
Map<String, Object> params = new HashMap<String, Object>();
boolean examOK = false;
params.put("examOK", examOK);
ksession.startProcess("com.sample.bpmn.hello", params);
How can I access this map in a WorkItemHandler?
When i try it like u told me:
workItem.getParameter("examOK") or workItem.getParameters().get("examOK") i always get null
-
3. Re: passing data to nodes
calca Sep 6, 2011 12:04 PM (in response to d.y.)1 of 1 people found this helpfulYou start your process with this map.
This will get keys from the map, and put them into the process variable you have defined.
Then, in a task node, you have to map each process variable you will need to a node variable.
Then, when you are in work item handler, you will get the parameters you have defined for this node, not all process variables.
To make it more clear. If you are using Eclipse plugin,
1) Define "examOK" variable in process. Click on process->Properties->Variables, and then add this variable
2) Then, for example you have a custom node. Click on the node->Properties->Parameter Mapping, and then you put the name of the process variable, "examOK", and the name you will use it inside work item handler (it can be the same).
3) Then, with workItem.getParameter("examOK") should work.
Hope this helps,
Demian
-
4. Re: passing data to nodes
eaa Sep 6, 2011 12:05 PM (in response to d.y.)1 of 1 people found this helpfulYou are missing some steps in the middle
First of all, you need to declare each of the "variables" passed in startProcess() as process variables.
Then you need to map the variables you want to use into your WorkItemHandler. In order to do this, you need to configure the input parameters of the Work Item Node. What you need to do is basically to map the process variable name with the work item variable name that you want to use.
After you do this, you will be able to access the variable from within the Work Item Handler.
For further examples you can take a look at this set of examples: https://github.com/esteban-aliverti/JBPM-Samples
-
5. Re: passing data to nodes
rrpeterson Sep 6, 2011 7:29 PM (in response to d.y.)I'm going through this myself, so far I've found:
Put the variable into the map like you wrote:
Map<String, Object> params = new HashMap<String, Object>();
boolean examOK = false;
params.put("examOK", examOK);
ksession.startProcess("com.sample.bpmn.hello", params);
Then in the bpmn definition, you need to have the process variables (if you want a global process variable I think?):
<itemDefinition id="_examOK" structureRef="java.lang.Boolean" />
and within the process def itself (still in the .bpmn file):
<property id="examOK" itemSubjectRef="_examOK"/>
You also need the dataInput mapped to your task (within your task, that lies inside the process):
<dataInput id="_999_examOK" name="examOK" />
<inputSet>
<dataInputRefs>_999_examOK</dataInputRefs>
</inputSet>
<dataInputAssociation>
<sourceRef>examOK</sourceRef>
<targetRef>_999_examOK</targetRef>
</dataInputAssociation>
That will map it into your workItemHandler, so you can obtain it via:
Boolean examOk = (Boolean) workItem.getParameter("examOK");
I'm not 100% sure if this is the "correct" way to implement this. I'm unsure if this variable is global for all processes, for instance: what if the process is started multiple times for multiple users? Does each process implementation get its own global examOk boolean using this method?
-
6. Re: passing data to nodes
d.y. Sep 7, 2011 4:24 AM (in response to rrpeterson)Thank You all. It works now. :-)