Oracle9i OLAP Developer's Guide to the OLAP API Release 2 (9.2) Part Number A95297-01 |
|
Creating Dynamic Queries, 2 of 4
The Template
class is the basis of a very powerful feature of the Oracle OLAP API. You use Template
objects to create modifiable Source
objects. With those Source
objects, you can create dynamic queries that can change in response to end-user selections. Template
objects also offer a convenient way for you to translate user-interface elements into OLAP API operations and objects.
These features are briefly described below. The rest of this chapter describes the Template
class and the other classes you use to create dynamic Source
objects. For information on the Transaction
objects that you use to make changes to the dynamic Source
and to either save or discard those changes, see Chapter 7.
The main feature of a Template
is its ability to produce a dynamic Source
. That ability is based on two of the other objects that a Template
uses: instances of the DynamicDefinition
and MetadataState
classes.
When a Source
is created, a SourceDefinition
is automatically created. The SourceDefinition
has information about how the Source
was created. Once created, the Source
and its SourceDefinition
are paired immutably. The getSource
method of a SourceDefinition
gets its paired Source
.
DynamicDefinition
is a subclass of SourceDefinition
. A Template
creates a DynamicDefinition
, which acts as a proxy for the SourceDefinition
of the Source
produced by the Template
. This means that instead of always getting the same immutably paired Source
, the getSource
method on the DynamicDefinition
gets whatever Source
is currently produced by the Template
. The instance of the DynamicDefinition
does not change even though the Source
that it gets is different.
The Source
that a Template
produces can change because the values, including other Source
objects, that the Template
uses to create the Source
can change. A Template
stores those values in a MetadataState
. A Template
provides methods to get the current state of the MetadataState
, to get or set a value, and to set the state. You use those methods to change the data values the MetadataState
stores.
You use a DynamicDefinition
to get the Source
produced by a Template
. If your application changes the state of the values that the Template
uses to create the Source
, for example, in response to end-user selections, then the application uses the same DynamicDefinition
to get the Source
again, even though the new Source
defines a result set different than the previous Source
.
The Source
produced by a Template
can be the result of a series of Source
operations that create other Source
objects, such as a series of selections, sorts, calculations, and joins. You put the code for those operations in the generateSource
method of a SourceGenerator
for the Template
. That method returns the Source
produced by the Template
. The operations use the data stored in the MetadataState
.
You might build an extremely complex query that involves the interactions of dynamic Source
objects produced by many different Template
objects. The end result of the query building is a Source
that defines the entire complex query. If you change the state of any one of the Template
objects that you used to create the final Source
, then the final Source
represents a result set different than that of the previous Source
. You can thereby modify the final query without having to reproduce all of the operations involved in defining the query.
You design Template
objects to represent elements of the user interface of an application. Your Template
objects turn the selections that the end user makes into OLAP API query-building operations that produce a Source
. You then create a Cursor
to fetch the result set defined by the Source
from Oracle OLAP. You get the values from the Cursor
and display them to the end user. When an end user makes changes to the selections, you change the state of the Template
. You then get the Source
produced by the Template
, create a new Cursor
, get the new values, and display them.
|
Copyright © 2000, 2002 Oracle Corporation. All Rights Reserved. |
|