com.sas.services.information.search
Interface Search

All Superinterfaces:
java.rmi.Remote

public interface Search
extends java.rmi.Remote

The Search can be used to manage and perform searches for public objects in metadata. Searches are defined using search filters, folder scoping, and output manipulation settings i.e the result details. (attributes returned, sorting results, result limits).

You can search for public types in the metadata server that match specified search filters or you can scope the search to be within a specified folder in the SAS Folders tree. You can indicate if the search includes subfolders when doing a folder search or just within the folder specified.

The Search is created using the SearchFactory createSearch() method. If the search does not find any matched results, the user is returned an empty list.

The following is an example of using Search to search for all public objects in the metadata server that contain the name "Sample":
   Search search = SearchFactory.createSearch(server);  //where "server" is the ServerInterface  
   
   //create the name filter and have it search for the name in the description field as well.
   ObjectNameFilter nameFilter = new ObjectNameFilter("Sample", true);
   
   //add the nameFilter to the search filters used in Search
   search.addFilter(nameFilter);

   //Only show the first 100 objects that match the search from all the results
   //returned from the server.  If the server returns more than 100 matching objects we
   //limit what we see in the client to the first 100 in this example.
   search.getResultDetails().setResultLimit(100);
   
   //run the search, return a list of PublicObjects that search found.
   List searchResults = search.search();  
 

The following is another example of using Search to search for all public objects, however this time we are searching within a folder, using multiple filters (Search by Name and by Dates):
   Search search = SearchFactory.createSearch(server);  //where "server" is the ServerInterface  
   
   //create the name filter and have it search for the name.
   ObjectNameFilter nameFilter = new ObjectNameFilter("Sample", false);
   
   //Search for objects that were created between January 1, 2009 and December 15, 2009
   Calendar cMin = Calendar.getInstance();
   cMin.setTimeZone(TimeZone.getTimeZone("GMT"));
   cMin.set(Calendar.YEAR, 2009);
   cMin.set(Calendar.MONTH, Calendar.JANUARY);
   cMin.set(Calendar.DAY_OF_MONTH, 1);
   
   Calendar cMax = Calendar.getInstance();
   cMax.setTimeZone(TimeZone.getTimeZone("GMT"));
   cMax.set(Calendar.YEAR, 2009);
   cMax.set(Calendar.MONTH, Calendar.December);
   cMax.set(Calendar.DAY_OF_MONTH, 15);
   
   DateFilter dateFilter = new DateFilter(DateType.CREATED_DATE, cMin.getTime(), cMax.getTime());
   
   //add the nameFilter and dateFilter to the search filters used in Search 
   search.addFilter(nameFilter);
   search.addFilter(dateFilter);

   //Change the sort order for the objects returned from the search so that they are 
   //sorted by Type and then Name instead of by Name and then Type, which is the default. 
   SortOrder[] order = {SortOrder.TYPE, SortOrder.NAME, SortOrder.CREATED_DATE};
   search.getResultDetails().setSortOrder(order);
   
   //Search within the "/Products/SAS Intelligence Platform" folder in the SAS folders tree
   String path = "/Products/SAS Intelligence Platform(Folder)";
   PathUrl pathURL = PathUrl.newPathUrlFromAbsolutePath(server, path);
   
   //Pass "true" to search in all subfolders as well
   search.setFolderScope(pathURL, true);
   
   //run the search, return a list of PublicObjects that search found.
   List searchResults = search.search();  
 

Finally, here is another example of using Search to search for specific public objects, searching within a folder and using multiple search filters. (Search by Name and by Job and Library Types):
   Search search = SearchFactory.createSearch(server);  //where "server" is the ServerInterface
   
   //create the name filter and have it search for the name.
   ObjectNameFilter nameFilter = new ObjectNameFilter("Sample", false);
   
   //Set Public Types to search for (only Job and Library).
   List objectTypes = new ArrayList(); 
   objectTypes.add("Job");
   objectTypes.add("Library");
   PublicTypeFilter typeFilter = new PublicTypeFilter(objectTypes);
   
   //add the nameFilter and typeFilter to the search filters used in search 
   search.addFilter(nameFilter);
   search.addFilter(typeFilter);
   
   //Search within the "/Products/SAS Intelligence Platform" folder in the SAS folders tree
   String path = "/Products/SAS Intelligence Platform(Folder)";
   PathUrl pathURL = PathUrl.newPathUrlFromAbsolutePath(server, path);
   
   //Pass "true" to search in all subfolders as well
   search.setFolderScope(pathURL, true);
   
   //run the search, return a list of Job and Library PublicObjects that search found.
   List searchResults = search.search();  
 


