LockReportSample

This stand-alone sample demonstrates how to log the work object number and user information for locked work objects. Run the sample by entering a command similar to the following:

java LockReportSample username password <server name>:<port number>/<router instance name> [output_filename]

Note For a detailed explanation of the command line, see the Run the sample application section of the Run the Unmodified Samples topic.

Methods

The LockReportSample class contains two methods: the main(String args[]) method and the LockReportSample(VWSession vwSession, Logger logger) method, which is the constructor.

main(String args[])

The main method uses common techniques for validating and defaulting argument values.  If the user does not supply an output filename, the main method supplies LockReportSample.out. The method sets local variables to point to the VWSession and Logger object arguments and passes them to the sample constructor. This method handles the login and logoff for the session with the login() and logoff() methods of the sample SessionHelper class. The main method provides workflow logging functions by creating an instance of the sample Logger class. The LockReportSample main method passes the session and the logger instances to the LockReportSample constructor.

The following code from the LockReportSample main method enables it to operate as a stand-alone program. It validates the arguments and supplies a default value for the [output_filename] string, as needed.

if (args.length < 3 || (args.length > 0 && args[0].compareTo("?") == 0)){

System.out.println("Usage:  LockReportSample username password router_URL [output_filename]");
System.exit(1);

}

 // The file name (for output) is optional.

if(args.length > 3) fileName = args[3];
else  

// Supply a default output_filename.

fileName = new String("LockReportSample.out");

Instantiate Logger and session objects. The sample SessionHelper class instantiates the session object:

logger = new Logger(fileName);

// Create the session instance and log on.

sessionHelper = new SessionHelper(args[0], args[1], args[2], logger);

Log onto the session with sessionHelper.logon() and construct an instance of the LockReportSample class.

vwSession = sessionHelper.logon();
if (vwSession != null) {

            // Create the sample class.

    sampleClass = new LockReportSample(vwSession, logger);
}

When the class terminates, the main method terminates the session with sessionHelper.logoff(). Additional code in the main method manages common cleanup and error handling.

LockReportSample(VWSession vwSession, Logger logger)

The code for the LockReportSample constructor is organized as follows:

Output a header for the lock report withlogger.logAndDisplay(String):

logger.logAndDisplay("\n~ Begin writing lock report.");

Create a QueueHelper object:

queueHelper = new QueueHelper(vwSession, logger);

Log the lock status of each work object in each queue.

queueHelper.displayQueueLockStatus();