com.sas.storage.olap.embedded
Class OLAPDataSet

com.sas.storage.olap.embedded.OLAPDataSet
All Implemented Interfaces:
OLAPDataSetInterface, ResultSetInterface

public class OLAPDataSet
implements OLAPDataSetInterface

The OLAPDataSet together with the ResultSetInterface, ResultSetMetadataInterface, AxisInterface, TupleInterface, TupleElementInterface, and PerformanceTuningInterface make up the Data portion of the MD model. The ResultSetInterface is the central interface for setting the data and the structure or shape of that data. The structure of the data is defined by the ResultSetMetadataInterface, which is directly accessible via the ResultSetInterface. The AxisInterface, TupleInterface, and TupleElementInterface are the metadata components for the ResultSetMetadata. The OLAPDataSetInterface brings them all together. An OLAPDataSet object is the Java Data Model that should be attached to MD viewers, roughly equivalent to a JDBC RowSet. The OLAPDataSetInterface extends the functionality of the ResultSetInterface and PerformanceTuningInterface. Only one ResultSet is available within the OLAPDataSetInterface at any point in time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different OLAPDataSetInterface objects.


Field Summary
 
Fields inherited from interface com.sas.storage.olap.OLAPDataSetInterface
DEFAULT_CONTEXT_TYPE, NO_CONTEXT_TYPE
 
Fields inherited from interface com.sas.storage.olap.ResultSetInterface
DEFAULT_END_CELL, DEFAULT_ENDCELL
 
Constructor Summary
OLAPDataSet()
           
OLAPDataSet(ResultSetInterface resultSet)
           
 
Method Summary
 void close()
          Close the ResultSetInterface
 void executeQuery()
          Executes the current query statement, which can be retrieved via the getQueryStatement() method.
 void executeQuery(java.lang.String queryStatement)
          Executes the query statement that is passed in as a parameter.
 long getCellCount()
          Returns the total number of cells defined in the ResultSet.
 java.lang.Object[] getCells(long startCell, long endCell)
          Returns the unformatted data slice beginning with the startCell (upper left corner ordinal) and ending with endCell (lower right corner ordinal).
 java.lang.Object getConnection()
          This will always return null, since there is on connection in the embedded version
 int getContextType()
          Get the context type.
 java.lang.String getCubeName()
          Return the cubeName for the embedded model if it is set, otherwise null
 MetadataInterface getDatabaseMetadata()
          This implementation returns null.
 java.lang.String[] getFormattedCells(long startCell, long endCell)
          Returns the formatted data slice beginning with the startCell (upper left corner ordinal) and ending with endCell (lower right corner ordinal).
 java.util.Locale getLocale()
          This will always return null, since there is on connection in the embedded version
 PerformanceTuning getPerformanceTuning()
          This method returns a performanceTuning object on the model.
 java.lang.String getQueryStatement()
          Returns the most recent query statement.
 ResultSetMetadataInterface getResultSetMetadata()
          Returns the metadata that defines the structure of the ResultSet
 boolean isReadOnly()
          This implementation will always return true.
 void setCells(long startCell, long endCell, java.lang.Object[] cellValues)
          Sets the values for the cells.
 void setConnection(java.lang.Object connection)
          This defines a connection to the SAS OLAP server.
 void setContextType(int contextType)
          Set the context type.
 void setCubeName(java.lang.String cubeName)
          Set the cube name for this olap dataset
 void setFormattedCells(long startCell, long endCell, java.lang.String[] cellValues)
          Sets the formatted values for the cells.
 void setLocale(java.util.Locale locale)
          This defines a connection to the SAS OLAP server.
 void setPerformanceTuning(PerformanceTuning pf)
          Set the PerformanceTuning Object on this model.
 void setQueryStatement(java.lang.String queryStatement)
          Sets the query statement, but does not execute the query.
 void setReadOnly(boolean readOnly)
          The readOnly state may only be set to true.
 

Constructor Detail

OLAPDataSet

public OLAPDataSet()
            throws OLAPException
Throws:
OLAPException

OLAPDataSet

public OLAPDataSet(ResultSetInterface resultSet)
            throws OLAPException
Throws:
OLAPException
Method Detail

getContextType

public int getContextType()
                   throws OLAPException
Description copied from interface: OLAPDataSetInterface
Get the context type.

Specified by:
getContextType in interface OLAPDataSetInterface
Returns:
context type set on the resultSet. Currently there are only two types, DEFAULT_CONTEXT_TYPE and NO_CONTEXT_TYPE
Throws:
OLAPException - if cannot set the context type.

setContextType

public void setContextType(int contextType)
                    throws OLAPException
Description copied from interface: OLAPDataSetInterface
Set the context type. The context type determines whether a tuple element in the resultset has context applied to it or not. For example, a tupleElement Jan will be displayed as '1997.Jan' if it is with context and simply 'Jan' if has no context.

