Search controls are specifications about how far and how long a search operation should look for a component or folder. The oracle.dss.bicontext.BISearchControls
class embodies the search controls that you can set. The BISearchControls
class allows you to specify the following controls:
The scope of the search -- How deeply you want to search in the namespace
The time precision of the search -- How narrowly you want the time and date to match the search critera
The extent of the search -- Whether the search includes linked objects
The time limit of the search -- The maximum time that the search should run
The size limit of the search -- The maximum number of items that the search result should contain
What the search result contains -- Whether the search result contains the object or only a reference to the component, and also which, if any, attributes that the search result contains.
The following constants specify how deeply in the namespace you want the search to take place. These constants are available in oracle.dss.bicontext.BISearchControls
:
OBJECT_SCOPE
-- The search returns only the named component, and that component only when the component meets the search criteria. Use this scope when you want to know whether the component has a particular attribute value, for example.
ONELEVEL_SCOPE
-- The search returns components in the specified folder only. Use this when you want to know whether a component exists in a folder, or when you want to find components in a folder that have certain attribute values.
SUBTREE_SCOPE
-- The search returns components that meet the search criteria and that are in the specified folder or in any of its subfolders. This search includes subfolders.
ONELEVEL_SCOPE_WITH_FOLDERS
-- The search returns components that meet the search criteria and that are in the specified folder, and it returns all of the subfolders in the specified folder. This is like a ONELEVEL_SCOPE
search plus a search for all subfolders.
SELECTIVE_ONELEVEL_SCOPE
-- The search returns components that meet the search criteria in the specified folder, and it returns any subfolders that contain components that meet the search criteria. This is like a series of ONELEVEL_SCOPE
searches whose results are combined to a single search. Any path that you follow in the search result eventually leads to a component that meets the search criteria.
The following folder structure shows a likely scenario in the BI Beans Catalog.
MyFolder MySalesInfoFolder MyGraphsFolder MySalesBarGraph MySalesPieGraph MyCrosstabFolder MySalesCrosstab MyOperationsInfoFolder MyOperationsCrosstab MyOperationsBarGraph MyTemplateGraph MyTemplateBarGraph
You can specify attributes to refine the search for bar graphs. If you do an OBJECT_SCOPE
search of MyFolder/MyTemplateGraph
, and if MyTemplateGraph
is a bar graph, then the search result enumeration will include:
MyFolder/MyTemplateGraph
If you do a ONELEVEL_SCOPE
search for bar graphs from MyFolder
, then the search result enumeration will include:
MyFolder/MyTemplateGraph MyFolder/MyTemplateBarGraph
If you do a SUBTREE_SCOPE
search for bar graphs from MyFolder
, then the search result enumeration will include:
MyFolder/MySalesInfoFolder/MyGraphsFolder/MySalesBarGraph MyFolder/MyOperationsInfoFolder/MyOperationsBarGraph MyFolder/MyTemplateGraph MyFolder/MyTemplateBarGraph
If you do a ONELEVEL_SCOPE_WITH_FOLDERS
search for a bar graph from MyFolder
, then the search result enumeration will contain search results for:
MyFolder MyFolder/MySalesInfoFolder MyFolder/MyOperationsInfoFolder MyFolder/MyTemplateGraph MyFolder/MyTemplateBarGraph
If you do a SELECTIVE_ONELEVEL_SCOPE
search for a bar graph from MyFolder
, then the search result enumeration will contain search results for:
MyFolder MyFolder/MySalesInfoFolder MyFolder/MyOperationsInfoFolder MyFolder/MyTemplateGraph MyFolder/MyTemplateBarGraph
To use search controls to refine a search operation, you create a BISearchControls
object. You call methods on the BISearchControls
to set the controls as you want them. Then you pass the BISearchControls
to a search method that takes a SearchControls
as an argument.
The following code searches for any folders that contain bar graphs, starting the search in a folder named MyFolder
. This example uses SELECTIVE_ONELEVEL_SCOPE
.
//pmRoot is the InitialPersistenceManager BasicAttributes _attrs = new BasicAttributes(); _attrs.put(PSRConstants.Attributes.OBJECT_TYPE, PSRConstants.GRAPH); _attrs.put(Graph.GRAPH_TYPE, Graph.convertGraphTypeToString(Graph.BAR_VERT_CLUST)); BISearchControls _search = new BISearchControls(); _search.setSearchScope(BISearchControls.SELECTIVE_ONELEVEL_SCOPE); NamingEnumeration results = null; try{ results = pmRoot.search("", _attrs, _search); } catch(NamingException ne){ ne.printStackTrace(); }