IBM FileNet P8, Version 5.2.1            

Working with Custom Root Classes

The following information and code examples demonstrate custom root class operations. For an overview of custom root classes, see Custom Root Classes.

Creating a Custom Root Class

The following Java™ and C# examples show how to create a custom root class from the CmAbstractSequential class definition. The custom root class serves as a queue table that's periodically processed by a client application. Because the client needs to retrieve and process table entries sequentially, CmAbstractSequential is subclassed.

Java Example

// Fetch class definition.
ClassDefinition asCD = Factory.ClassDefinition.fetchInstance(os, GuidConstants.Class_CmAbstractSequential, null);

// Create CmAbstractSequential subclass.
ClassDefinition newCD = asCD.createSubclass();
newCD.set_SymbolicName("MySequentialRootClass");
LocalizedString ls = Factory.LocalizedString.createInstance();
ls.set_LocalizedText("My Sequential Root Class");
ls.set_LocaleName("en_US");
LocalizedStringList lsl = Factory.LocalizedString.createList();
lsl.add(ls);
newCD.set_DisplayNames(lsl);
newCD.save(RefreshMode.REFRESH);

C# Example

// Fetch class definition.
IClassDefinition asCD = Factory.ClassDefinition.FetchInstance(os, GuidConstants.Class_CmAbstractSequential, null);

// Create CmAbstractSequential subclass.
IClassDefinition newCD = asCD.CreateSubclass();
newCD.SymbolicName = "MySequentialRootClass";
ILocalizedString ls = Factory.LocalizedString.CreateInstance();
ls.LocalizedText = "Custom root class for processing entries in order";
ls.LocaleName = "en_US";
ILocalizedStringList lsl = Factory.LocalizedString.CreateList();
lsl.Add(ls);
newCD.DisplayNames = lsl;
newCD.Save(RefreshMode.REFRESH);
    

Creating an Instance of the Custom Root Class

The following Java and C# examples show how to create an instance of the custom root class that was created in the previous example. Note that because CmAbstractSequential is abstract, the Factory method for creating the instance must specify the custom root class, MySequentialRootClass, not the base abstract class.

Java Example

// Create an instance of the CmAbstractSequential subclass, MySequentialRootClass.
CmAbstractSequential asInstance = Factory.CmAbstractSequential.createInstance(os, "MySequentialRootClass");
asInstance.save(RefreshMode.REFRESH);

C# Example

// Create an instance of the CmAbstractSequential subclass, MySequentialRootClass.
ICmAbstractSequential asInstance = Factory.CmAbstractSequential.CreateInstance(os, "MySequentialRootClass");
asInstance.Save(RefreshMode.REFRESH);
    

Applying a Disposition Policy to the Custom Root Class

The following Java and C# examples show how to create a disposition policy and apply it to a custom root class that was created in a previous example. The disposition policy is configured to remove MySequentialRootClass instances that are older than 30 days.

Note that when a client creates and saves a CmDisposalPolicy object, the server automatically creates the objects that are required for policy-based processing: CmSweepPolicyRelationship and CmPolicyControlledSweep. For more information, see Disposal Policies.

Java Example

CmDisposalPolicy policy = Factory.CmDisposalPolicy.createInstance(os);
policy.set_DisplayName("Disposition Policy for MySequentialRootClass");

// Specify MySequentialRootClass as the policy target.
policy.set_SweepTarget(Factory.ClassDefinition.getInstance(os,new Id("{5E1F975A-54BC-411C-B8FF-63ECB0B2C4CC}")));

// Specify disposition of instances older than 30 days.
policy.set_FilterExpression("Now() > DateCreated + TimeSpan(30, 'days')"); 

policy.save(RefreshMode.NO_REFRESH);

C# Example

ICmDisposalPolicy policy = Factory.CmDisposalPolicy.CreateInstance(os);
policy.DisplayName = "Disposition Policy for MySequentialRootClass";

// Specify MySequentialRootClass as the policy target.
policy.SweepTarget = Factory.ClassDefinition.GetInstance(os, new Id("{5E1F975A-54BC-411C-B8FF-63ECB0B2C4CC}"));

// Specify disposition of instances older than 30 days.
policy.FilterExpression = "Now() > DateCreated + TimeSpan(30, 'days')"; 
                    
policy.Save(RefreshMode.NO_REFRESH);
    


Last updated: October 2015
customclass_procedures.htm

© Copyright IBM Corporation 2015.