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.
//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; }
// Executes a stored search BaseObjects executeStoredSearch(RMStoredSeach aoStoredSearch, String asExecuteDataXML) { return aoStoredSearch.execute(asExecuteDataXML) }
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 Engine Stored Search XML Schema. In the executeXML method, you pass the asExecuteDataXML parameter, which is an XML string representation of a StoredSearch object.
// Sets up a string variable to pass search criteria executeStoredSearch(RMStoredSearch aoStoredSearch) { String mySearchData = "<executedata xmlns=\"http://filenet.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; }