Example Oracle® OLAP Java API and
Oracle OLAP Analytic Workspace Java API Programs


The example programs were compiled using the Oracle OLAP Java API and Oracle OLAP Analytic Workspace Java API classes in the 10.2.0.4 version of Oracle Database 10g Release 2 (10.2). The programs also compile and run successfully in the 10.2.0.3 version of the database.

The example programs use analytic workspace metadata objects that are mapped to columns of tables in the relational database. The tables are part of the Global sample schema. You can get the SQL scripts that install the Global schema from the Oracle OLAP 10g section under Sample Schemas and Code on the Oracle OLAP Downloads page.

Most of the programs are the complete code for the examples in Oracle OLAP Developer's Guide to the OLAP API, 10g Release 2 (10.2), part number B14347. Some of the example programs are the complete code for examples that appear in Oracle OLAP Java API Reference, Release 2 (10.2), part number B14348.

You can add the example program classes to your Java development environment and compile and run them if the programs can connect to an Oracle Database instance with the OLAP option that has the Global schema installed. The example programs are in a package organization that you can import into an integrated development environment such as Oracle JDeveloper. The packages indicate the chapter in which the example appears in Oracle OLAP Developer's Guide to the OLAP API.

Extracting the contents of the compressed file that contains the examples creates the following directory structure.

examples
  src
    oracle
      olapi
        examples
          chapter2
          chapter3
          chapter4
          chapter5
          chapter6
          chapter7
          chapter8
          chapter9
          chapter10

 

The top-level examples directory contains the build.xml and build.properties files. You can use these files in importing the examples as a project into some integrated development environments. Modify the build.properties file to specify the location of the JAR files that contain the libraries required to build an OLAP Java API program.

The following table lists the required JAR files and their locations under the ORACLE_HOME directory in an installation of Oracle Database Enterprise Edition with the OLAP option.

 

File Name Location
  olap_api.jar   /olap/api/lib
  ojdbc14.jar   /jdbc/lib
  xmlparserv2.jar   /lib

 

Note: The BuildAW11g program creates the analytic workspace that is used by most of the other example programs. You must run the BuildAW11g program before you can run any of those other example programs.

 

The following table lists the Java classes that are in the examples/src/oracle/olapi/examples directory.

 

Classes in examples Description
BaseExample The base class for all of the example programs. This abstract class has methods that do the following:
  • Put command line arguments into a Properties object.
  • Create a CursorPrintWriter.
  • Execute the example program.
BuildAWExample A program that uses the Oracle OLAP Analytic Workspace Java API to define and build an analytic workspace. The OLAP Java API example programs query that analytic workspace.
ContextExample An abstract class that extends BaseExample. This class creates a Context10g object and it has methods that are commonly used by the examples.
Context10g An instance of this class is created by a ContextExample. This class has methods that do the following:
  • Use the command-line properties from the ContextExample to connect to an Oracle Database instance.
  • Create the MDM metadata objects required by most of the example programs.
  • Get the MDM metadata objects contained by an MdmSchema and store them in a HashMap.

This class also has convenience methods for getting metadata objects from the HashMap, for creating Cursor objects, and for displaying the contents of the Cursor objects.

CursorPrintWriter A PrintWriter that has methods for displaying the values of a Cursor in various formats.
Logger This class encapsulates the logging of output generated by an example program.
MyMdmObjectVisitor This class extends the MdmBaseObjectVisitor class. It is used by the chapter4.SampleMetadataDiscoverer10g example program.
RecursiveJoinAndShortcutsExamples This class has the complete code for some of the examples in the Oracle OLAP Java API Reference. It has the code for the examples in the descriptions of the full signature of the Source.recursiveJoin method, of other signatures of recursiveJoin, and of some related Source methods such as selectDescendants and sortDescendingHierarchically.

 

The subdirectories of examples/src/oracle/olapi/examples contain the source code for the examples in the chapters of the Oracle OLAP Developer's Guide to the OLAP API. The chapter2 directory has the classes that contain the complete code for the examples in Chapter 2, "Understanding OLAP API Metadata". The following table lists the classes that are in that directory.

 

Classes in chapter2 Description
ElementsOfMdmAttribute A program that creates a query that produces the results that appear in the table in the "MdmAttribute Class" section of Chapter 2.
CreateCustomDimensionMember Example 2-1, Creating a Custom Member of a Dimension.
GettingDataTypeOfMdmSource Example 2-2, Getting the Data Type of an MdmSource.
GettingTypeOfMdmSource Example 2-3, Getting the Type of an MdmSource.
CreateCustomMeasureDimensionMember Example 2-4, Creating a Custom Member of the MdmMeasureDimension.
GettingDataTypeOfMdmSource Contains the code in the Getting the Data Type of an MdmSource example.
GettingTypeOfMdmSource Contains the code in the Getting the Type of an MdmSource example.

 

The code for most of the examples in Chapter 3, "Connecting to a Data Store", is used in the Context10g program to create a connection to an Oracle Database instance. The chapter3 directory contains a class that has complete code for one of the examples in the chapter . The following table lists the class that is in that directory.

 

Classes in chapter3 Description
GettingExistingConnection Example 3-3, Getting an Existing Connection.

 

The code for most of the examples in Chapter 4, "Discovering the Available Metadata", appears in the SampleMetadataDiscoverer10g program, which is in the chapter4 directory. The following table lists the class that is in that directory.

 

