All work items for a particular workflow step reside in a queue, typically a User queue, a Work queue, or both. A required operation of any Step Processor is to retrieve the work items for the step. The work items are retrieved by querying the queue (or queues) that holds the work items.
See About Queues for general information about workflow system queues.
To query a queue for Step elements or WorkObject elements, do the following actions:
Alternatively, you might want to display a list of queues. See Displaying a List of Queues for this information.
To help optimize your queries on queues:
The following Step Processor sample illustrates how to query a queue to retrieve a VWStepElement object. Logger and SessionHelper objects are created. Comments and code that are related to querying a queue are in bold.
This code uses the QueueHelper (helper class) sample. See also StepProcessor Sample.
import filenet.vw.api.*;
/*
* This sample Step Processor class illustrates how to retrieve,
* modify, and complete a step using the VWStepElement class.
*/
public class StepProcessorSample extends Object
{
// declare variables
/*
* Constructor - performs initialization and establishes
* the Process session.
*/
public StepProcessorSample(VWSession vwSession, Logger logger, String queueName)
{
QueueHelper queueHelper = null;
VWQueue vwQueue = null;
VWStepElement vwStepElement = null;
try
{
logger.logAndDisplay("\n~ Starting StepProcessorSample execution.");
// create the helper class
queueHelper = new QueueHelper(vwSession, logger);
// get the requested queue
vwQueue = queueHelper.getQueue(queueName);
if (vwQueue != null)
{
// get a step element
vwStepElement = queueHelper.getStepElement(vwQueue);
if (vwStepElement != null)
{
// lock the record
vwStepElement.doLock(true);
// set the comments
vwStepElement.setComment("This is the user's comment.");
// display the Step Processor information
logger.displayStepElementInfo(vwStepElement);
// complete the step
logger.log("Completing step: " + vwStepElement.getOperationName());
vwStepElement.doDispatch();
}
}
}
catch(Exception ex)
{
if (logger != null)
logger.log(ex);
else
ex.printStackTrace();
}
finally
{
if (logger != null)
logger.logAndDisplay("~ StepProcessorSample execution complete.\n");
}
}
/*
* Creates the Logger and SessionHelper objects, then
* instantiates the outer class.
*/
public static void main(String args[])
{
String queueName = null;
String outputFileName = null;
Logger logger = null;
SessionHelper sessionHelper = null;
VWSession vwSession = null;
StepProcessorSample sampleClass = null;
try
{
// did the user supply enough arguments?
if (args.length < 4 || (args.length > 0 && args[0].compareTo("?") == 0))
{
System.out.println("Usage: StepProcessorSample username password router_URL queueName [output_filename]");
System.exit(1);
}
// the file name (for output) is optional
if (args.length > 4)
outputFileName = args[4];
else
outputFileName = new String("StepProcessorSample.out");
// create and initialize the logger
logger = new Logger(outputFileName);
// create the session and log in
sessionHelper = new SessionHelper(args[0], args[1], args[2], logger);
vwSession = sessionHelper.logon();
if (vwSession != null)
{
// create the sample class
sampleClass = new StepProcessorSample(vwSession, logger, args[3]);
}
}
catch (Exception ex)
{
if (logger != null)
logger.log(ex);
else
ex.printStackTrace();
}
finally
{
// logoff
if (sessionHelper != null)
sessionHelper.logoff();
}
}
}