IBM FileNet P8, Version 5.2.1            

Defining the Background Search Results

The following Java™ and C# code examples demonstrate how to define background search results by defining a subclass of the CmAbstractSearchResult interface.
Each code example performs the following steps:
  1. Create a CmAbstractSearchResult subclass definition.
  2. Define a property template for the property value to be examined from the background search results.
  3. Use the new property template to add a custom property definition to the CmAbstractSearchResult subclass definition. This custom property maps a search parameter property that is returned in the set of search result objects.

Java Example

// Fetch CmAbstractSearchResult class definition.
ClassDefinition objClassDefSearchResult = Factory.ClassDefinition.fetchInstance(objObjectStore, GuidConstants.Class_CmAbstractSearchResult, null);

// Create a subclass of the CmAbstractSearchResult class.
ClassDefinition objClassDefSearchResultSub = objClassDefSearchResult.createSubclass();

// Set locale for subclass.
LocalizedString objLocStrSC = Factory.LocalizedString.createInstance();
objLocStrSC.set_LocalizedText("CmAbstractSearchResult Subclass 1");
objLocStrSC.set_LocaleName(objObjectStore.get_LocaleName());

// Set display name for subclass.
objClassDefSearchResultSub.set_DisplayNames(Factory.LocalizedString.createList());
objClassDefSearchResultSub.get_DisplayNames().add(objLocStrSC);

// Set symbolic name for subclass.
objClassDefSearchResultSub.set_SymbolicName("SearchResultSubclass1");

// Create property template for DateTime property to use for property mapping (DateCreated AS DocCreationDate).
String strTemplateName = "DocCreationDate";
PropertyTemplateDateTime objPropTemplate = Factory.PropertyTemplateDateTime.createInstance(objObjectStore);

// Set cardinality of properties that will be created from the property template.
objPropTemplate.set_Cardinality(Cardinality.SINGLE);

// Define locale for property template.
LocalizedString objLocStrPT = Factory.LocalizedString.createInstance();
objLocStrPT.set_LocalizedText(strTemplateName);
objLocStrPT.set_LocaleName(objObjectStore.get_LocaleName());

// Set display name for property template.
objPropTemplate.set_DisplayNames(Factory.LocalizedString.createList());
objPropTemplate.get_DisplayNames().add(objLocStrPT);

// Save new property template to the server.
objPropTemplate.save(RefreshMode.REFRESH);

// Create property definition from property template.
PropertyDefinitionDateTime objPropDef = (PropertyDefinitionDateTime) objPropTemplate.createClassProperty();

// Get PropertyDefinitions property from the property cache.
PropertyDefinitionList objPropDefs = objClassDefSearchResultSub.get_PropertyDefinitions(); 

// Add new property definition to the CmAbstractSearchResult subclass definition and save it.
objPropDefs.add(objPropDef);
objClassDefSearchResultSub.save(RefreshMode.REFRESH);

C# Example

// Fetch CmAbstractSearchResult class definition.
IClassDefinition objClassDefSearchResult = Factory.ClassDefinition.FetchInstance(objObjectStore, GuidConstants.Class_CmAbstractSearchResult, null);

// Create a subclass of the CmAbstractSearchResult class.
IClassDefinition objClassDefSearchResultSub = objClassDefSearchResult.CreateSubclass();

// Set locale for subclass.
ILocalizedString objLocStrSC = Factory.LocalizedString.CreateInstance();
objLocStrSC.LocalizedText = "CmAbstractSearchResult Subclass 1";
objLocStrSC.LocaleName = objObjectStore.LocaleName;

// Set display name for subclass.
objClassDefSearchResultSub.DisplayNames = Factory.LocalizedString.CreateList();
objClassDefSearchResultSub.DisplayNames.Add(objLocStrSC);

// Set symbolic name for subclass.
objClassDefSearchResultSub.SymbolicName = "SearchResultSub1";

// Create property template for DateTime property to use for property mapping (DateCreated AS DocCreationDate).
String strTemplateName = "DocCreationDate";
IPropertyTemplateDateTime objPropTemplate = Factory.PropertyTemplateDateTime.CreateInstance(objObjectStore);

// Set cardinality of properties that will be created from the property template.
objPropTemplate.Cardinality = Cardinality.SINGLE;

// Set locale for property template.
ILocalizedString objLocStrPT = Factory.LocalizedString.CreateInstance();
objLocStrPT.LocalizedText = strTemplateName;
objLocStrPT.LocaleName = objObjectStore.LocaleName;

// Set display name for property template.
objPropTemplate.DisplayNames = Factory.LocalizedString.CreateList();
objPropTemplate.DisplayNames.Add(objLocStrPT);

// Save new property template to the server.
objPropTemplate.Save(RefreshMode.REFRESH);

// Create property definition from property template.
IPropertyDefinitionDateTime objPropDef = (IPropertyDefinitionDateTime) objPropTemplate.CreateClassProperty();

// Get PropertyDefinitions property from the property cache.
IPropertyDefinitionList objPropDefs = objClassDefSearchResultSub.PropertyDefinitions;

// Add new property definition to the CmAbstractSearchResult subclass definition and save it.
objPropDefs.Add(objPropDef);
objClassDefSearchResultSub.Save(RefreshMode.REFRESH);


Last updated: October 2015
backgroundsearch_snip1.htm

© Copyright IBM Corporation 2015.