Classes in chapter4 Description
SampleMetadataDiscoverer10g Example 4-1, Creating an MdmMetadataProvider
Example 4-2, Getting the Root MdmSchema
Example 4-3, Getting MdmDimension Objects
Example 4-4, Getting Subschemas
Example 4-5, Getting the MdmMeasureDimension
Example 4-6, Getting the Dimensions of an MdmMeasure
Example 4-7, Getting the MdmHierarchy Components of an MdmPrimaryDimenison
Example 4-8, Getting a Primary Source for a Metadata Object
Example 4-9, Discovering the OLAP Metadata.

 

The chapter5 directory has the classes that contain the complete code for the examples in Chapter 5, "Understanding Source Objects". The following table lists the classes that are in that directory.

 

Classes in chapter5 Description
UnderstandingSourceObjects The following examples, and two informal untitled examples, are implemented as methods of this class.

Example 5-1, Getting the Data Type of a Source.
Example 5-2, Using the isSubtypeOf Method.
Example 5-3, Using the join Method To Produce a Source Without an Output.
Example 5-4, Using the join Method To Produce a Source With an Output.
Example 5-5, Using the join Method To Match Source Objects To Inputs.
Example 5-6, Using Shortcuts.
Example 5-7, Matching the Base Source to an Input of the Joined Source.
Example 5-8, Matching an Input of the Base Source to an Output of the Joined Source.
Example 5-9, Matching the Inputs of a Measure and Producing Outputs.

UsingParamSourceWithMeasDim Example 5-10, Using a Parameterized Source With a Measure Dimension.
ImplementingExtractAsACustomModel Example 5-11, Implementing the extract Method as a CustomModel.
CreateDependentAssignment Example 5-12, Creating an Assignment That Depends on Another Assignment.
CreateCustomMemberWithAggVal Example 5-13, Creating a Custom Member That Assigns an Aggregated Value.

 

The chapter6 directory has the classes that contain the complete code for the examples in Chapter 6, "Making Queries Using Source Objects". The following table lists the classes that are in that directory.

 

Classes in chapter6 Description
MakingQueriesExamples The following examples are implemented as methods of this class.

Example 6-1, Controlling Input-to-Source Matching With the alias Method.
Example 6-2, Using the distinct Method.
Example 6-3, Using COMPARISON_RULE_REMOVE.
Example 6-4, Using COMPARISON_RULE_DESCENDING.
Example 6-5, Selecting the First and Last Time Elements.
Example 6-7, Selecting a Subset of the Elements of a Source.
Example 6-8, Using the extract Method
Example 6-11, Hierarchical Sorting by Measure Value.

SortingHierarchicallyByAttribute Example 6-6, Sorting Products Hierarchically By Attribute.
CreatingCubeAndPivotingEdges Example 6-9, Creating a Cube and Pivoting Its Edges.
DrillingInHierarchy Example 6-10, Drilling in a Hierarchy.
GettingShareOfUnits Example 6-12, Getting the Share of Units Sold.
UsingLagMethod Example 6-13, Using the Lag Method.
UsingMovingTotalMethod Example 6-14, Using the movingTotal Method.
SelectingRangeWithNumberParam Example 6-15, Selecting a Range With NumberParameter Objects.

 

The chapter7 directory has the classes that contain the complete code for the examples in Chapter 7, "Using a TransactionProvider". The following table lists the classes that are in that directory.

 

Classes in chapter7 Description
TransactionExamples The following examples are implemented as methods of this class.

Example 7-1, Rolling Back a Transaction.
Example 7-2, Using Child Transaction Objects.

 

The chapter8 directory has the classes that contain the complete code for the examples in Chapter 8, "Understanding Cursor Classes and Objects". The following table lists the classes that are in that directory.

 

Classes in chapter8 Description
CursorConceptsExamples The following examples, and an informal example, are implemented as methods of this class.

Example 8-1, Creating the querySource Query.
Example 8-2, Setting the CompoundCursor Position and Getting the Current Values.
Example 8-3, Positions in an Asymmetric Query.

 

The chapter9 directory has the classes that contain the complete code for the examples in Chapter 9, "Retrieving Query Results". The following table lists the classes that are in that directory.

 

Classes in chapter9 Description
RetrievingQueryResults The following examples are implemented as methods of this class.

Example 9-1, Creating a Cursor.
Example 9-2, Getting a Single Value from a ValueCursor.
Example 9-3, Getting All of the Values from a ValueCursor.
Example 9-4, Getting ValueCursor Objects from a CompoundCursor example.
Example 9-5, Getting Values from a CompoundCursor with Nested Outputs example.
Example 9-6, Navigating For a Table View.
Example 9-7, Navigating For a Crosstab View Without Pages.
Example 9-8, Navigating For a Crosstab View With Pages.
Example 9-9, Getting CursorSpecification Objects from a CursorManagerSpecification.
Example 9-10, Specifying the Calculation of the Extent of a Cursor.
Example 9-11, Specifying the Calculation of Starting and Ending Positions in a Parent.
Example 9-12, Calculating the Span of the Positions in the Parent of a Value.
Example 9-13, Specifying a Fetch Size.

 

The chapter10 directory has the classes that contain the complete code for the examples in Chapter 10, "Creating Dynamic Queries". The following table lists the classes that are in that directory.

 

Classes in chapter10 Description
TopBottomTemplate Example 10-1, Implementing a Template.

The following examples are implemented as inner classes of TopBottomTemplate.

Example 10-2, Implementing a MetadataState.
Example 10-3, Implementing a SourceGenerator.

TopBottomTest Example 10-4, Getting the Source Produced by the Template.
SingleSelectionTemplate A Template that is used by TopBottomTest.

 


Copyright © 2002, 2006, Oracle. All rights reserved.
KScope 14 RHS Banner

Database Cloud Service Banner