カスタム・スイープ・オブジェクトの作成
スイープ・オブジェクトは、インスタンスの取得元のターゲット・クラスを設定するためのプロパティー、および取得されたインスタンスが指定された基準に準拠しない場合に、そのインスタンスをフィルタリングして除外するためのプロパティーを提供します。カスタム・スイープ・オブジェクトには、追加プロパティーが含まれています。このプロパティーは、スイープ・オブジェクトによって取得されたインスタンスを処理するユーザー実装のアクション・ハンドラーを指定します。
カスタム・スイープ・オブジェクトのタイプは、CmCustomSweepJob、CmCustomSweepPolicy、または CmCustomQueueSweep のいずれかです。
以下の Java™ および C# の例では、CmCustomSweepJob オブジェクトの作成方法を示します。(CmCustomSweepPolicy または CmCustomQueueSweep オブジェクトを作成するコードも同様です。)オブジェクトは、Document クラスをスイープし、スイープによって返されたクラス・インスタンスに対して FilterExpression プロパティーを適用するように構成されます。フィルター式の結果として、指定された MimeType 値を持つインスタンスのみが、処理のためにアクション・ハンドラーに渡されます。
Java の例
// Creates a custom sweep job.
CmCustomSweepJob customJob = Factory.CmCustomSweepJob.createInstance(os, "CmCustomSweepJob");
customJob.set_DisplayName("Java Custom Sweep Job: Change class");
customJob.set_SweepTarget(Factory.DocumentClassDefinition.getInstance(os, GuidConstants.Class_Document));
customJob.set_IncludeSubclassesRequested(Boolean.TRUE);
customJob.set_SweepMode(SweepMode.SWEEP_MODE_NORMAL);
// Get CmSweepAction object that references custom handler.
CmSweepAction sweepAction = Factory.CmSweepAction.fetchInstance(os,
new Id("{19F6121E-B6D0-4210-92FA-CC8B8D4C07E2}"), null);
customJob.set_SweepAction(sweepAction);
// Set filter expression so that only document's of the following mime type
// are passed to custom handler.
customJob.set_FilterExpression("MimeType='application/dita+xml'");
customJob.save(RefreshMode.NO_REFRESH);
C# の例
// Creates a custom sweep job.
ICmCustomSweepJob customJob = Factory.CmCustomSweepJob.CreateInstance(os, CmCustomSweepJob);
customJob.DisplayName="C# Custom Sweep Job: Change class";
customJob.SweepTarget = Factory.DocumentClassDefinition.GetInstance(os, GuidConstants.Class_Document);
customJob.IncludeSubclassesRequested=true;
customJob.SweepMode=SweepMode.SWEEP_MODE_NORMAL;
// Get ICmSweepAction object that references custom handler.
ICmSweepAction sweepAction = Factory.CmSweepAction.FetchInstance(os,
new Id("{19F6121E-B6D0-4210-92FA-CC8B8D4C07E2}"), null);
customJob.SweepAction=sweepAction;
// Set filter expression so that only document's of the following mime type
// are passed to custom handler.
customJob.FilterExpression="MimeType='application/dita+xml'";
customJob.Save(RefreshMode.NO_REFRESH);