Package com.sas.services.information.search

# Interface SearchFolder

All Superinterfaces:
  `MetadataInterface`, `PublicObjectContainerInterface`, `PublicObjectInterface`, `Remote`

public interface SearchFolder extends MetadataInterface, PublicObjectContainerInterface
The SearchFolder class is a "smart" object for metadata searches. It is used to save a search's details to metadata and also for retrieving those search details from the metadata. This interface is used to describe the SearchFolder actions and processes.

The SearchFolder is created using the SearchFactory createSearchFolder() methods. There are 2 signatures for this method. The first signature creates the SearchFolder with a new default Search. In the second signature, the user passes in an existing Search to associate to this SearchFolder. The Search is used to define and run a search. For more details, see: Examples of creating and using a Search object

The following is an example of creating a SearchFolder smart object from an existing Search object:

      Search search = SearchFactory.createSearch(server);  //where "server" is the ServerInterface
       .
       .  //Assumes you populated and ran the search in this Search class
       .
       .

      //Setup to save this SearchFolder in the "My Folder" folder in the SAS folders tree.
      String path = "/Users/sasadm/My Folder(Folder)";
      PathUrl pathURL = PathUrl.newPathUrlFromAbsolutePath(server, path);
      FolderInterface folder = (FolderInterface)server.getObjectByPath(pathURL);

      //create SearchFolder named "Searcher1" in the "My Folder" folder.
      SearchFolder mySearchFolder = SearchFactory.createSearchFolder("Searcher1", folder, search);

      //Set an optional description on the SearchFolder smart object
      mySearchFolder.setDescription("Searcher1 is a search of all public types by Object Name (Sample)");

      //Add optional keywords to the SearchFolder smart object
      ArrayList keywords = new ArrayList();
      keywords.add("NameSearch");   //created a keyword for this object
      mySearchFolder.setKeywords(keywords);

      mySearchFolder.update();  //Method to commit the SearchFolder object to metadata

The following is an example of retrieving an existing SearchFolder and simply displaying the object results (Name, Type, and Metadata object id):

       //Query a SearchFolder named "MySearch" from the metadata (assume this is saved).
       //findSearchFolder() is a testing method that just queries for the smart object using
       //the informationService.search() method.  Is is used for this example only and we assume the
       //user will query for the existing SearchFolder object as they see fit.
       SearchFolder searchObj = findSearchFolder(informationService, user, "MySearch");

       //Will retrieve the search results for the saved search.  It will run the search if the results
       //are not already in memory.
       List searchResults = searchObj.getSearchResults();

       try {
            System.err.println("Retrieve Search Results");
            System.err.println("=======================");
            for (PublicObjectInterface sobj : searchResults) {
                                    System.err.println("Name:  " + sobj.getName());
                                    System.err.println("Type:  " + sobj.getTypeDescriptor().getTypeName());
                                    System.err.println("Id:  " + sobj.getIdentifier())
                                    System.err.println("  ");
                    }
             }
             catch (Exception e)
             {
                    String errmsg = "Error printing search results.  Exception:" + e.getMessage();
                    System.err.println(errmsg);
             }

The following is an example of retrieving an existing SearchFolder, changing some search criteria, rerunning the search and simply displaying the object results (Name, Type, and Metadata object id):

       //Query a SearchFolder named "MySearch" from the metadata (assume this is saved).
       //findSearchFolder() is a testing method that just queries for the smart object using
       //the informationService.search() method.  Is is used for this example only and we assume the
       //user will query for the existing SearchFolder object as they see fit.
       SearchFolder searchObj = findSearchFolder(informationService, user, "MySearch");

             Search search = searchObj.getSearch();

       //Change that we only want to see the first 10 resulting object
       search.getResultDetails().setResultLimit(10);

       //Assume we were searching all Public Types in the saved search.  Now we just want
       //to search for Job and Library types.
       List objectTypes = new ArrayList();
       objectTypes.add("Job");
       objectTypes.add("Library");
       PublicTypeFilter typeFilter = new PublicTypeFilter(objectTypes);

       //add the typeFilter to this search's filter list
       search.addFilter(typeFilter);

       //Rerun modified search from Search object
       List searchResults = search.search();

       try {
            System.err.println("Retrieve 10 Search Results");
            System.err.println("==========================");
            for (PublicObjectInterface sobj : searchResults) {
                                    System.err.println("Name:  " + sobj.getName());
                                    System.err.println("Type:  " + sobj.getTypeDescriptor().getTypeName());
                                    System.err.println("Id:  " + sobj.getIdentifier())
                                    System.err.println("  ");
                    }
             }
             catch (Exception e)
             {
                    String errmsg = "Error printing search results.  Exception:" + e.getMessage();
                    System.err.println(errmsg);
             }

       //If you want to save these search updates call update method.
       try {
          searchObj.update();
       }
       catch (Exception e)
       {
            String errmsg = "Error saving smart object.  Exception:" + e.getMessage();
            System.err.println(errmsg);
       }

