|
Oracle OLAP Java API Reference 10g Release 1 (10.1) B10994-01 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--oracle.olapi.data.source.Template
The basis for creating a Source that an application can dynamically change. An application can use a Template to turn the selections made by an end user into Source objects.
A Template has the following component objects:
TemplateMetadataStateDataProviderSourceGeneratorDynamicDefinitionThe components work together as follows:
Template has methods that create a DynamicDefinition and that get and set the current state of a MetadataState. An extension to the Template abstract class adds methods to get values from its MetadataState and to put values into the fields on the MetadataState.MetadataState implementation has fields for storing the data to use in generating the Source for the Template. An application passes the MetadataState to the constructor when creating a new Template. When the application calls the getSource on the DynamicDefinition, the MetadataState is passed to the generateSource method on the SourceGenerator.DataProvider is used by the Template in creating a DynamicDefinition.SourceGenerator implementation has a generateSource method that uses the current state of the data in the MetadataState to produce the Source that the Template defines. The application passes the SourceGenerator to the createDynamicDefinition method on the Template to create a DynamicDefinition.DynamicDefinition has a getSource method that gets the Source generated by the SourceGenerator. The DynamicDefinition serves as a proxy for the immutably paired SourceDefinition of that Source.The application can use the Source produced by the Template in creating a Cursor to fetch the data defined by the Source. It can also use the Source in creating another Source.
The application can use Source objects produced by different Template objects in the process of creating a Source that represents a complex query. The application can change the selection of data for any one of the Template objects that comprise the complex query. Since the DynamicDefinition that gets the Source for a Template is a proxy, the application does not have to recreate all of the component Source objects to produce a Source for the complex query that includes the new selection. Instead, the application just calls the getSource method on the DynamicDefinition for the Template that produces the complex query, and the current state of the changed Template component is used in rebuilding the query.
As an example of using Template objects, suppose an application lets an end user do the following:
The data that the user has selected is the ten products that have the highest total sales amounts of those sold through the direct channel to customers from San Francisco in the first quarter of 2000 during a televised promotion.
Suppose the application can use the following objects:
MetadataState, called TopBottomTemplateState, that has fields that store values for the measure and the number of data values, the selection of top or bottom, and a selection of single values from the dimensions other than the base.Template, called TopBottomTemplate, that has a method that calls the getCurrentState method on its TopBottomTemplateState, specifies the number of data values, and then calls the setCurrentState method on the TopBottomTemplateState. It has similar methods for specifying the top or bottom and the selection of the measure and the single values for the dimensions other than the base.SourceGenerator, called TopBottomTemplateGenerator, that has methods in its generateSource method that use the values from the TopBottomTemplateState to create a Source.MetadataState, called SingleSelectionsTemplateState, that has fields that stores the measure and the selections of single values from the dimensions.Template, called SingleSelectionsTemplate, that has methods that add the measure and the single value selections to the SingleSelectionsTemplateState.SourceGenerator, called SingleSelectionsTemplateGenerator, that has methods in its generateSource method that use the values from the SingleSelectionsTemplateState to create a Source.The constructor methods for the SingleSelectionsTemplate and the TopBottomTemplate both do the following:
DataProvider as an input value.MetadataState and pass it, and the DataProvider, to their Template superclasses.SourceGenerator.DynamicDefinition and store it in a private field.The constructor for the TopBottomTemplate then looks like the following:
public class TopBottomTemplate(DataProvider dataProvider)
{
super(new TopBottomTemplateState(),
dataProvider);
TopBottomTemplateGenerator topBottomTemplateGenerator =
new TopBottomTemplateGenerator(dataProvider);
_definition = createDynamicDefinition(topBottomTemplateGenerator)
}
Along with a DataProvider, the SingleSelectionsTemplate constructor has as an input value a Source that represents the measure.
The Template subclasses also have a method, called getSource, that calls the getSource method on the saved DynamicDefinition and returns the Source for the Template. After receiving the selections from the end user, the application does the following:
SingleSelectionsTemplate.addSingleValue method on the SingleSelectionsTemplate once for each single value selected for the dimensions other than the base. The method stores the values in fields on the SingleSelectionsTemplateState.getSource method on the SingleSelectionsTemplate.TopBottomTemplate.TopBottomTemplate that add the value specifying the number of data values and the value for the selection of top to the TopBottomTemplateState.TopBottomTemplate that adds the Source produced by the SingleSelectionsTemplate to the TopBottomTemplateState.prepareCurrentTransaction and commitCurrentTransaction methods on the TransactionProvider that the application is using.getSource method on the TopBottomTemplate.CursorManagerSpecification for the Source produced by the TopBottomTemplate and then creates a CursorManager and a Cursor.Cursor to display to the end user.Suppose that the end user decides to change the single value selection for the customers dimension from "San Francisco" to "Buffalo". The application receives the new selection, and then does the following:
addSingleValue method on the SingleSelectionsTemplate, which overwrites the previous value for the dimension that was stored in the SingleSelectionsTemplateState.prepareCurrentTransaction and commitCurrentTransaction methods on the TransactionProvider.getSource method on the TopBottomTemplate.CursorManagerSpecification for the Source produced by the TopBottomTemplate and then creates a CursorManager and a Cursor.Cursor and displays them to the end user.Note that the application does not need to call the getSource method on the SingleSelectionsTemplate. The current state for that Template, with the "Buffalo" selection, is used in the process of generating the Source for the TopBottomTemplate. The application does not need to repeat all of the other steps in producing either of the Template objects.
DynamicDefinition, MetadataState, SourceGenerator, TransactionProvider| Constructor Summary | |
protected |
Template(MetadataState initialState, DataProvider dataProvider)Creates a new Template. |
| Method Summary | |
protected DynamicDefinition |
createDynamicDefinition(SourceGenerator sourceGenerator)Creates a DynamicDefinition that acts as a proxy for the SourceDefinition that is immutably paired to the Source generated by the SourceGenerator. |
protected MetadataState |
getCurrentState()Gets the current state for this Template. |
protected MetadataState |
getCurrentStateForRead()Gets the current state for this Template. |
protected MetadataState |
getCurrentStateForWrite()Gets the current state for this Template. |
DataProvider |
getDataProvider()Gets the DataProvider for this Template. |
protected void |
setCurrentState(MetadataState state)Specifies a state as the current state for this Template. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
protected Template(MetadataState initialState,
DataProvider dataProvider)
throws TransactionTypeUnavailableException,
TransactionInactiveException
Template.initialState - The MetadataState to use with this Template.dataProvider - A DataProvider for internal use by the Template.| Method Detail |
protected DynamicDefinition createDynamicDefinition(SourceGenerator sourceGenerator)
DynamicDefinition that acts as a proxy for the SourceDefinition that is immutably paired to the Source generated by the SourceGenerator.sourceGenerator - The SourceGenerator that generates the Source produced by the current state of this Template.DynamicDefinition for accessing the Source produced by this Template.
protected MetadataState getCurrentState()
throws TransactionalObjectInvalidException,
TransactionTypeUnavailableException,
TransactionInactiveException
Template.Template.
protected MetadataState getCurrentStateForRead()
throws TransactionalObjectInvalidException,
TransactionTypeUnavailableException,
TransactionInactiveException
Template. Do not modify the state returned by this method; use it only for read operations.Template.
protected MetadataState getCurrentStateForWrite()
throws TransactionalObjectInvalidException,
TransactionTypeUnavailableException,
TransactionInactiveException
Template. The returned state is a clone of the actual state, so you can modify it. If you modify it, then you must reset the state by passing it to the setCurrentState method.Template.public DataProvider getDataProvider()
DataProvider for this Template.DataProvider with which this Template was constructed.
protected void setCurrentState(MetadataState state)
throws CursorLockException,
WriteLockException,
TransactionTypeUnavailableException,
TransactionInactiveException
Template.state - The state to specify as the current state for this Template.
|
Oracle OLAP Java API Reference 10g Release 1 (10.1) B10994-01 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||