Adding a QueryBuilder to an Application

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.

To add a QueryBuilder to an application:

  1. Prepare an application for QueryBuilder by creating the required objects for the communication and management of data.

  2. Create a QueryBuilder object.

  3. Set the MetadataManager property of the QueryBuilder object to specify the object that will manage its connections to data stores.

  4. 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.

  5. (Optional.) Set up a universe for each dimension.

  6. 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.

  7. Call the run method of the QueryBuilder object.

Example: Setting up a QueryBuilder

The code in this example assumes that the variables in the following list exist:

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();