You can also use the standard information service methods to create smart objects, including this SearchFolder, but it is up to the user to understand how to do this and to make sure they set all required information to create a valid and useable SearchFolder.

- ## Field Summary

  ### Fields inherited from interface com.sas.services.information.metadata.MetadataInterface

  `METADATA_STATE_DELETED, METADATA_STATE_DESTROYED, METADATA_STATE_NEW, METADATA_STATE_NORMAL, PERMISSION_READMETADATA, PERMISSION_WRITEMETADATA`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Search`
  `getSearch()`
  Retrieve the Search object which drives the search for this SearchFolder.
  `List<PublicObjectInterface>`
  `getSearchResults()`
  Retrieve the search results from metadata.
  `List<PublicObjectInterface>`
  `search()`
  Run an existing search from this SearchFolder.

  ### Methods inherited from interface com.sas.services.information.metadata.MetadataInterface

  `add, addAccessControl, addAttribute, addAttributes, addDocument, addExtension, addGroup, addImplementor, addKeyword, addNoteTextStore, addNoteTextStore, addObjectProperty, addObjectProperty, addPermissions, addPrompt, addPropertySet, addRemark, addResponsibleParty, addTransactionListener, addUsedByPrototype, checkin, checkout, commit, copyTo, countAssociatedObjects, delete, deleteAttribute, deleteAttributes, destroy, getAccessControls, getAttribute, getAttributes, getAuthorizationUtil, getCreateDate, getCreatedBy, getDescription, getDocuments, getEntityKey, getEntityURL, getExtensions, getGroups, getGUID, getIdentities, getImplementors, getKeywords, getLockedBy, getModifiedBy, getModifyDate, getNoteTextStore, getNoteTextStores, getNoteTextStoresByRole, getObjectProperties, getParent, getParentPath, getParents, getPath, getPaths, getPermission, getPermissions, getPermissions, getPreviousVersionNames, getPrimaryPropertyGroup, getPrompt, getPrompts, getPropertyBag, getPropertySets, getRemarksList, getReposId, getRepository, getRepositoryEntity, getRepositoryName, getReposKey, getResponsibleParties, getState, getTrackingId, getType, getUsageVersion, getUsedByPrototypes, getUsingPrototype, getVersion, isAuthorized, isCompatible, isDeleted, isDestroyed, isObjectAlive, isReadCompatible, mapNameToFilesystem, mapUrlToFilesystem, moveTo, newServiceObject, refresh, removeAccessControl, removeDocument, removeExtension, removeGroup, removeImplementor, removeKeyword, removeNoteTextStore, removeObjectProperty, removePermissions, removePrompt, removePropertySet, removeResponsibleParty, removeResponsiblePartyByIdentity, removeUsedByPrototype, rollback, setAttribute, setAttributes, setDeleted, setDescription, setDocuments, setExtensions, setGroups, setGUID, setKeywords, setName, setNoteTextStores, setObjectProperties, setPermission, setPrimaryPropertyGroup, setPrompt, setPrompts, setRemarksList, setRepository, setUsingPrototype, startTransaction, toByteArray, transactionEvent, uncheckout, update, updateFromBag, version`

  ### Methods inherited from interface com.sas.services.information.publicobject.PublicObjectContainerInterface

  `getChildAt, getChildCount, getChildren, getChildren, newChild`

  ### Methods inherited from interface com.sas.services.information.publicobject.PublicObjectInterface

  `addProcessorInterface, getContainer, getIdentifier, getName, getObjectURI, getPathUrl, getProcessorInterface, getTypeDescriptor`

- ## Method Details

  - ### getSearchResults

    List<PublicObjectInterface> getSearchResults() throws ServiceException, RemoteException
    Retrieve the search results from metadata.
    Returns:
      matched objects. May be null if no search has been performed. The returned list is not modifiable.
    Throws:
      `ServiceException` - for any service related failure in this method
      `RemoteException` - for RMI network errors

  - ### getSearch

    Search getSearch() throws ServiceException, RemoteException
    Retrieve the Search object which drives the search for this SearchFolder.
    Returns:
      Search, It contains all required elements of the search.
    Throws:
      `ServiceException` - for any service related failure in this method
      `RemoteException` - for RMI network errors

  - ### search

    List<PublicObjectInterface> search() throws ServiceException, RemoteException
    Run an existing search from this SearchFolder. Returns latest search results.
    Throws:
      `ServiceException` - for any service related failure in this method If a ServiceException is thrown, you must perform a rollback to close the transaction.
      `RemoteException` - in the event of remote object failure.