IBM Enterprise Records, Version 5.1.2    

Executing an ad hoc search

To perform an ad hoc search, you use the RMSearch interface, which extends the Search interface in the Content Java™ API.

The following code snippet shows how to get an RMSearch object.
// Obtains the RMSearch object for executing the search operation 
RMSearch getRMSearch(String asObjectStoreName, Session aoSession) 
{ 
   try 
   { 
      ObjectStore loStore = ObjectFactory.getObjectStore (asObjectStoreName, aoSession);

      // creates an object of RMObjectStore
      RMObjectStore loRMStore = new RMUtil().getRMObjectStore(loStore);
      return loRMStore.getRMSearch(); 
   } 
  
   catch (RMException aoRME)
   { 

   } 
}
After obtaining an RMSearch object, you can use the following methods for performing an ad hoc search:
  • executeXML
  • singleObjectTypeExecuteXML

Both methods initiate the search process and return an XML string representation of objects that match the search criteria. In the executeXML method, you pass three parameters: asSearchRequestXML, asContentSearchWhereClause, and asOperator.

The following table provides a description of these parameters.

Parameter Description
asSearchRequestXML Contains an XML string representation, which is used for searching the metadata values. If you are performing a content-based search, this parameter contains only ID and aggregation values. This parameter cannot be null.
asContentSearchWhereClause Contains a string, which is used for the content-based search in the Record Object Store (ROS). For a metadata search, this parameter is null.
asOperator Contains an operator to merge the metadata or content-based search on the File Plan Object Store (FPOS) and the content-based search on the ROS. Constants that are supported are defined in RMSearch. This parameter cannot be null if the asContentSearchWhereClause is provided.

In the singleObjectTypeExecuteXML method, in addition to those three parameters, you pass one more parameter representing the RM object type that you search for.

Parameter Description
aiObjectType This parameter represents the RM Object Type that you search for. It can be either a Document, Folder or the CustomObject.

Performing the metadata search

The following code fragment performs the metadata search by calling the executeXML method. In this code fragment, you create an XML string to retrieve the record folder specified in the query statement.
// Performs the metadata search in an object store
void searchMetadataOnly(RMObjectStore aoRMOS)
{
   try
   {
      searchRequestXML = "<?xml version=\"1.0\" encoding=\"UTF-8
          \"?>"+ "<request><objectstores ><objectstore
          id='Test_PRO_12032004_1'/></objectstores><querystatement 
          tablealias='d'>SELECT d.ObjectType, d.Id , d.isReserved, 
          d.VersionStatus, d.OIID, d.MinorVersionNumber, d.MimeType, 
          d.DocumentTitle, d.Creator, d.Id, d.ContentSize, 
          d.LastModifier, d.DateLastModified, d.MajorVersionNumber, 
          d.IsCurrentVersion from RecordInfo d where (Id = 
          {9DA3E6E4-5CBB-4FC4-9531-EF271DE403A0} ) 
          </querystatement>"+ "<options maxrecords='100' 
          objectasid=\"false\"/></request>";
          
          RMSearch loRMSearch = aoRMOS.getRMSearch();
      String actualReturn = loRMSearch.singleObjectTypeExecuteXML(searchRequestXML, 
             null, null, RMObject.TYPE_FOLDER);
   }
   catch(Exception aoEx)
   {
   }
}

Performing both metadata and content search

Using the RMSearch interface, you can also perform both metadata and content search in an object store, as shown in the following code fragment.
// Performs both  metadata and content search in an object store
void searchMetadataAndContent(RMObjectStore aoRMOS)
{
   try
   {
      searchRequestXML = "<?xml version=\"1.0\" encoding=\"UTF-8
          \"?>"+ "<request><objectstores ><objectstore
          id='Test_PRO_12032004_1'/></objectstores><querystatement 
             tablealias='d'>SELECT d.ObjectType, d.Id , d.isReserved, 
          d.VersionStatus, d.OIID, d.MinorVersionNumber, d.MimeType, 
          d.DocumentTitle, d.Creator, d.Id, d.ContentSize, d.LastModifier, 
          d.DateLastModified, d.MajorVersionNumber, d.IsCurrentVersion from RecordInfo 
          d where (Id = {9DA3E6E4-5CBB-4FC4-9531-EF271DE403A0} ) 
          </querystatement>"+ "<options maxrecords='100' 
      objectasid=\"false\"/></request>";
          
          String lsContentCriteria = "(CONTAINS(content, '&lt;NEAR&gt;(create)'))";
      RMSearch loRMSearch = aoRMOS.getRMSearch();
      String actualReturn = loRMSearch.singleObjectTypeExecuteXML(searchRequestXML, 
             lsContentCriteria, RMSearch.moAND_OPERATOR, RMObject.TYPE_DOCUMENT);
        }
        catch(Exception aoEx)
        {
        }
}


Feedback

Last updated: November 2013
ierdg038.htm

© Copyright IBM Corporation 2013