The OLAP Dimension List Panel sample demonstrates how you can use the OLAPDimensionListPanel
bean to modify the member steps of a query, which is embedded within a presentation
object, such as a crosstab.
The following figure shows a page from the OLAP Dimension List Panel sample. This page contains the following items:
A menu bar and a toolbar.
The Choose box in which you specify the dimension whose values you want to select.
An OLAPDimensionListPanel
. This panel also contains a toolbar,
which you can use to select levels and to expand or collapse the dimension
list. In the list, you select the dimension values to add to or replace in
the existing query. The selected dimension values are represented as query
steps.
The Add and Replace
buttons. Once the dimension values are selected in the OLAPDimensionListPanel
,
you can apply these selections to the query using the Add
or Replace button.
A crosstab that displays the results of your modifications to the query.
If you have not already done so, you must perform several installation
and configuration tasks, then open the workspace javaclient\javaclient.jws
under the samples
directory within JDeveloper. All the necessary
files for this sample can be found in the using_dimensionlist.jpr
project under the javaclient.jws
workspace.
The OLAP Dimension List Panel sample creates a default query, which is applied to a new crosstab, as shown in the following code fragment.
// Create the default query used in the crosstab
m_query = getDefaultQuery();
// Attach the query to the crosstab
newCrosstab.setDataSource(m_query);
The OLAP Dimension List Panel sample uses information about the dimension whose
values it displays in the OLAPDimensionListPanel
. In particular,
the OLAPDimensionListPanel
object requires unique dimension identifiers
such as the dimension ID and the default hierarchy ID. The sample implements
the getDimensionDetails
method, which retrieves information about
the dimensions from the MetadataManager.
The strSelectedMeas
variable holds the name of the first measure
in the default query for which dimension information is being retrieved.
The code loops over all the dimensions for a given measure and retrieves all
the required information, which is stored in a multidimensional array for use
later. The following code fragment shows how to retrieve dimension information.
// Retrieve the metadata measure unique ID
MDMeasure firstMeasure = getMetadataManager().getMeasure(MM.UNIQUE_ID, strSelectedMeas);
// Cycle over the dimensions of the measure until the required dimension name
is found
MDDimension[] mdDimensions = firstMeasure.getDimensions();
// Create an array to hold the dimension short names
String[][] strDimensionInfo = new String[4][mdDimensions.length];
// Cycle over the dimensions for the measure
for (int i = 0; i < mdDimensions.length; i++)
{
// Retrieve the name of the dimension
strDimensionInfo[0][i] = mdDimensions[i].getName();
// Retrieve the ID for the dimension
strDimensionInfo[1][i] = mdDimensions[i].getUniqueID();
// Retrieve the hierarchy ID for the dimension
strDimensionInfo[2][i] = mdDimensions[i].getDefaultHierarchy().getUniqueID();
// Retrieve the short name for the dimension
strDimensionInfo[3][i] = mdDimensions[i].getShortLabel();
if (strDimensionInfo[0][i].equals(m_OLAPDim)) {
// Set the dimension ID once the dimension name is found
m_strCurrentDim = strDimensionInfo[1][i];
// Set the hierarchy ID once the dimension name is found
m_strCurrentDimHier = strDimensionInfo[2][i];
// Set the list index for the dimension selection combo list box
// This ensures the selected dimension is selected in the combo box
selectedComboIndex = i;
}
}
OLAPDimensionListPanel
The OLAP Dimension List Panel sample implements the OLAPDimensionListPanel
class, which instantiates the OLAPDimensionListPanel
and specifies
what dimension to display, as shown in the following code fragment.
QueryAccess
is a class that allows the modification of a query's
selections, without changes being reflected immediately in dependent objects
e.g. where a presentation object is using the query. This eliminates the need
to clone the dimension selection prior to changing any aspect of the query.
QueryAccessDimensionModel
is an object that specifies dimension
information for the OLAP Dimension List Panel. In this code fragment, the variable
for the QueryAccessDimensionModel
is qadm. This requires
MetadataManager unique ID's for the dimension and hierarchy, which are retrieved
and stored in the m_strCurrentDim and m_strCurrentDimHier
variables. Both these variables were populated previously when the getDimensionDetails
method was called.
OLAPDimensionListPanel newDimList = null;
// Retrieve the query object embedded in the crosstab
Query query = (Query) m_activeView.getDataSource();
// Grant access to the query using the QueryAccess class
QueryAccess queryAccess = query.createQueryAccess();
// Retrieve the unique ID for both the selected dimension and the hierarchy
MetadataManager mdm = getMetadataManager();
// The QueryAccessDimensionModel specifies the dimension information for the OLAPDimensionListPanel
QueryAccessDimensionModel qadm = new QueryAccessDimensionModel(queryAccess, null,
null, m_strCurrentDim,m_strCurrentDimHier, mdm);
// Create the OLAPDimensionListPanel by passing the QueryAccessDimensionModel
newDimList = new OLAPDimensionListPanel(qadm);
A query is comprised of a series of Select, Add, Keep, and Remove steps. The
OLAPDimensionListPanel
contains a list of selected members that
are used to create a member step. If the user is replacing the existing selection,
then all the existing steps are removed and replaced with a new member step.
If the user is adding to a selection, then the member step is added to the existing
list of steps.
The OLAP Dimension List Panel sample implements the applyDimListSelection
method, which is called when the user chooses the Add
or Replace button. The sample code adds the dimension
values that were selected in the OLAPDimensionListPanel
as a member
step in the query and applies the updated query to the crosstab.
The following code fragment shows how to apply dimension selections as query steps.
// Retrieve the query object for the crosstab
Query query = (Query) m_activeView.getDataSource();
// Retrieve the selection object for the selected dimension
Selection selection = query.findSelection(m_strCurrentDim);
// Retrieve the member step for the selected dimension for the list
MemberStep step = m_dimList.getSelectedMemberStep();
if (action == ADD_ITEM)
// Add to the selection step
step.setAction(Step.ADD);
else {
// Replace selection steps
selection.removeAllSteps();
// Add new selection steps
step.setAction(Step.SELECT);
}
// Add the selection step to the list of steps and apply the selection to the query
selection.addStep(step);
To run the OLAP Dimension List Panel sample within JDeveloper, simply right-click
the BIDimList.java
file and choose Run BIDimList.
Once the sample starts, you are prompted for the user name and password of the
user that owns the sample schema, for example, bibdemo
.
![]() |
|
---|---|
Copyright © 2002, 2003 Oracle. All Rights Reserved. |
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. |