Performing a search operation
Many operations support acting on one or more items in an Encyclopedia volume. To target the items on which to act, you must apply a search condition to the operation. The Actuate Information Delivery API library contains many special classes for setting a search condition and implementing a search for an item in an Encyclopedia volume.
The Actuate Information Delivery API provides three sets of parameters that support searching for the data on which an operation acts. Typically, these parameters apply to operations that select, update, move, copy, or delete Encyclopedia volume items. The parameters are:
*Id or IdList
*Name or NameList
*Search
Use SelectFiles to retrieve file properties using the ID or name of a single file or folder, or a list of files or folders, in an Encyclopedia volume. SelectFiles can recursively search all subfolders in a directory. To restrict a search to the items in a single directory, not including subfolders, use GetFolderItems. SelectFiles does not retrieve file or folder content. SelectFiles supports three types of searches:
*Use Name or Id to retrieve a single file or folder.
*Use NameList or IdList to retrieve a list of files or folders in a directory.
*Use Search to retrieve all files or folders that match a given condition.
The following application derives from the code in the BIRT iHub Integration Technology example applications for the MS .NET Client. In the example application, AcSelectFiles specifies a search condition and performs the following operations:
*Specifies a search condition for the file type using the wildcard, *, to target all files that contain the character, R, as the first character in the file extension
namespace Actuate
{
class AcSelectFiles
{
string fileType = "R*";
A wildcard is a character used in a search or conditional expression that matches one or more literal characters. Actuate wildcards include the ones in the following list:
*? matches any single one- or two-byte character.
*# matches any ASCII numeric character [0-9].
** matches any number of characters.
The wildcard expression in the example targets files in BIRT iHub such as a BIRT executable file with the file extension RPTDESIGN, and a BIRT document file with the file extension RPTDOCUMENT.
*Instantiates a FileCondition object, setting the condition to match on FileField.FileType using the wildcard expression
static void SearchByCondition (string fileType)
{
Server_Proxy.localhost.SelectFiles l_req = new
SelectFiles( );
FileCondition l_fileCondition = new FileCondition( );
l_fileCondition.Field = FileField.FileType;
l_fileCondition.Match = fileType;
*Instantiates a FileSearch object, setting the search to the properties specified in the FileCondition object
FileSearch l_fileSearch = new FileSearch( );
l_fileSearch.Item = l_fileCondition;
An application sets the search condition for a file using the FileSearch class. FileSearch is a complex data type that contains the list of properties to specify in a file search condition.
An application can specify the search condition for a file using one or more of the following fields:
*Name
*FileType
*Description
*PageCount
*Size
*TimeStamp
*Version
*VersionName
*Owner
Use ArrayOfFileCondition to specify multiple search conditions.
*Specifies the fetch handle and SelectFilesResponse object for processing the results
l_fileSearch.FetchSize = 1;
l_fileSearch.FetchSizeSpecified = true;
SelectFilesResponse l_res;
*Makes the selectFiles( ) proxy call, obtaining the reference to the SelectFilesResponse object
do
{
try
{
l_res = l_proxy.selectFiles(l_req);
}
catch(Exception e)
{
PrintExceptionDetails(e);
return;
}
A fetch handle indicates that the number of items in the result set exceeds the fetch size limit. A fetch handle returns as a parameter in the response to a Select or Get request, such as SelectFiles or GetFolderItems.
Use the fetch handle to retrieve more results from the result set. In the second and subsequent calls for data, you must specify the same search condition that you used in the original call. All Get and Select requests, except SelectFileType, support the use of a fetch handle.
*Continues processing until there are no more results, printing an appropriate output message
File[ ] l_fileList = (File[ ]) l_res.Item;
if (l_fileList != null)
{
for(int i = 0; i < l_fileList.Length; i++)
{
Console.WriteLine();
Console.WriteLine("Item " + i + " Id:" +
l_fileList[i].Id);
Console.WriteLine("Item " + i + " Name:" +
l_fileList[i].Name);
Console.WriteLine("Item " + i + " Owner:" +
l_fileList[i].Owner);
Console.WriteLine("Item " + i + " Description:" +
l_fileList[i].Description);
Console.WriteLine("Item " + i + " File Type:" +
l_fileList[i].FileType);
Console.WriteLine("Item " + i + " File Size:" +
l_fileList[i].Size);
}
}
l_fileSearch.FetchHandle = l_res.FetchHandle;
} while(l_res.FetchHandle != null);