Specified by:
setContextType in interface OLAPDataSetInterface
Throws:
OLAPException - if cannot set the context type.

getConnection

public java.lang.Object getConnection()
                               throws OLAPException
This will always return null, since there is on connection in the embedded version

Specified by:
getConnection in interface OLAPDataSetInterface
Returns:
connection will always retunr null, since there is no connection
Throws:
OLAPException - if a database error occurs

setConnection

public void setConnection(java.lang.Object connection)
                   throws OLAPException
This defines a connection to the SAS OLAP server.

Specified by:
setConnection in interface OLAPDataSetInterface
Parameters:
connection - for this result set
Throws:
OLAPException - if the connection cannot be set

getLocale

public java.util.Locale getLocale()
                           throws OLAPException
This will always return null, since there is on connection in the embedded version

Specified by:
getLocale in interface OLAPDataSetInterface
Returns:
connection will always retunr null, since there is no connection
Throws:
OLAPException - if a database error occurs

setLocale

public void setLocale(java.util.Locale locale)
               throws OLAPException
This defines a connection to the SAS OLAP server.

Specified by:
setLocale in interface OLAPDataSetInterface
Parameters:
connection - for this result set
Throws:
OLAPException - if the connection cannot be set

executeQuery

public void executeQuery(java.lang.String queryStatement)
                  throws OLAPException
Description copied from interface: OLAPDataSetInterface
Executes the query statement that is passed in as a parameter. The execution of this query will generate a new ResultSet. This method will implicitly close the current ResultSet object if an open one exists.

Specified by:
executeQuery in interface OLAPDataSetInterface
Parameters:
queryStatement - The query statement
Throws:
OLAPException - if a database error occurs

executeQuery

public void executeQuery()
                  throws OLAPException
Description copied from interface: OLAPDataSetInterface
Executes the current query statement, which can be retrieved via the getQueryStatement() method. The execution of this query will generate a new ResultSet. This method will implicitly close the current ResultSet object if an open one exists.

Specified by:
executeQuery in interface OLAPDataSetInterface
Throws:
OLAPException - if a database error occurs

setQueryStatement

public void setQueryStatement(java.lang.String queryStatement)
                       throws OLAPException
Description copied from interface: OLAPDataSetInterface
Sets the query statement, but does not execute the query. To execute the query, use the executeQuery() method. If the query statement is set, but not executed the ResultSet object will not be in sync with the queryStatement property. The ResultSet is a reflection of the last query that was executed.

Specified by:
setQueryStatement in interface OLAPDataSetInterface
Parameters:
queryStatement - The query to be executed
Throws:
OLAPException - if a database error occurs

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws OLAPException
The readOnly state may only be set to true. This implementation does not support updates.

Specified by:
setReadOnly in interface OLAPDataSetInterface
Parameters:
readOnly - The updateable state of the OLAPDataSet.
Throws:
OLAPException - If a database-access error occurs

getDatabaseMetadata

public MetadataInterface getDatabaseMetadata()
                                      throws OLAPException
This implementation returns null.

Specified by:
getDatabaseMetadata in interface OLAPDataSetInterface
Returns:
metadata An instance of the MetadataInterface that shares the same connection as the Data Model
Throws:
OLAPException - If a database error occurs

getResultSetMetadata

public ResultSetMetadataInterface getResultSetMetadata()
                                                throws OLAPException
Description copied from interface: ResultSetInterface
Returns the metadata that defines the structure of the ResultSet

Specified by:
getResultSetMetadata in interface ResultSetInterface
Returns:
The ResultSetMetadata which defines the structure of the ResultSet.
Throws:
OLAPException - if a database error occurs

getQueryStatement

public java.lang.String getQueryStatement()
                                   throws OLAPException
Description copied from interface: ResultSetInterface
Returns the most recent query statement. This value should be used as a hint for the query that may have generated this ResultSet. It's possible that this value could be null or out of date if the ResultSet is not connected. It is also possible that this query is not in sync with the ResultSet. It could have been set, but not executed, in which case the ResultSet is not a product of this query.

Specified by:
getQueryStatement in interface ResultSetInterface
Returns:
The most recent query statement.
Throws:
OLAPException - if a database error occurs

isReadOnly

public boolean isReadOnly()
                   throws OLAPException
This implementation will always return true. The OLAPDataSet is not updateable.

Specified by:
isReadOnly in interface ResultSetInterface
Returns:
Indicates whether this OLAPDataSet is updateable
Throws:
OLAPException - If a database-access error occurs

getCells

public java.lang.Object[] getCells(long startCell,
                                   long endCell)
                            throws OLAPException
