4 Replies Latest reply on Oct 13, 2005 5:41 AM by a s

    customizing task instances

    a s Newbie

      I am looking at implementing jbpm for the workflow related tasks in my application.
      The process consists of the followings steps ->create tasks , assign/re-assign tasks and complete tasks.
      I have had a look at the task-node and the JBPM_TASKINSTANCE table in which the tasks instances are stored. However i find that we need to store more information regrading the tasks then those that stored in JBPM_TASKINSTANCE.

      I need a solution for the problem .
      Should i customize the taskinstance , ie subclass it .
      If yes, where can i find some examples /more elaborate steps to do the same? because the tutorial ( scetion 9.8 ) does not include any details.

      please suggest how i should go about this ?

        • 1. Re: customizing task instances
          James Depoorter Novice

          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
            a s Newbie

            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
              Alejandro Guizar Master

              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;

              • 4. Re: customizing task instances
                a s Newbie

                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>
                 <task-node name="create action">
                 <task name="task1">
                 <assignment class="com.jbay.CreateTaskHandler"></assignment>
                 <transition name="tr1" to="assign action"></transition>
                 <node name="assign action">
                 <event type="node-enter">
                 <action name="AssignAction" class="com.jbay.AssignTaskHandler"></action>
                 <transition name="tr2" to="end1"></transition>
                 <end-state name="end1"></end-state>

                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?