IBM Enterprise Records, Version 5.1.2    

Executing a stored search

To perform a stored search, you first retrieve an RMStoredSearch object and then call its execute and executeXML methods. In these methods, the search criteria can differ depending on the search type.

For a user-defined search, search criteria can consist of additional template data, extra properties, and a value for maximum results. However, for a predefined search, the criteria include only extra properties and a value for maximum results. This section discusses how to retrieve an RMStoredSearch object and use the execute and executeXML methods to perform the stored search.

Retrieving an RMStoredSearch object

To retrieve an RMStoredSearch object, you pass the name of the Content Java™ API StoredSearch object in the getStoredSearchByName method. The following code fragment retrieves an RMStoredSearch object:
//Retrieves an RMStoredSeach object by passing the name of the StoredSearch object 
RMStoredSearch getStoredSearchByName(RMObjectStore aoRMOS, String asName) throws
   PropertyNotFoundException, RMException 
{ 
   RMStoredSearches loStoredSearches = aoRMOS.getRMStoredSearches(null, null); 
   RMStoredSearch loSearch = 
      (RMStoredSearch)loStoredSearches.filterByProperty(RMProperty.DOCUMENT_TITLE,  
          PropertyDescriptions.IS_EQUAL, asName).get(0); 
   return loSearch; 
}
After obtaining an RMStoredSearch object, you can use the following methods for performing a stored search:

Using the execute method

The execute method returns a collection of BaseObject objects that match the search criteria specified in a query string. In this method, you pass the asExecuteDataXML parameter, which is an XML string representation of a StoredSearch object. The method signature for the execute method is shown in the following code:
// Executes a stored search 
BaseObjects executeStoredSearch(RMStoredSeach aoStoredSearch, String asExecuteDataXML) 
{ 
   return aoStoredSearch.execute(asExecuteDataXML) 
} 
 

Using the executeXML method

The executeXML method returns a string containing an XML representation of objects that match the search criteria. The returned XML string is formatted according to the Content Platform Engine Stored Search XML Schema. In the executeXML method, you pass the asExecuteDataXML parameter, which is an XML string representation of a StoredSearch object.

For example, the following fragment calls the executeXML method, which contains a string variable as the search criteria.
// Sets up a string variable to pass search criteria 
executeStoredSearch(RMStoredSearch aoStoredSearch)
{ 
   String mySearchData = "<executedata 
   xmlns=\"http://www.ibm.com/namespaces/wcm/apps/1.0\"><version 
   dtd=\"3.0
   \"/><objecttypesdata><objecttypedata><templatedata><templateverityitems><templateverityitem 
   itemid=\"2\"><verityitemdata><verityunit 
   wordvariation=\"stem\">test</verityunit></verityitemdata></templateverityitem></templateverityitems></templatedata><from><class 
   symname=\"document\"/></from></objecttypedata></objecttypesdata></executedata>"; 

   // Executes the stored search 
   String resultString = aoStoredSearch.executeXML(mySearchData); Return resultString;
}


Feedback

Last updated: November 2013
ierdg040.htm

© Copyright IBM Corporation 2013