バックグラウンド検索結果の定義
以下の Java™ および C# のコード例は、CmAbstractSearchResult インターフェースのサブクラスを定義することにより、バックグラウンド検索結果を定義する方法を示しています。
それぞれのコード例では、以下のステップを実行します。
- CmAbstractSearchResult サブクラス定義を作成します。
- バックグラウンド検索結果から調べるプロパティー値のプロパティー・テンプレートを定義します。
- 新しいプロパティー・テンプレートを使用して、CmAbstractSearchResult サブクラス定義にカスタム・プロパティー定義を追加します。 このカスタム・プロパティーは、一連の検索結果オブジェクトに返された検索パラメーター・プロパティーをマップします。
Java の例
// 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);
// プロパティー・テンプレートからプロパティー定義を作成
PropertyDefinitionDateTime objPropDef = (PropertyDefinitionDateTime) objPropTemplate.createClassProperty();
// PropertyDefinitions プロパティーをプロパティー・キャッシュから取得
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# の例
// 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);
// プロパティー・テンプレートからプロパティー定義を作成
IPropertyDefinitionDateTime objPropDef = (IPropertyDefinitionDateTime) objPropTemplate.CreateClassProperty();
// PropertyDefinitions プロパティーをプロパティー・キャッシュから取得
IPropertyDefinitionList objPropDefs = objClassDefSearchResultSub.PropertyDefinitions;
// Add new property definition to the CmAbstractSearchResult subclass definition and save it.
objPropDefs.Add(objPropDef);
objClassDefSearchResultSub.Save(RefreshMode.REFRESH);