Searching for Objects

You use the following classes when you search for objects in the BI Beans Catalog:

How to search for an object

To search for an object, you call one of the search methods of a folder in which you expect to find the object. To search the entire namespace, call the search method of the InitialPersistenceManager or of the MDRoot, using a SUBTREE_SCOPE.

The search methods take an implementation of the Attributes interface as an argument. The javax.naming.directory.BasicAttributes class implements the Attributes interface. You store the attributes for which you want to search in a javax.naming.directory.BasicAttribute class, which you then store in the BasicAttributes class. To define the search more narrowly, you add more attributes. For example, if you want to search only for graphs that were modified by a particular user, then set both the OBJECT_TYPE attribute and the MODIFIED_BY attribute.

You pass the BasicAttributes to the search method of the folder in which you expect to find the component. The NamingEnumeration that the search method returns will contain SearchResults only for the components whose attributes match the specified Attributes.

If you do not want to limit your search to components that have particular attributes, then you pass an empty BasicAttributes to the search method.

Definition: Attribute

An attribute is a characteristic of a folder or of a component. Each attribute includes an attribute name and an attribute value. For example, each component has an OBJECT_TYPE attribute. The attribute consists of the attribute name (OBJECT_TYPE) and an attribute value, such as GRAPH.

Example: Searching for bar graphs

The following code uses the persistence service to search for bar graphs in a folder MyGraphsFolder. MyGraphsFolder is in a folder named MySalesInfoFolder, which is in a folder named MyFolder. This example calls the search method of the context for MyFolder.


//ctxMyFolder is the PersistenceManager or the MDFolder for MyFolder BasicAttributes _attrs = new BasicAttributes(); _attrs.put(PSRConstants.Attributes.OBJECT_TYPE, PSRConstants.GRAPH); _attrs.put(Graph.GRAPH_TYPE,   Graph.convertGraphTypeToString(Graph.BAR_VERT_CLUST)); NamingEnumeration results = null; SearchResult foundGraph = null; Vector graphs = new Vector(); try{   results = ctxMyFolder.search("MySalesInfoFolder/MyGraphsFolder", _attrs);   while (results.hasMore){      graphs.addElement(results.getObject());      } } catch(NamingException ne){   ne.printStackTrace(); }