Processing participating or purely human tasks

Why and when to perform this task

Participating or purely human tasks are assigned to various people in your organization through work items. Participating tasks and their associated work items are created, for example, when a process navigates to a staff activity. One of the potential owners claims the task associated with the work item. This person is responsible for providing the relevant information and completing the task.

Steps for this task

  1. List the tasks belonging to a logged-on person that are ready to be worked on.
    QueryResultSet result = 
         task.query("TASK.TKIID", 
                    "TASK.STATE = TASK.STATE.STATE_READY AND
                    (TASK.KIND = TASK.KIND.KIND_PARTICIPATING OR 
                     TASK.KIND = TASK.KIND.KIND_HUMAN)AND
                     WORK_ITEM.REASON = 
                       WORK_ITEM.REASON.REASON_POTENTIAL_OWNER",
                     null, null, null); 

    This action returns a query result set that contains the tasks that can be worked on by the logged-on person.

  2. Claim the task to be worked on.
    if (result.size() > 0)
    {
      result.first();
      TKIID tkiid = (TKIID) result.getOID(1);
      ClientObjectWrapper input = task.claim(tkiid);
      DataObject taskInput = null ;
      if ( input.getObject()!= null && input.getObject() instanceof DataObject )
      {
        taskInput = (DataObject)input.getObject();
        // read the values
        ...
      }  
    }

    When the task is claimed, the input message of the task is returned.

  3. When work on the task is finished, complete the task.

    The task can be completed either successfully or with a fault message. If the task is successful, an output message is passed. If the task is unsuccessful, a fault message is passed. You must create the appropriate messages for these actions.

    1. To complete the task successfully, create an output message.
      ClientObjectWrapper output = 
            task.createOutputMessage(tkiid);
      DataObject myMessage = null ;
      if ( output.getObject()!= null && output.getObject() instanceof DataObject )
      {
        myMessage = (DataObject)output.getObject();
        //set the parts in your message, for example, an order number
        myMessage.setInt("OrderNo", 4711);
      }
      
      //complete the task
      task.complete(tkiid, output); 
      This action sets an output message that contains the order number. The task is put into the finished state.
    2. To complete the task when a fault occurs, create a fault message.
      //retrieve the faults modeled for the task
      List faultNames = task.getFaultNames(tkiid);
      
      //create a message of the appropriate type
      ClientObjectWrapper myFault = 
            task.createFaultMessage(tkiid, (String)faultNames.get(0));
      
      // set the parts in your fault message, for example, an error number
      DataObject myMessage = null ;
      if ( myFault.getObject()!= null && input.getObject() instanceof DataObject )
      {
        myMessage = (DataObject)myFault.getObject();
        //set the parts in the message, for example, a customer name
        myMessage.setInt("error",1304);
      }
      
      task.complete(tkiid, (String)faultNames.get(0), myFault);

      This action sets a fault message that contains the error code. The task is put into the failed state.


Terms of use |

Last updated: Tue Feb 21 17:31:27 2006

(c) Copyright IBM Corporation 2005.
This information center is powered by Eclipse technology (http://www.eclipse.org)