Method Summary
 void addFilter(SearchFilter filter)
          Method to specify a search filter to use in this search.
 java.util.List<SearchFilter> getFilters()
          Getter to retrieve the filters used for this search
 PathUrl getFolderScope()
          If a folder was specified for scoping this search, the getter returns the folders path Url.
 OMIRepositoryInterface getRepository()
          Returns the repository being searched.
 ResultDetails getResultDetails()
          Returns the ResultDetails instance used when retrieving the objects from the server.
 java.util.List<PublicObjectInterface> getSearchResults()
          Get the search results for this search.
 ServerInterface getServer()
          Returns the ServerInterface instance used when retrieving the objects from the server.
 boolean isFolderSearchRecursive()
          Returns the boolean value that tells us if we are recursively searching in subfolders when doing a folder search.
 void removeFilter(SearchFilter filter)
          Removes a filter currently being used for the search.
 java.util.List<PublicObjectInterface> search()
          Search the server using the provided search criteria that was set.
 void setFolderScope(PathUrl pathUrl, boolean recurse)
          If we are searching within the scope of a folder, set the folder path Url to search from.
 void setRepository(OMIRepositoryInterface repos)
          Sets the repository to search within.
 

Method Detail

getServer

ServerInterface getServer()
                          throws java.rmi.RemoteException
Returns the ServerInterface instance used when retrieving the objects from the server.

Returns:
ServerInterface instance
Throws:
java.rmi.RemoteException - in the event of remote object failure.

search

java.util.List<PublicObjectInterface> search()
                                             throws ServiceException,
                                                    java.rmi.RemoteException
Search the server using the provided search criteria that was set.

Returns:
a Unmodifiable list of PublicObjectInterface objects
Throws:
ServiceException - if repository errors occur.
java.rmi.RemoteException - in the event of remote object failure.

getResultDetails

ResultDetails getResultDetails()
                               throws java.rmi.RemoteException
Returns the ResultDetails instance used when retrieving the objects from the server. If the instance does not exist, it is created and returned

Returns:
result details instance
Throws:
java.rmi.RemoteException - in the event of remote object failure.

addFilter

void addFilter(SearchFilter filter)
               throws java.rmi.RemoteException
Method to specify a search filter to use in this search.

Parameters:
filter -
Throws:
java.rmi.RemoteException - in the event of remote object failure.

removeFilter

void removeFilter(SearchFilter filter)
                  throws java.rmi.RemoteException
Removes a filter currently being used for the search.

Parameters:
filter -
Throws:
java.rmi.RemoteException - in the event of remote object failure.

getFilters

java.util.List<SearchFilter> getFilters()
                                        throws java.rmi.RemoteException
Getter to retrieve the filters used for this search

Returns:
List of SearchFilter filters
Throws:
java.rmi.RemoteException - in the event of remote object failure.

setFolderScope

void setFolderScope(PathUrl pathUrl,
                    boolean recurse)
                    throws java.rmi.RemoteException
If we are searching within the scope of a folder, set the folder path Url to search from.
Also indicate if we should search in subfolders when doing a folder search or just within the folder specified.

Parameters:
pathUrl - - the folder path URL
recurse - - true or false. Recursively search through subfolders.
Throws:
java.rmi.RemoteException - in the event of remote object failure.

getFolderScope

PathUrl getFolderScope()
                       throws java.rmi.RemoteException
If a folder was specified for scoping this search, the getter returns the folders path Url.

Returns:
PathUrl for the folder selected to search within.
Throws:
java.rmi.RemoteException - in the event of remote object failure.

isFolderSearchRecursive

boolean isFolderSearchRecursive()
                                throws java.rmi.RemoteException
Returns the boolean value that tells us if we are recursively searching in subfolders when doing a folder search.

Returns:
the boolean value, true means recurse, false no recurse
Throws:
java.rmi.RemoteException - in the event of remote object failure.

setRepository

void setRepository(OMIRepositoryInterface repos)
                   throws java.rmi.RemoteException
Sets the repository to search within. This method should be used when the client doesn't want to search across an entire server or a particular folder.

Note, this is only valid when a folder has not already been specified as well.

Parameters:
repos - the repository to search within
Throws:
java.rmi.RemoteException - in the event of remote object failure.

getRepository

OMIRepositoryInterface getRepository()
                                     throws java.rmi.RemoteException
Returns the repository being searched.

Returns:
repository
Throws:
java.rmi.RemoteException - in the event of remote object failure.

getSearchResults

java.util.List<PublicObjectInterface> getSearchResults()
                                                       throws java.rmi.RemoteException
Get the search results for this search.

Returns:
matched objects list. May be an empty list if no search has been performed or no matching results are found.. The returned list is not modifiable.
Throws:
java.rmi.RemoteException - in the event of remote object failure.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.