-
1. Re: customizing task instances
icyjamie Oct 11, 2005 6:35 AM (in response to jbpm2005)9.8 says exactly what to do:
- create a subclass of TaskInstance
- update the property jbpm.task.instance.class to specify the name of custom class
- create a mapping file for the subclass, for mapping the extra properties you want to save
- add that mapping file to the list of mapping files
What else do you want to know? -
2. Re: customizing task instances
jbpm2005 Oct 11, 2005 10:28 AM (in response to jbpm2005)Thanks for that reply.
I managed to customize the taskInstance to suit my requirements and persisted the same in the database using task-nodes in my processdefinition. Obviously the extra properties are saved as null as i have not set them.
How do i access the TaskInstances created by the task-node ?
How do i set these properties in the Assignment Handler for my TaskInstances ?
Some sample code will be helpful -
3. Re: customizing task instances
aguizar Oct 12, 2005 12:51 AM (in response to jbpm2005)Section 9.3.1 states that assignment handlers are called when a task instance is created. Therefore, you access task instances in assignment handlers.
The signature of the assign method is:void assign(Assignable assignable, ExecutionContext executionContext)
9.3.1 points out that both TaskInstance and SwimlaneInstance implement this interface. Hence, you can cast the assignable to your custom subclass of TaskInstance:public class MyAssignmentHandler implements AssignmentHandler { void assign(Assignable assignable, ExecutionContext executionContext) { MyTaskInstance mti = (MyTaskInstance) assignable; mti.setActorId("someone"); mti.setCustomIntProperty(24); } }
-
4. Re: customizing task instances
jbpm2005 Oct 13, 2005 5:41 AM (in response to jbpm2005)Thanks alex , that was helpful, i guess i missed that bit in the docs
I have some more questions,
This is my process definition,<process-definition name="test2"> <start-state name="start"> <transition name="tr1" to="create action"></transition> </start-state> <task-node name="create action"> <task name="task1"> <assignment class="com.jbay.CreateTaskHandler"></assignment> </task> <transition name="tr1" to="assign action"></transition> </task-node> <node name="assign action"> <event type="node-enter"> <action name="AssignAction" class="com.jbay.AssignTaskHandler"></action> </event> <transition name="tr2" to="end1"></transition> </node> <end-state name="end1"></end-state> </process-definition>
It consists of 1) creating tasks , 2) the person assigned the task can now reassign the task to someone else.
After each node is executed the processinstance is persisted in the database.
1.At node "assign action" - i need to know how the taskinstance created by the previos task-node can be retrieved from the execution context and assigned to another actor ID in the ActionHandler .
2. Knowing TaskInstanceID can i find out the processinstanceId of the process that created it ? or do i have to maitain this mapping myself in a session?