The following Java™ and C# examples show how to create a CmCustomSweepJob object. (The code for creating a CmCustomSweepPolicy or CmCustomQueueSweep object is similar.) The object is configured to sweep the Document class and to apply the FilterExpression property against the class instances that are returned by the sweep. As a result of the filter expression, only instances with the specified MimeType value are passed to the action handler for processing.
Java Example
// 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# Example
// 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);