Description copied from interface: ResultSetInterface
Returns the unformatted data slice beginning with the startCell (upper left corner ordinal) and ending with endCell (lower right corner ordinal). Because these parameters are used to identify the slice, not all cells between startCell and endCell are necessarily fetched. The cell ordinal can be calculated based on the crossing of tuple coordinates. There are utility methods available in OLAPUtil for making these calculations and details as to how they are calculated.

Specified by:
getCells in interface ResultSetInterface
Parameters:
startCell - A zero-based ordinal position for the starting cell.
endCell - A zero-based ordinal position for the ending cell where DEFAULT_ENDCELL can be used to indicate all remaining cells
Returns:
The data in its raw format.
Throws:
OLAPException - if a database error occurs

getFormattedCells

public java.lang.String[] getFormattedCells(long startCell,
                                            long endCell)
                                     throws OLAPException
Description copied from interface: ResultSetInterface
Returns the formatted data slice beginning with the startCell (upper left corner ordinal) and ending with endCell (lower right corner ordinal). Because these parameters are used to identify the slice, not all cells between startCell and endCell are necessarily fetched. The cell ordinal can be calculated based on the crossing of tuple coordinates. There are utility methods available in OLAPUtil for making these calculations and details as to how they are calculated.

Specified by:
getFormattedCells in interface ResultSetInterface
Parameters:
startCell - A zero-based ordinal position for the starting cell.
endCell - A zero-based ordinal position for the ending cell where DEFAULT_ENDCELL can be used to indicate all remaining cells
Returns:
The formatted data.
Throws:
OLAPException - if a database error occurs

getCellCount

public long getCellCount()
                  throws OLAPException
Description copied from interface: ResultSetInterface
Returns the total number of cells defined in the ResultSet.

Specified by:
getCellCount in interface ResultSetInterface
Returns:
The total number of cells defined in the ResultSet.
Throws:
OLAPException - if a database error occurs

setCells

public void setCells(long startCell,
                     long endCell,
                     java.lang.Object[] cellValues)
              throws OLAPException
Description copied from interface: ResultSetInterface
Sets the values for the cells. This ResultSet may not be updateable. An OLAPException will be thrown if updates cannot be made.

Specified by:
setCells in interface ResultSetInterface
Parameters:
startCell - A zero-based ordinal position for the starting cell.
endCell - A zero-based ordinal position for the ending cell.
cellValues - Sets the values for the cells.
Throws:
OLAPException - if a database error occurs

setFormattedCells

public void setFormattedCells(long startCell,
                              long endCell,
                              java.lang.String[] cellValues)
                       throws OLAPException
Description copied from interface: ResultSetInterface
Sets the formatted values for the cells. This ResultSet may not be updateable. An OLAPException will be thrown if updates cannot be made.

Specified by:
setFormattedCells in interface ResultSetInterface
Parameters:
startCell - A zero-based ordinal position for the starting cell.
endCell - A zero-based ordinal position for the ending cell.
cellValues - Sets the formatted values for the cells.
Throws:
OLAPException - if a database error occurs

close

public void close()
           throws OLAPException
Description copied from interface: ResultSetInterface
Close the ResultSetInterface

Specified by:
close in interface ResultSetInterface
Throws:
OLAPException - if a database error occurs

getCubeName

public java.lang.String getCubeName()
                             throws OLAPException
Return the cubeName for the embedded model if it is set, otherwise null

Specified by:
getCubeName in interface OLAPDataSetInterface
Returns:
name of the cube.
Throws:
OLAPException - if the cubename cannot be

setCubeName

public void setCubeName(java.lang.String cubeName)
                 throws OLAPException
Set the cube name for this olap dataset

Parameters:
cubeName -
Throws:
OLAPException

getPerformanceTuning

public PerformanceTuning getPerformanceTuning()
                                       throws OLAPException
Description copied from interface: OLAPDataSetInterface
This method returns a performanceTuning object on the model. This can be null if the query has not been set. User can create a new PerformanceTuning object and set it on the model. The returned object may be different than the set object, in case of it being set on multiple models. The model checks for an existence of model (property) on the passed in object and if there is one, it makes a copy of the passed in object and sets it on this model. In other words there is one to one relationship between model and the performance tuning object.

Specified by:
getPerformanceTuning in interface OLAPDataSetInterface
Returns:
performanceTuning object
Throws:
OLAPException

setPerformanceTuning

public void setPerformanceTuning(PerformanceTuning pf)
Description copied from interface: OLAPDataSetInterface
Set the PerformanceTuning Object on this model. Nothing will happen if the object is null. Since each instance of model has its own performance tuning, if this object is derived from another model or it is already set on another model, a copy of the perfroamnceTuning object will be made before setting it on this model. In other words, a get may not return the same object as the set.

Specified by:
setPerformanceTuning in interface OLAPDataSetInterface



Copyright © 2009 SAS Institute Inc. All Rights Reserved.