In order to use QueryBuilder, you must add it to an application and run the application. During design, you can run an application to create selections that you save in the BI Beans Catalog. At runtime, you can allow users to create a new selection or to edit an existing one.
Prepare an application for QueryBuilder by creating the required objects for the communication and management of data.
Create a QueryBuilder
object.
Set the MetadataManager
property of the QueryBuilder
object to specify the object that will manage its connections to data stores.
Call the setQueryContext
method of the QueryBuilder
object to assign a Query
object to the QueryBuilder
object.
The Query
object, which implements the QueryContext
interface, serves as the data source for the QueryBuilder
object.
(Optional.) Set up a universe for each dimension.
Customize the QueryBuilder
object, as needed.
Note: You do not have to customize the QueryBuilder; you can use it just as it is, with the default settings.
Tip: To have the Layout panel of the QueryBuilder use the same type of view as the view from which the QueryBuilder is called, use the QueryBuilder's setViewLayoutPanel
method.
Call the run
method of the QueryBuilder
object.
The code in this example assumes that the variables in the following list exist:
m_MetadataManager
-- The MetadataManager
object
that the QueryBuilder will use.
m_query
-- The Query
object that QueryBuilder
will access through the QueryContext
interface.
top_parent
-- The top-level dialog box or frame that serves
as the parent for the QueryBuilder. By specifying the name of the top-level
dialog box or a frame in the constructor for the QueryBuilder, you ensure
that the focus for the QueryBuilder and its associated dialogs is maintained
properly.
Tip: When you use the constructor in this manner, you can also specify an icon for the top-level dialog box or a frame that is propagated to the QueryBuilder's panels and associated dialog boxes. The following sample line of code shows how to set this icon.
top_parent.setIconImage(java.awt.Toolkit.getDefaultToolkit().createImage("myicon.gif"));
The following code example sets up a QueryBuilder in wizard mode.
//Create the QueryBuilder QueryBuilder m_queryBuilder = new QueryBuilder(top_parent); m_queryBuilder.setMode(QueryBuilder.WIZARD); //Specify the MetadataManager that the QueryBuilder will use. m_queryBuilder.setMetadataManager (m_MetadataManager); //Assign the query to the QueryBuilder m_queryBuilder.setQuery((QueryContext)m_query); //Change the Layout panel to use graph //rather than the default of crosstab Graph graph = new Graph(); graph.setDataSource(m_query); GraphLayout graphLayout = new GraphLayout(); graphLayout.setGraph(graph); graphLayout.setLayoutContext((LayoutContext)m_query); m_queryBuilder.setViewLayoutPanel(graphLayout); //Run the QueryBuilder m_queryBuilder.run();