Searching the content management system

You can search the content management system by using the pre-configured metadata in the data map. You can search on multiple configured content management systems by using a data map. When you search the content management system, you are able to locate and select a particular content to be associated with an IBM® InfoSphere® Master Data Management Collaboration Server - Collaborative Edition item or category.

Before you begin

  1. Install and configure IBM Content Integrator.
  2. Configure the content management system by using the configuration file.
  3. Define a spec.
  4. Add an external content reference type attribute to the spec.

Procedure

Search the content management system. Use either of the following methods: user interface or Java™ API.
Option Description
User interface
  1. Open an item or category in the Single Edit screen using one of the following ways:
    1. Click an item or category in the pane navigation.
    2. Open an item to edit from the Item View screen.
    3. Select a step from the collaboration area.
  2. Click the search icon next to an external content reference attribute on the Single Edit screen. The Search screen opens.
  3. Select at least one repository to perform your search on. Choose AND or OR search criteria.
  4. Provide values for the search attributes, and click Search. The search results display in the same screen.
  5. Select a search result to display the content properties, the content versions, all items that reference this content or if the content is an image type, a thumbnail preview. Click Associate Document to associate that content with the external content reference attribute of the item. You can also select a version in the Versions tab and click Associate Document to associate that version of the content with the external content reference attribute of the item.
Java API The following sample Java API code searches the content management system by using the CMSManager and CMSInstance Java interfaces.
Note: The following two statements should not be called repeatedly in a Java API.
CMSManager CMSMgr = ctx.getCMSManager();
    CMSInstance CMSInst = CMSMgr.getCMSInstance();
Otherwise, this might lead to OutOfMemory or an increase in the number of applications that are connecting to the Content Management System from collaborative MDM. The following sample code uses these statements correctly.
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;
}

What to do next

Now you can associate a content management system document to an item and view content in the content management system.