Interface Search
- All Superinterfaces:
Remote
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
|
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
|
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
|
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddFilter(SearchFilter filter) Method to specify a search filter to use in this search.List<SearchFilter> Getter to retrieve the filters used for this searchIf a folder was specified for scoping this search, the getter returns the folders path Url.Returns the repository being searched.Returns the ResultDetails instance used when retrieving the objects from the server.List<PublicObjectInterface> Get the search results for this search.Returns the ServerInterface instance used when retrieving the objects from the server.booleanReturns the boolean value that tells us if we are recursively searching in subfolders when doing a folder search.voidremoveFilter(SearchFilter filter) Removes a filter currently being used for the search.List<PublicObjectInterface> search()Search the server using the provided search criteria that was set.voidsetFolderScope(PathUrl pathUrl, boolean recurse) If we are searching within the scope of a folder, set the folder path Url to search from.voidSets the repository to search within.voidsetValidateCriteria(boolean validate) Allows caller to specifically ignore validating the search criteria and just do the search to the server with the given criteria.
-
Method Details
-
getServer
Returns the ServerInterface instance used when retrieving the objects from the server.- Returns:
- ServerInterface instance
- Throws:
RemoteException- in the event of remote object failure.
-
search
Search the server using the provided search criteria that was set.- Returns:
- a Unmodifiable list of PublicObjectInterface objects
- Throws:
ServiceException- if repository errors occur.RemoteException- in the event of remote object failure.
-
getResultDetails
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:
RemoteException- in the event of remote object failure.
-
addFilter
Method to specify a search filter to use in this search.- Parameters:
filter-- Throws:
RemoteException- in the event of remote object failure.
-
removeFilter
Removes a filter currently being used for the search.- Parameters:
filter-- Throws:
RemoteException- in the event of remote object failure.
-
getFilters
Getter to retrieve the filters used for this search- Returns:
- List of SearchFilter filters
- Throws:
RemoteException- in the event of remote object failure.
-
setFolderScope
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 URLrecurse- - true or false. Recursively search through subfolders.- Throws:
RemoteException- in the event of remote object failure.
-
getFolderScope
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:
RemoteException- in the event of remote object failure.
-
isFolderSearchRecursive
boolean isFolderSearchRecursive() throws RemoteExceptionReturns 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:
RemoteException- in the event of remote object failure.
-
setRepository
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:
RemoteException- in the event of remote object failure.
-
getRepository
Returns the repository being searched.- Returns:
- repository
- Throws:
RemoteException- in the event of remote object failure.
-
getSearchResults
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:
RemoteException- in the event of remote object failure.
-
setValidateCriteria
void setValidateCriteria(boolean validate) throws RemoteException Allows caller to specifically ignore validating the search criteria and just do the search to the server with the given criteria. Default is true, validate- Parameters:
validate- - flag (true or false)- Throws:
RemoteException- in the event of remote object failure.
-