Provides a set of classes for accessing OLAP data from the SAS OLAP Server.

OVERVIEW

This package provides a set of classes which implement the interfaces defined in com.sas.storage.olap. This implementation provides access to the SAS OLAP Server and can be used to execute data queries, primarily MDX, and read the results of these queries. It can also be used to request and read metadata from OLAP data sources, known as Cubes.

EXAMPLES

Data Access

> Execute an MDX Query and Print the Results

> try {

> // Create instance of OLAPDataSet
> OLAPDataSetInterface olapDataSet = new OLAPDataSet("hostname", port, "username", "password");

> // Execute the MDX Query
> String queryStatement = "sample MDX Query";
> olapDataSet.executeQuery(queryStatement);
> // Print Cell Data
> Object[] cells = olapDataSet.getCells(0, OLAPDataSet.DEFAULT_ENDCELL);
> System.out.println("--Unformatted cell values--");
> for (int i = 0; i < cells.length; i++) {
> System.out.println(i + ": " + (cells[i]).toString());
> }
> String[] formattedCells = olapDataSet.getFormattedCells(0, OLAPDataSet.DEFAULT_ENDCELL);
> System.out.println("--Formatted cell values--");
> for (int i = 0; i < formattedCells.length; i++) {
> System.out.println(i + ": " + formattedCells[i]);
> }

> // Get the ResultSet Metadata
> ResultSetMetadataInterface rsm = olapDataSet.getResultSetMetadata();

> // Print Basic Axis Information
> AxisInterface[] axes = rsm.getAxes(0, -1);
> System.out.println("Axis count = " + axes.length);

> for (int i = 0; i < axes.length; i++) {
> System.out.println("Axis Number: " + axes[i].getAxisNumber());
> System.out.println("Tuple Count: " + axes[i].getTupleCount());
> String[] axisHeaders = axes[i].getAxisHeaders();
> System.out.print("Axis Headers: ");

> for (int j = 0; j < axisHeaders.length; j++) {
> System.out.print(" " + axisHeaders[j]);
> }

> String[] dimensionNames = axes[i].getDimensionNames();
> System.out.print("Dimension Names: ");
> for (int j = 0; j < dimensionNames.length; j++) {
> System.out.print(" " + dimensionNames[j]);
> }

> // Print Basic Tuple Information
> TupleInterface[] tuples = axes[i].getTuples(0, -1);
> for (int j = 0; j < tuples.length; j++) {
> System.out.println("Tuple Coordinate: " + tuples[j].getTupleIndex());
> // Print Basic Tuple Element Information
> TupleElementInterface[] tupleElements = tuples[j].getElements(0, -1);

> for (int k = 0; k < tupleElements.length; k++) {
> System.out.println("Tuple Element label: " + tupleElements[k].getLabel());
> System.out.println("TupleElement minimumCoordinate: " + tupleElements[k].getMinimumCoordinate());
> System.out.println("TupleElement maximumCoordinate: " + tupleElements[k].getMaximumCoordinate());
> }
> }
> }
> // Close the OLAPDataSet
> olapDataSet.close();

> }
> catch (OLAPException ex) {
> System.out.println(ex.getMessage());
> ex.printStackTrace();
> }

Metadata Access

> Query Cube Metadata and Print the Results

> try {

> // Create instance of Metadata
> MetadataInterface metadata = new Metadata("hostname", port, "username", "password");

> // Alternatively, an instance of the Metadata class can be gotten from an instance of the OLAPDataSet
> // MetadataInterface metadata = olapDataSet.getDatabaseMetadata();

> // Build a Filter using the cube name restriction
> Filter filter =

> new Filter();
> filter.setCubeName("MyCube");

> // Print Basic Cube Information
> System.out.println("--Cubes--");
> CubeInterface[] cubes = metadata.getCubes(filter);
> for (int i = 0; i < cubes.length; i++) {
> System.out.println(cubes[i].getLabel());
> }

> // Print Basic Measure Information
> System.out.println("--Measures--");
> MeasureInterface[] measures = metadata.getMeasures(filter);
> for (int i = 0; i < measures.length; i++) {
> String measureLabel = measures[i].getLabel();
> System.out.println("Measure Label: " + measureName);
> String measureUniqueName = measures[i].getUniqueName();
> System.out.println("Measure Unique Name: " + measureUniqueName);
> }

> // Print Basic Dimension Information (using Cube to acquire Dimensions)
> System.out.println("--Dimensions--");
> DimensionInterface[] dimensions = cubes[0].getDimensions();

> for (int i = 0; i < dimensions.length; i++) {
> System.out.println("Dimension Label: " + dimensions[i].getLabel());
> System.out.println("Dimension Unique Name: " + dimensions[i].getUniqueName());

> // Print Basic Hierarchy Information (using Dimension to acquire Hierarchies)
> System.out.println("--Hierarchies--");
> HierarchyInterface[] hierarchies = dimensions[i].getHierarchies();
> for (int j = 0; j < hierarchies.length; j++) {
> System.out.println("Hierarchy Label: " + hierarchies[j].getLabel());
> System.out.println("Hierarchy Unique Name: " + hierarchies[j].getUniqueName());

> // Print Basic Level Information (using Hierarchy to acquire Levels)
> System.out.println("--Levels--");
> LevelInterface[] levels = hierarchies[j].getLevels();
> for (int k = 0; k < levels.length; k++) {
> System.out.println("Level Label: " + levels[k].getLabel());
> System.out.println("Level Unique Name: " + levels[k].getUniqueName());
> }
> }
> }

> }
> catch (OLAPException ex) {
> System.out.println(ex.getMessage());
> ex.printStackTrace();
> }

For More Information

> Visit the AppDev Studio Developer's Site to access step-by-step examples, white papers and additional usage information at http://support.sas.com/rnd/appdev/.