Processing staff activities

Staff activities in business processes are assigned to various people in your organization through work items. When a process is started, work items are created for the potential owners.

Why and when to perform this task

A potential owner claims the activity. This person is responsible for providing the relevant information and completing the activity.

Steps for this task

  1. List the activities belonging to a logged-on person that are ready to be worked on:
    QueryResultSet result = 
         process.query("ACTIVITY.AIID", 
                       "ACTIVITY.STATE = ACTIVITY.STATE.STATE_READY AND
                        ACTIVITY.KIND = ACTIVITY.KIND.KIND_STAFF AND
                        WORK_ITEM.REASON = 
                             WORK_ITEM.REASON.REASON_POTENTIAL_OWNER",
                        (String)null, (Integer)null, (TimeZone)null); 
    This action returns a query result set that contains the activities that can be worked on by the logged-on person.
  2. Claim the activity to be worked on:
    if (result.size() > 0)
    {
    	result.first();
    	AIID aiid = (AIID) result.getOID(1);
    	ClientObjectWrapper input = process.claim(aiid);
    	DataObject activityInput = null ;
      if ( input.getObject()!= null && input.getObject() instanceof DataObject )
      {
        activityInput = (DataObject)input.getObject();
        // read the values
        ...
      }  
    }
    When the activity is claimed, the input message of the activity is returned.
  3. When work on the activity is finished, complete the activity. The activity can be completed either successfully or with a fault message. If the activity is successful, an output message is passed. If the activity is unsuccessful, the activity is put into the failed or stopped state and a fault message is passed. You must create the appropriate messages for these actions. When you create the message, you must specify the message type name so that the message definition is contained.
    1. To complete the activity successfully, create an output message.
      ActivityInstanceData activity = process.getActivityInstance(aiid);
      ClientObjectWrapper output = 
            process.createMessage(aiid, activity.getOutputMessageTypeName());
      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 activity
      process.complete(aiid, output);
      This action sets an output message that contains the order number.
    2. To complete the activity when a fault occurs, create a fault message.
      //retrieve the faults modeled for the staff activity
      List faultNames = process.getFaultNames(aiid);
      
      //create a message of the appropriate type
      ClientObjectWrapper myFault = 
            process.createMessage(aiid, 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);
      }
      
      process.complete(aiid, (String)faultNames.get(0), myFault);
      This action sets the activity in either the failed or the stopped state. If the continueOnError parameter for the activity in the process model is set to true, the activity is put into the failed state and the navigation continues. If the continueOnError parameter is set to false and the fault is not caught on the surrounding scope, the activity is put into the stopped state. In this state the activity can be repaired using force terminate or force retry.

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