Edit D:\app\Administrator\product\11.2.0\dbhome_1\olap\api\doc\doc-files\ExamplePrograms.html
<HTML> <HEAD> <TITLE> Example Oracle OLAP Java API Programs (Oracle OLAP Java API Reference) </TITLE> </HEAD> <LINK REL ="stylesheet" TYPE="text/css" HREF="../stylesheet.css" TITLE="Style"> <LINK REL ="stylesheet" TYPE="text/css" HREF="olapiref.css" TITLE="Style"> <body BGCOLOR="white"> <table summary="" border="0" width="100%" cellpadding="1" cellspacing="0"> <tr> <TD> <TABLE summary="" BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../overview-summary.html"><FONT ID="NavBarFont1"><B>Overview</B></FONT></A> </TD> </TR> </TABLE> <td align="right" valign="top" rowspan="3"><em><b>Oracle® OLAP Java API Reference<br>11<i>g</i> Release 1 (11.1)</b></td> </tr> </table> <hr> <H1>Example Oracle OLAP Java API Programs</H1> <P> This documentation and <I>Oracle OLAP Java API Developer's Guide</I> contain examples that demonstrate the use of OLAP Java API classes. The complete code for many of the examples is available in the <CODE>examples.zip</CODE> file, which <!-- is in the <ORACLE_HOME><CODE>/olap/api/doc</CODE> directory in an installation of an Oracle Database with the OLAP option. You can also get the <CODE>examples.zip</CODE> file --> you can get from the Oracle Technology Network (OTN) Web site at <a href="http://www.oracle.com/technology/products/bi/olap/olap.html">http://www.oracle.com/technology/products/bi/olap/olap.html</a>. <P> The example programs use metadata objects that are based on tables of a schema in the relational database. The schema is owned by the GLOBAL user. From the OTN Web site, you can also download the SQL scripts that create the GLOBAL user and install the Global schema. <P> 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. <P> The example programs are in a package organization that you can import into an integrated developement environment such as Oracle JDeveloper. Most of the programs are the complete code for the examples in <I>Oracle OLAP Java API Developer's Guide</I>. The example program classes are in a structure that indicates the package of API classes that they exemplify. Extracting the contents of the <CODE>examples.zip</CODE> file creates the following directory structure. <pre> examples src oracle olapi examples cursor metadata source template transaction</pre> <P> In the remainder of this document, the references to the directory structure begin with the <CODE>examples.src.oracle.olapi.examples</CODE> directory. <H2>Base and Utility Classes</H2> <P> The following table lists the classes that are in the <CODE>examples</CODE> directory. These classes are used by all of the example programs. <P> <table title="Classes in the Examples Directory" summary="This table describes the classes that are in the examples/src/oracle/olapi/examples directory." border cellspacing="0" cellpadding="5"> <thead> <tr> <th align="center" id="examples_head">Class</th> <th align="center" id="examples_descr">Description</th> </tr> </thead> <tbody> <tr> <td valign="top" headers="examples_head"><code>BaseExample11g</code></a> </td> <td valign="top" headers="examples_descr">The base class for all of the example programs. Some of the methods of this class do the following: <UL> <LI>Put command line arguments into a <CODE>Properties</CODE> object. <LI>Create a <CODE>CursorPrintWriter</CODE>. <LI>Execute the example program. </UL> </td> </tr> <tr> <td valign="top" headers="examples_head"><code>Context11g</code></a> </td> <td valign="top" headers="examples_descr">An instance of this class is created by a <CODE>BaseExample11g</CODE>. This class has methods that do the following: <UL> <LI>Use the command-line properties from the <CODE>BaseExample11g</CODE> to connect to an Oracle Database instance. <LI>Create or get the MDM metadata objects that are used by most of the example programs and store some of the objects in a <CODE>HashMap</CODE>. </UL> <P> This class also has convenience methods for getting metadata objects from the <CODE>HashMap</CODE>, for creating <CODE>Cursor</CODE> objects, and for displaying the contents of the <CODE>Cursor</CODE> objects. </td> </tr> <tr> <td valign="top" headers="examples_head"><code>CursorPrintWriter</code></a> </td> <td valign="top" headers="examples_descr">A <CODE>PrintWriter</CODE> that has methods for displaying the values of a <CODE>Cursor</CODE> in various formats. </td> </tr> <tr> <td valign="top" headers="examples_head"><code>Logger</code></a> </td> <td valign="top" headers="examples_descr">This class encapsulates the logging of output generated by an example program. </td> </tr> </tbody> </table> <H2>First Example Program to Run</H2> Before running any of the other example programs, first run the <CODE>BuildAW11g</CODE> program. It creates metadata objects and builds an analytic workspace. Most of the other example programs use the objects created by this program. <P> <table title="First Example to Run" summary="This table describes the first example program to run." border cellspacing="0" cellpadding="5"> <thead> <tr> <th align="center" id="first_pkg">Package</th> <th align="center" id="first_head">Class</th> <th align="center" id="first_descr">Description</th> </tr> </thead> <tbody> <tr> <td valign="top" headers="first_pkg"><code>metadata</code></a> </td> <td valign="top" headers="first_head"><code>BuildAW11g</code></a> </td> <td valign="top" headers="first_descr">A program that defines metadata objects, maps them to the Global schema, deploys them to an analytic workspace, writes the metadata object definitions to an XML file, and builds the analytic workspace. Most of the other OLAP Java API example programs query that analytic workspace. </td> </tr> </tbody> </table> <H2>Examples in Oracle OLAP Java API Reference</H2> The following table lists the classes that have the code for examples that appear in <I>Oracle OLAP Java API Reference</I>. <P> <table title="Examples in Oracle OLAP Java API Reference" summary="This table describes the classes that have the examples that are in Oracle OLAP Java API Reference." border cellspacing="0" cellpadding="5"> <thead> <tr> <th align="center" id="ref_pkg">Package</th> <th align="center" id="ref_head">Class</th> <th align="center" id="ref_descr">Description</th> </tr> </thead> <tbody> <tr> <td valign="top" headers="ref_pkg"><code>source</code></a> </td> <td valign="top" headers="ref_head"><code>RecursiveJoinAndShortcutsExamples</code></a> </td> <td valign="top" headers="ref_descr">This class has the complete code for the examples in the descriptions of the full signature of the <CODE>Source.recursiveJoin</CODE> method, of other signatures of <CODE>recursiveJoin</CODE>, and of some related <CODE>Source</CODE> methods such as <CODE>selectDescendants</CODE> and <CODE>sortDescendingHierarchically</CODE>. </td> </tr> <tr> <td valign="top" headers="ref_pkg"><code>source</code></a> </td> <td valign="top" headers="ref_head"><code>SourceExamplesInRef</code></a> </td> <td valign="top" headers="ref_descr">This class has the complete code for examples in some of the classes in the <CODE>oracle.olapi.data.source</CODE> package. </td> </tr> </tbody> </table> <H2>Examples in Oracle OLAP Java API Developer's Guide</H2> The tables in this section list the classes that contain the code for the examples in <I>Oracle OLAP Java API Developer's Guide</I>. The tables are organized by chapter and list the examples in the order in which they appear in the documentation. <H3>Examples in Chapter 2</H3> The following table lists the examples that appear in Chapter 2, "Understanding OLAP Java API Metadata", and the example programs that contain the code for the examples. <P> <table title="Examples in Chapter 2" summary="This table describes the classes that have the code of the examples in Chapter 2." border cellspacing="0" cellpadding="5"> <thead> <tr> <th align="center" id="ch2_pkg">Package</th> <th align="center" id="ch2_head">Class</th> <th align="center" id="ch2_descr">Description</th> </tr> </thead> <tbody> <tr> <td valign="top" headers="ch2_pkg"><code>metadata</code></a> </td> <td valign="top" headers="ch2_head"><code>ElementsOfMdmAttribute</code></a> </td> <td valign="top" headers="ch2_descr">Creates a query that produces the results that appear in the table in the "MdmAttribute Class" section. </td> </tr> <!-- <tr> <td valign="top" headers="ch2_pkg"><code>metadata</code></a> </td> <td valign="top" headers="ch2_head"><code>CreateCustomDimensionMember</code></a> </td> <td valign="top" headers="ch2_descr">Example 2-1, Creating a Custom Member of a Dimension. </td> </tr> --> <tr> <td valign="top" headers="ch2_pkg"><code>metadata</code></a> </td> <td valign="top" headers="ch2_head"><code>GettingDataTypeOfMdmSource</code></a> </td> <td valign="top" headers="ch2_descr">Example 2-1, Getting the Data Type of an MdmSource. </td> </tr> <tr> <td valign="top" headers="ch2_pkg"><code>metadata</code></a> </td> <td valign="top" headers="ch2_head"><code>GettingTypeOfMdmSource</code></a> </td> <td valign="top" headers="ch2_descr">Example 2-2, Getting the Type of an MdmSource. </td> </tr> <!-- <tr> <td valign="top" headers="ch2_pkg"><code>metadata</code></a> </td> <td valign="top" headers="ch2_head"><code>CreateCustomMeasureDimensionMember</code></a> </td> <td valign="top" headers="ch2_descr">Example 2-4, Creating a Custom Member of the MdmMeasureDimension. </td> </tr> --> </tbody> </table> <H3>Examples in Chapter 3 </H3> The following table lists the examples that appear in Chapter 3, "Discovering Metadata", and the example program that contains the code for the examples. <P> <table title="Examples in Chapter 3" summary="This table describes the classes that have the code of the examples in Chapter 3." border cellspacing="0" cellpadding="5"> <thead> <tr> <th align="center" id="ch3_pkg">Package</th> <th align="center" id="ch3_head">Class</th> <th align="center" id="ch3_descr">Description</th> </tr> </thead> <tbody> <tr> <td valign="top" headers="ch3_pkg"><code>metadata</code></a></td> <td valign="top" headers="ch3_head"><code>ConnectAndDiscover</code></td> <td valign="top" headers="ch3_descr">Example 3-1, Getting a JDBC OracleConnection.<br> Example 3-2, Creating a DataProvider.<br> Example 3-3, Closing the Connection.<br> Example 3-4, Creating an MdmMetadataProvider.<br> Example 3-5, Getting the MdmSchema Objects<br> Example 3-6, Getting a Single MdmDatabaseSchema.<br> Example 3-7, Getting the Dimensions and Measures of an MdmDatabaseSchema.<br> Example 3-8, Getting the Dimensions and Measures of an MdmCube.<br> Example 3-9, Getting the Hierarchies and Levels of a Dimension.<br> Example 3-10, Getting the MdmAttribute Objects of an MdmPrimaryDimension.<br> Example 3-11, Getting a Primary Source for a Metadata Object. </td> </tr> </tbody> </table> <H3>Examples in Chapter 4 </H3> The following table lists the examples that appear in Chapter 4, "Creating Metadata and Analytic Workspaces", and the example program that contains the code for the examples. The <code>CreateMetadataAndAW</code> program, which contains the code for the examples, is a subset of the <CODE>BuildAW11g</CODE> program, simplified for use as examples in the documentation. Both programs first delete the GLOBALAW analytic workspace if it exists and then define and build the analytic workspace. <P> <b>Note:</b> All of the examples from the other chapters use the analytic workspace created by the <CODE>BuildAW11g</CODE> program. If you run the <CODE>CreateMetadataAndAW</CODE> program, be sure to run the <CODE>BuildAW11g</CODE> program before running any of the other example programs. <P> <table title="Examples in Chapter 4" summary="This table describes the classes that have the code of the examples in Chapter 4." border cellspacing="0" cellpadding="5"> <thead> <tr> <th align="center" id="ch4_pkg">Package</th> <th align="center" id="ch4_head">Class</CODE></td> <th align="center" id="ch4_descr">Description</th> </tr> </thead> <tbody> <tr> <td valign="top" headers="ch4_pkg"><code>metadata</code></a></td> <td valign="top" headers="ch4_head"><code>CreateMetadataAndAW</code></td> <td valign="top" headers="ch4_descr">Example 4-1, Creating an AW.<br> Example 4-2, Creating and Deploying an MdmStandardDimension.<br> Example 4-3, Creating and Mapping an MdmDimensionLevel.<br> Example 4-4, Creating and Mapping MdmLevelHierarchy and MdmHierarchyLevel Objects.<br> Example 4-5, Creating an MdmBaseAttribute.<br> Example 4-6, Creating and Mapping an MdmCube.<br> Example 4-7, Creating and Mapping Measures.<br> Example 4-8, Committing Transactions.<br> Example 4-9, Exporting to an XML Template.<br> Example 4-10, Building an Analytic Workspace. </td> </tr> </tbody> </table> <H3>Examples in Chapter 5</H3> The following table lists the examples that appear in Chapter 5, "Understanding Source Objects", and the example programs that contain the code for the examples. <P> <table title="Examples in Chapter 5" summary="This table describes the classes that have the code of the examples in Chapter 5." border cellspacing="0" cellpadding="5"> <thead> <tr> <th align="center" id="ch5_pkg">Package</th> <th align="center" id="ch5_head">Class</td> <th align="center" id="ch5_descr">Description</th> </tr> </thead> <tbody> <tr> <td valign="top" headers="ch5_pkg"><code>source</code></a></td> <td valign="top" headers="ch5_head"><code>UnderstandingSourceObjects</code></td> <td valign="top" headers="ch5_descr">The following examples, and two informal untitled examples, are implemented as methods of this class. <P> Example 5-1, Getting the Data Type of a Source.<br> Example 5-2, Using the isSubtypeOf Method.<br> Example 5-3, Using the join Method To Produce a Source Without an Output.<br> Example 5-4, Using the join Method To Produce a Source With an Output.<br> Example 5-5, Using the join Method To Match Source Objects To Inputs.<br> Example 5-6, Using Shortcuts.<br> Example 5-7, Matching the Base Source to an Input of the Joined Source.<br> Example 5-8, Matching an Input of the Base Source to an Output of the Joined Source.<br> Example 5-9, Matching the Inputs of a Measure and Producing Outputs. </td> </tr> <tr> <td valign="top" headers="ch5_pkg"><code>source</code></a></td> <td valign="top" headers="ch5_head"><code>UsingParamSourceWithMeasDim</code></td> <td valign="top" headers="ch5_descr">Example 5-10, Using a Parameterized Source With a Measure Dimension.</td> </tr> <tr> <td valign="top" headers="ch5_pkg"><code>source</code></a></td> <td valign="top" headers="ch5_head"><code>ImplementingExtractAsACustomModel</code></td> <td valign="top" headers="ch5_descr">Example 5-11, Implementing the extract Method as a CustomModel.</td> </tr> <!-- <tr> <td valign="top" headers="ch5_pkg"><code>source</code></a></td> <td valign="top" headers="ch5_head"><code>CreateDependentAssignment</code></td> <td valign="top" headers="ch5_descr">Example 5-12, Creating an Assignment That Depends on Another Assignment.</td> </tr> <tr> <td valign="top" headers="ch5_pkg"><code>source</code></a></td> <td valign="top" headers="ch5_head"><code>CreateCustomMemberWithAggVal</code></td> <td valign="top" headers="ch5_descr">Example 5-13, Creating a Custom Member That Assigns an Aggregated Value.</td> </tr> --> </tbody> </table> <H3>Examples in Chapter 6</H3> The following table lists the examples that appear in Chapter 6, "Making Queries Using Source Methods", and the example programs that contain the code for the examples. <P> <table title="Examples in Chapter 6" summary="This table describes the classes that have the code of the examples in Chapter 6." border cellspacing="0" cellpadding="5"> <thead> <tr> <th align="center" id="ch6_pkg">Package</th> <th align="center" id="ch6_head">Class</td> <th align="center" id="ch6_descr">Description</th> </tr> </thead> <tbody> <tr> <td valign="top" headers="ch6_pkg"><code>source</code></a></td> <td valign="top" headers="ch6_head"><code>MakingQueriesExamples</code></td> <td align="top" headers="ch6_descr">The following examples are implemented as methods of this class. <P> Example 6-1, Controlling Input-to-Source Matching With the alias Method.<br> Example 6-2, Using the distinct Method.<br> Example 6-3, Using COMPARISON_RULE_REMOVE.<br> Example 6-4, Using COMPARISON_RULE_DESCENDING.<br> Example 6-5, Selecting the First and Last Time Elements.<br> Example 6-7, Selecting a Subset of the Elements of a Source.<br> Example 6-8, Using the extract Method<br> Example 6-11, Hierarchical Sorting by Measure Value. </td> </tr> <tr> <td valign="top" headers="ch6_pkg"><code>source</code></a></td> <td valign="top" headers="ch6_head"><code>SortingHierarchicallyByAttribute</code></td> <td valign="top" headers="ch6_descr">Example 6-6, Sorting Products Hierarchically By Attribute.</td> </tr> <tr> <td valign="top" headers="ch6_pkg"><code>source</code></a></td> <td valign="top" headers="ch6_head"><code>CreatingCubeAndPivotingEdges</code></td> <td valign="top" headers="ch6_descr">Example 6-9, Creating a Cube and Pivoting Its Edges.</td> </tr> <tr> <td valign="top" headers="ch6_pkg"><code>source</code></a></td> <td valign="top" headers="ch6_head"><code>DrillingInHierarchy</code></td> <td valign="top" headers="ch6_descr">Example 6-10, Drilling in a Hierarchy.</td> </tr> <tr> <td valign="top" headers="ch6_pkg"><code>source</code></a></td> <td valign="top" headers="ch6_head"><code>GettingShareOfUnits</code></td> <td valign="top" headers="ch6_descr">Example 6-12, Getting the Share of Units Sold.</td> </tr> <tr> <td valign="top" headers="ch6_pkg"><code>source</code></a></td> <td valign="top" headers="ch6_head"><code>UsingLagMethod</code></td> <td valign="top" headers="ch6_descr">Example 6-13, Using the Lag Method.</td> </tr> <tr> <td valign="top" headers="ch6_pkg"><code>source</code></a></td> <td valign="top" headers="ch6_head"><code>UsingMovingTotalMethod</code></td> <td valign="top" headers="ch6_descr">Example 6-14, Using the movingTotal Method.</td> </tr> <tr> <td valign="top" headers="ch6_pkg"><code>source</code></a></td> <td valign="top" headers="ch6_head"><code>SelectingRangeWithNumberParam</code></td> <td valign="top" headers="ch6_descr">Example 6-15, Selecting a Range With NumberParameter Objects.</td> </tr> </tbody> </table> <H3>Examples in Chapter 7</H3> The following table lists the examples that appear in Chapter 7, "Using a TransactionProvider", and the example programs that contain the code for the examples. <P> <table title="Examples in Chapter 7" summary="This table describes the classes that have the code of the examples in Chapter 7." border cellspacing="0" cellpadding="5"> <thead> <tr> <th align="center" id="ch7_pkg">Package</th> <th align="center" id="ch7_head">Class</td> <th align="center" id="ch7_descr">Description</th> </tr> </thead> <tbody> <tr> <td valign="top" headers="ch7_pkg"><code>transaction</code></a></td> <td valign="top" headers="ch7_head"><code>TransactionExamples</code></td> <td valign="top" headers="ch7_descr">The following examples are implemented as methods of this class. <P> Example 7-1, Rolling Back a Transaction.<br> Example 7-2, Using Child Transaction Objects.</td> </tr> </tbody> </table> <H3>Examples in Chapter 8</H3> The following table lists the examples that appear in Chapter 8, "Understanding Cursor Classes and Objects", and the example programs that contain the code for the examples. <P> <table title="Examples in Chapter 8" summary="This table describes the classes that have the code of the examples in Chapter 8." border cellspacing="0" cellpadding="5"> <thead> <tr> <th align="center" id="ch8_pkg">Package</th> <th align="center" id="ch8_head">Class</td> <th align="center" id="ch8_descr">Description</th> </tr> </thead> <tbody> <tr> <td valign="top" headers="ch8_pkg"><code>cursor</code></a></td> <td valign="top" headers="ch8_head"><code>CursorConceptsExamples</code></td> <td valign="top" headers="ch8_descr">The following examples, and an informal example, are implemented as methods of this class. <P> Example 8-1, Creating the querySource Query.<br> Example 8-2, Setting the CompoundCursor Position and Getting the Current Values.<br> Example 8-3, Positions in an Asymmetric Query.</td> </tr> </tbody> </table> <H3>Examples in Chapter 9</H3> The following table lists the examples that appear in Chapter 9, "Retrieving Query Results", and the example programs that contain the code for the examples. <P> <table title="Examples in Chapter 9" summary="This table describes the classes that have the code of the examples in Chapter 9." border cellspacing="0" cellpadding="5"> <thead> <tr> <th align="center" id="ch9_pkg">Package</th> <th align="center" id="ch9_head">Class</td> <th align="center" id="ch9_descr">Description</th> </tr> </thead> <tbody> <tr> <td valign="top" headers="ch9_pkg"><code>cursor</code></a></td> <td valign="top" headers="ch9_head"><code>RetrievingQueryResults</code></td> <td valign="top" headers="ch9_descr">The following examples are implemented as methods of this class. <P> Example 9-1, Creating a Cursor.<br> Example 9-2, Getting a Single Value from a ValueCursor.<br> Example 9-3, Getting All of the Values from a ValueCursor.<br> Example 9-4, Getting ValueCursor Objects from a CompoundCursor example.<br> Example 9-5, Getting Values from a CompoundCursor with Nested Outputs example.<br> Example 9-6, Navigating For a Table View.<br> Example 9-7, Navigating For a Crosstab View Without Pages.<br> Example 9-8, Navigating For a Crosstab View With Pages.<br> Example 9-9, Getting CursorSpecification Objects for a Source.<br> Example 9-10, Specifying the Calculation of the Extent of a Cursor.<br> Example 9-11, Specifying the Calculation of Starting and Ending Positions in a Parent.<br> Example 9-12, Calculating the Span of the Positions in the Parent of a Value.<br> Example 9-13, Specifying a Fetch Size.</td> </tr> </tbody> </table> <H3>Examples in Chapter 10</H3> The following table lists the examples that appear in Chapter 10, "Creating Dynamic Queries, and the example programs that contain the code for the examples. <P> <table title="Examples in Chapter 10" summary="This table describes the classes that have the code of the examples in Chapter 10." border cellspacing="0" cellpadding="5"> <thead> <tr> <th align="center" id="ch10_pkg">Package</th> <th align="center" id="ch10_head">Class</CODE></td> <th align="center" id="ch10_descr">Description</th> </tr> </thead> <tbody> <tr> <td valign="top" headers="ch10_pkg"><code>template</code></a></td> <td valign="top" headers="ch10_head"><code>TopBottomTemplate</code></td> <td valign="top" headers="ch10_descr">Example 10-1, Implementing a Template. <P> The following examples are implemented as inner classes of <code>TopBottomTemplate</code>. <P> Example 10-2, Implementing a MetadataState.<br> Example 10-3, Implementing a SourceGenerator.</td> </tr> <tr> <td valign="top" headers="ch10_pkg"><code>template</code></a></td> <td valign="top" headers="ch10_head"><code>TopBottomTest</code></td> <td valign="top" headers="ch10_descr">Example 10-4, Getting the Source Produced by the Template.</td> </tr> <tr> <td valign="top" headers="ch10_pkg"><code>template</code></a></td> <td valign="top" headers="ch10_head"><code>SingleSelectionTemplate</code></td> <td valign="top" headers="ch10_descr">A <code>Template</code> that is used by <code>TopBottomTest</code>.</td> </tr> </tbody> </table> <P> <P> <hr> <center>Copyright © 2002, 2007, Oracle. All rights reserved.</center> </BODY> </HTML>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de