搜尋內容管理系統

您可以使用資料對映中預先配置的 meta 資料來搜尋內容管理系統。 您可以使用資料對映來搜尋多個已配置的內容管理系統。 當您搜尋內容管理系統時,可以尋找並選取要與 IBM® Product Master 項目或種類相關聯的特定內容。

開始之前

  1. 安裝並配置 IBM Content Integrator。
  2. 使用配置檔來配置內容管理系統。
  3. 定義規格。
  4. 將外部內容參照類型屬性新增至規格。

程序

搜尋內容管理系統。 請使用下列其中一種方法: 使用者介面或 Java™ API。
選項 說明
使用者介面
  1. 使用下列其中一種方式,在「單一編輯」畫面中開啟項目或種類:
    1. 按一下窗格導覽中的項目或種類。
    2. 從「項目視圖」畫面開啟要編輯的項目。
    3. 從協同作業區域中選取步驟。
  2. 在「單一編輯」畫面上,按一下外部內容參照屬性旁的搜尋圖示。 即會開啟「搜尋」畫面。
  3. 請至少選取一個儲存庫來執行搜尋。 選擇 ANDOR 搜尋準則。
  4. 提供搜尋屬性的值,然後按一下 搜尋。 搜尋結果會顯示在相同的畫面中。
  5. 選取搜尋結果,以顯示內容內容、內容版本、參照此內容的所有項目,或者如果內容是影像類型,則顯示縮圖預覽。 按一下 關聯文件 ,將該內容與項目的外部內容參照屬性相關聯。 您也可以在 版本 標籤中選取版本,然後按一下 關聯文件 ,將該版本的內容與項目的外部內容參照屬性相關聯。
Java API 下列範例 Java API 程式碼使用 CMSManagerCMSInstance Java 介面來搜尋內容管理系統。
附註: 在 Java API 中不應重複呼叫下列兩個陳述式。
CMSManager CMSMgr = ctx.getCMSManager();
    CMSInstance CMSInst = CMSMgr.getCMSInstance();
否則,這可能會導致 OutOfMemory 或從協同 MDM 連接至「內容管理系統」的應用程式數目增加。 下列範例程式碼會正確使用這些陳述式。
Context ctx = null;
String property = null;
String value = null;
try
{
        ctx = PIMContextFactory.getContext("Admin", "xxx", "MyCompany");
        CMSManager CMSMgr = ctx.getCMSManager();
        CMSInstance CMSInst = CMSMgr.getCMSInstance();
        
        // get datamap
        String dataMapName = CMSMgr.getDataMapName();
        // get the repositories to be searched on
        String[] selectedRepositories = new String[] {"DB2PAL", "DB2CM"};
        
        // get datamap properties
        Map<String, String> dataMapProps = CMSInst.getDataMapProperties();

        // create hashmap for datamap properties and their values to be searched on
        HashMap<String, String> dataMapPropsValuesHM = new HashMap<String, String>();
        Iterator<String> it = dataMapProps.keySet().iterator();

        while (it.hasNext())
        {
            property = (String) it.next();
            if (property.equals("Name"))
            {
                // set the value for the property
                value = "Mith8";
                dataMapPropsValuesHM.put(property, value);

            }
            else if (property.equals("Item_ID"))
            {
                value = "A1001001A09A10B02729B61702";
                dataMapPropsValuesHM.put(property, value);
            }
            else
            {
                // no other search parameter
                // user can add more search parameters here with more 'else if'
                // cases
            }

        }

        // creating the search query from the hashmap of data map
        // properties to be searched on and their values
        /**
         * In this sample, searchQuery will ultimately have the following string
         * : Name='Mith8' OR Item_Id='' User can directly write a valid search
         * query String and pass it to the search API.
         **/

        String searchQuery = null;
        Iterator<String> itr = dataMapPropsValuesHM.keySet().iterator();
        while (itr.hasNext())
        {
            property = (String) itr.next();
            value = (String) dataMapPropsValuesHM.get(property);

            if (value != "")
            {
                if (searchQuery != null)
                {
                    // here '=' is the operator used. Any other valid operator
                    // of Content Integrator can be used
                    searchQuery = searchQuery + " operation " + property + "='" + value + "'";
                }
                else
                {
                    searchQuery = property + "='" + value + "'";
                }

            }
        }

        // specify whether 'AND' or 'OR' operation to perform
        searchQuery = CMSUtils.replaceString(searchQuery, "operation", "OR");

        // search in selected repositories and get the resultset
        IResultSet irs = CMSInst.search(dataMapName, selectedRepositories, searchQuery);

}
catch (PIMAuthorizationException ae)
{
    // Expected a failure
    System.out.println("Authorization Failure");
    return;
}
catch(IllegalArgumentException iae)
{
    System.out.println(" Passed argument is null or empty ");
    return;
}

catch(PIMInternalException ie)
{
    System.out.println(" Internal Error ");
    return;
}

下一步

現在,您可以將內容管理系統文件與項目相關聯,並檢視內容管理系統中的內容。