IBM FileNet P8, バージョン 5.2.1            

バックグラウンド検索の定義

以下の Java™ および C# のコード例は、CmBackgroundSearch インターフェースのサブクラスを作成しカスタム・プロパティーを作成することによってバックグラウンド検索を定義する方法を示しています。
それぞれのコード例では、以下のステップを実行します。
  1. DITARenditionEngineConnection サブクラス定義を作成します。
  2. CmBackgroundSearch サブクラス定義の SearchExpression プロパティー定義のデフォルト値を SQL 検索式に設定します。
  3. SearchResults プロパティー定義の必須クラスを、前に定義した CmAbstractSearchResult サブクラスに設定します。
  4. 検索式内に含まれる、そのパラメーターのプロパティー・テンプレートを定義します。
  5. 新しいプロパティー・テンプレートを使用して、CmBackgroundSearch サブクラス定義にカスタム・プロパティー定義を追加します。

Java の例

// Fetch CmBackgroundSearch class definition.
ClassDefinition objClassDefBkSearch = Factory.ClassDefinition.fetchInstance(objObjectStore, GuidConstants.Class_CmBackgroundSearch, null);

// Create a subclass of the CmBackgroundSearch class.
ClassDefinition objClassDefBkSearchSub = objClassDefBkSearch.createSubclass();

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

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

// Set symbolic name for subclass.
objClassDefBkSearchSub.set_SymbolicName("BackgroundSearchSub1");

// Get property definitions list.
PropertyDefinitionList objPropDefs = objClassDefBkSearchSub.get_PropertyDefinitions();

// Iterate property definitions until SearchExpression is found and set its PropertyDefaultString
// metadata property to the background search expression.
String strPropDefSymbolicName = null;
PropertyDefinitionString objPropDef = null;
for (int i=0; i < objPropDefs.size(); i++)
{
   strPropDefSymbolicName = ((PropertyDefinition) objPropDefs.get(i)).get_SymbolicName();
   if (strPropDefSymbolicName.equalsIgnoreCase("SearchExpression"))
   {
      objPropDef = (PropertyDefinitionString) objPropDefs.get(i);
      Property prop = objPropDef.getProperties().get("PropertyDefaultString");
      prop.setObjectValue("SELECT DocumentTitle FROM Document1 WHERE DateCreated > @StartDate Parameter@");
   }
}

// Fetch CmAbstractSearchResult subclass definition created in previous example.
ClassDefinition objClassDefSearchResultSub = Factory.ClassDefinition.fetchInstance(objObjectStore, "SearchResultSubclass1", null);

// Iterate property definitions until SearchResults is found and set its RequiredClassId
// metadata property to the CmAbstractSearchResult subclass that was previously defined.
strPropDefSymbolicName = null;
objPropDef = null;
for (int i=0; i < objPropDefs.size(); i++)
{
   strPropDefSymbolicName = ((PropertyDefinition) objPropDefs.get(i)).get_SymbolicName();
   if (strPropDefSymbolicName.equalsIgnoreCase("SearchResults"))
   {
      objPropDef = (PropertyDefinitionString) objPropDefs.get(i);
      Property prop = objPropDef.getProperties().get("RequiredClassId");
      prop.setObjectValue(objClassDefSearchResultSub.get_Id());
   }
}

// Create property template for a DateTime custom property to use for the search parameter named StartDate.
String strTemplateName = "StartDate";
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 template.
LocalizedString objLocStrPT = Factory.LocalizedString.createInstance();
objLocStrPT.set_LocalizedText(strTemplateName);
objLocStrPT.set_LocaleName(objObjectStore.get_LocaleName());

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

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

// プロパティー・テンプレートからプロパティー定義を作成
PropertyDefinitionDateTime objPropDefDT = (PropertyDefinitionDateTime) objPropTemplate.createClassProperty();

// Create custom property by adding the new property definition to the CmBackgroundSearch subclass definition.
objPropDefs.add(objPropDefDT);
objClassDefBkSearchSub.save(RefreshMode.REFRESH);

C# の例

// Fetch CmBackgroundSearch class definition.
IClassDefinition objClassDefBkSearch = Factory.ClassDefinition.FetchInstance(objObjectStore, GuidConstants.Class_CmBackgroundSearch, null);

// Create a subclass of the CmBackgroundSearch class.
IClassDefinition objClassDefBkSearchSub = objClassDefBkSearch.CreateSubclass();

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

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

// Set symbolic name for subclass.
objClassDefBkSearchSub.SymbolicName = "BackgroundSearchSub1";

// Get property definitions list.
IPropertyDefinitionList objPropDefs = objClassDefBkSearchSub.PropertyDefinitions;

// Iterate property definitions until SearchExpression is found and set its PropertyDefaultString
// metadata property to the background search expression.
String strPropDefSymbolicName = null;
foreach (IPropertyDefinitionString objPropDef in objPropDefs)
{
   strPropDefSymbolicName = objPropDef.SymbolicName;
   if (strPropDefSymbolicName.Equals("SearchExpression"))
   {
      IProperty prop = objPropDef.Properties.GetProperty("PropertyDefaultString");
      prop.SetObjectValue("SELECT DocumentTitle FROM Document1 WHERE DateCreated > @StartDate Parameter@");
   }
}

// Fetch CmAbstractSearchResult subclass definition created in previous example.
IClassDefinition objClassDefSearchResultSub = Factory.ClassDefinition.FetchInstance(objObjectStore, "SearchResultSubclass1", null);

// Iterate property definitions until SearchResults is found and set its RequiredClassId
// metadata property to the CmAbstractSearchResult subclass that was previously defined.
strPropDefSymbolicName = null;
foreach (IPropertyDefinitionString objPropDef in objPropDefs)
{
   strPropDefSymbolicName = objPropDef.SymbolicName;
   if (strPropDefSymbolicName.Equals("SearchResults"))
   {
      IProperty prop = objPropDef.Properties.GetProperty("RequiredClassId");
      prop.SetObjectValue(objClassDefSearchResultSub.Id);
   }
}
// Create property template for a DateTime custom property to use for the search parameter named StartDate.
String strTemplateName = "StartDate";
IPropertyTemplateDateTime objPropTemplate = Factory.PropertyTemplateDateTime.CreateInstance(objObjectStore);

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

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

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

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

// プロパティー・テンプレートからプロパティー定義を作成
IPropertyDefinitionDateTime objPropDefDT = (IPropertyDefinitionDateTime) objPropTemplate.CreateClassProperty();

// Create custom property by adding the new property definition to the CmBackgroundSearch subclass definition.
objPropDefs.Add(objPropDefDT);
objClassDefBkSearchSub.Save(RefreshMode.REFRESH);


最終更新日: 2015 年 10 月
backgroundsearch_snip2.htm

© Copyright IBM Corp. 2015.