-
1. Re: passing objects between tasks
calca Jul 11, 2011 8:13 AM (in response to badda)Hi!
In your process you have to model the inputs and outputs of each test. In your case, coudl be:
task1
input: -
output: Person object
task2:
input: Person object
output: Person object
task3:
input: Person object
output-
You should declare your Person object as process variable:
<itemDefinition id="_personItem" structureRef="org.test.Person" />
...
<property id="person" itemSubjectRef="_personItem"/>
When declaring inputs and outputs you should make reference to this process variable, for example
For input:
<dataInputAssociation>
<sourceRef>person</sourceRef>
<targetRef>_9_personInput</targetRef>
</dataInputAssociation>
and for output:
<dataOutputAssociation>
<sourceRef>_8_personOutput</sourceRef>
<targetRef>person</targetRef>
</dataOutputAssociation>
This should help you:
http://dcalca.wordpress.com/2011/05/06/variables-in-jbpm5-human-tasks/
Hope it helps,
Demian
-
2. Re: passing objects between tasks
badda Jul 11, 2011 12:47 PM (in response to calca)Thanks Demian. I will look at the link. But does this have to be human task?
-
3. Re: passing objects between tasks
calca Jul 11, 2011 1:03 PM (in response to badda)Sorry, I thought you needed human tasks. Anyway, it is the same, inputs and outputs from tasks, that I described.
You can check in this process how process variables are used in the bpmn file:
In case it is not a human task, I imagine you will have your own WorkItemHandlers, right?
Then, to get the input, something like this should work:
workItem.getParameter("personInput");
Then modify it,
...
And then complete the task with
Map<String, Object> output;
output.put("personOutput")
manager.completeWorkItem(workItem.getId(), );
-
4. Re: passing objects between tasks
badda Jul 11, 2011 9:08 PM (in response to calca)Thanks again!. yes i would like use WorkItemHandlers. Are there WorkItemHandlers examples (in Java) that i can follow?
thanks lot!
-
5. Re: passing objects between tasks
garytse Jul 12, 2011 2:27 AM (in response to badda)http://sourceforge.net/projects/jbpm/files/jBPM%205/jbpm-5.1.0.Final/
jbpm-5.1.0.Final-examples.zip
Unzip and study every one of those cases (especially the Junit ones). Extremely helpful.
-
6. Re: passing objects between tasks
badda Jul 12, 2011 5:29 PM (in response to garytse)Thank you both. I was able to get one task WorkItemHandler working. My next question is -
If i have two tasks, each task to have different WorkItemHandlers - how can i achive this? I want task1 to execute WorkItemHandler1 and task2 to execute WorkItemHandler2.
thanks lot
b
-
7. Re: passing objects between tasks
calca Jul 12, 2011 8:02 PM (in response to badda)You have to register the task to the workitem. You can take a look at the user guide:
http://docs.jboss.org/jbpm/v5.1/userguide/ch13.html#d0e3599
Something like
ksession.getWorkItemManager().registerWorkItemHandler(
"task1", new WorkItemHandler1()ksession.getWorkItemManager().registerWorkItemHandler(
"task2", new WorkItemHandler2()Hope it helps,
Demian
-
8. Re: passing objects between tasks
badda Jul 13, 2011 1:36 PM (in response to calca)Thanks Damian. In this case how do i know (or how does JBPM process) task1 handler is WorkItemHandler1 and Task2 Handler is WorkItermHandler2. Is there any mapping i need to set when defining task or does i need to call HandlerX.completeItem() etc.
thanks log.,
b
-
9. Re: passing objects between tasks
calca Jul 14, 2011 2:58 AM (in response to badda)Hi badda,
When definning the bpmn, you see in the xml:
<task id="_5" name="MyTask" tns:taskName="task1">
And then you map this task name to the workItemHandler:
ksession.getWorkItemManager().registerWorkItemHandler(
"task1", new WorkItemHandler1()Demian
-
10. Re: passing objects between tasks
badda Jul 14, 2011 2:54 PM (in response to calca)Thank lot.. It looks like there is no way to specify 'tns:taskName' in JBPM process editor. Instead i opened the .xml and added
<userTask id="_2" name="My Task1" tns:taskName="task1" >
<userTask id="_3" name="My Task2" tns:taskName="task2" >
I then register handlers as
ksession.getWorkItemManager().registerWorkItemHandler(
"task1", new WorkItemHandler1()ksession.getWorkItemManager().registerWorkItemHandler(
"task2", new WorkItemHandler2()Junit now errors : Could not find work item handler for Human Task. Do i need to specify Handler type? what am i missing here?
Appreciate your help.
b
-
11. Re: passing objects between tasks
badda Jul 14, 2011 5:31 PM (in response to badda)i figured out that - these tasks can not be <userTask> tasks, instead I changed the BPMN .xml to <task>
<task id="_2" name="My Task1" tns:taskName="task1" >
<task id="_3" name="My Task2" tns:taskName="task2" >
This seems to work fine. Is this the correct way?
thanks
B
-
12. Re: passing objects between tasks
calca Jul 14, 2011 7:19 PM (in response to badda)It depends. If you use userTask, you have to register the handler with name "Human Task", for example:
session.getWorkItemManager().registerWorkItemHandler("Human Task",new CommandBasedWSHumanTaskHandler(session));
If you will make your custom task, you have to specify the name in the bmpn and when registering.
Demian
-
13. Re: passing objects between tasks
badda Jul 14, 2011 7:31 PM (in response to calca)Thanks Damian
If i have two User Tasks in the same the BPMN. How can i have each User Task with own different handlers? I am open to other ways try?
For example, i can NOT do this - as it executed only the last.
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WorkItemHandler1()
ksession.getWorkItemManager().registerWorkItemHandler( "Human Task", new WorkItemHandler2()
-
Thanks lot,
B
-
14. Re: passing objects between tasks
calca Jul 14, 2011 9:20 PM (in response to badda)It depends on what you are trying to do. Why using different handlers for each human task? You can do it using <task>, but I recomend you to read and understand
http://docs.jboss.org/jbpm/v5.1/userguide/ch.Human_Tasks.html
and see if you are following the right approach, you can also take a look at this simple test that has two simple human tasks,
Demian