ステップ・エレメントまたはワーク・オブジェクトの照会
特定のワークフロー・ステップのすべてのワーク・アイテムは、キュー (通常はユーザー・キューまたはワーク・キューのどちらか、あるいはその両方) に入っています。ステップ・プロセッサーに必要なオペレーションは、ステップのワーク・アイテムを取得することです。ワーク・アイテムは、ワーク・アイテムを保持しているキューを照会して取得されます。
ワークフロー・システム・キューの一般的な情報については、キューについてを参照してください。
キューの照会
キューでステップ・エレメントまたはワーク・オブジェクト・エレメントを照会するには、次の操作を実行します。
- VWSession オブジェクトがまだない場合、Content Platform Engine サーバーにログインし、VWSession を使用するワークフロー・システム・セッションを確立する必要があります。
- VWSession.getQueue() を呼び出して、目的のキューを取得します。
代わりに、キューのリストを表示することもできます。詳細については、「キューのリストの表示」を参照してください。
- VWQueue.createQuery() を呼び出して、キュー上に照会を作成します。ヒント:
- 照会のパフォーマンスを最適化するために、キューに関連付けられているデータベース索引を指定できます。 詳細については、ワークフロー索引の管理を参照してください。
- さらに効率を上げるために、createQuery() メソッドの queryFlags パラメーターで、QUERY_LOCK_OBJECTS フラグを設定できます。 そうすると、返されるワーク・アイテムがロックされます。この場合、次のステップをスキップできる可能性があります。
- VWStepElement.doLock() または VWWorkObject.doLock を使用して、取得したステップ・エレメント、ワーク・オブジェクト・エレメント、または両方のアイテムを、取得直後にロックします。
- 該当する場合、VWQueueQuery.next() を使用して、次の VWQueueElement、VWStepElement、 または VWWorkObject を呼び出します。
- 該当する場合、キューの照会結果を表示します。キューの照会結果を効率的に表示する方法は、QueueHelper.displayQueueContents() サンプル・ヘルパー・クラスを使用することです。
照会の最適化
キュー上の照会を最適化するには:
- より効率的に照会するには、索引とフィルターを使用します。索引は固有である必要があります。フィルターは以下の目的で使用してください。
- 取得するエレメントを指定された範囲内に制限するため。
- Content Platform Engine サーバーからのそれぞれの取り出しで取得されるオブジェクトの最大数を設定するため (VWQueue.setBufferSizeを参照)
- 返されるワーク・アイテムからシステム・フィールドやヘルパー・データを取得しないことにより、返されるデータの量を最小化します。 そのためには、VWQueue.createQuery() の queryFlags パラメーターで照会フラグ QUERY_GET_NO_SYSTEM_FIELDS および QUERY_GET_NO_TRANSLATED_SYSTEM_FIELDS を 1 つ以上設定します。
例: キューの照会
次のステップ・プロセッサーのサンプルは、VWStepElement オブジェクトを取得するためのキューの照会方法を示しています。Logger オブジェクトと SessionHelper オブジェクトが作成されます。コメントとキューの照会に関連するコードは、太字になっています。
このコードは、QueueHelper (ヘルパー・クラス) サンプルを使用しています。「StepProcessorSample」も参照してください。
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~ StepProcessorSample の実行を開始。");
// ヘルパー・クラスを作成
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);
// コメントを設定
vwStepElement.setComment("This is the user's comment.");
// ステップ・プロセッサー情報を表示
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
{
// ユーザーが十分な引数を入力したか?
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");
// ロガーを作成して初期化
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();
}
}
}