com.sas.graphics.components
Class GraphOLAPDataSet

com.sas.graphics.components.GraphOLAPDataSet
All Implemented Interfaces:
com.sas.collection.ContentsChangedListener, com.sas.collection.ContentsChangedSource, OLAPDataSetInterface, ResultSetInterface, java.util.EventListener

public class GraphOLAPDataSet
implements OLAPDataSetInterface, com.sas.collection.ContentsChangedListener, com.sas.collection.ContentsChangedSource

A class for sharing setup work between graph olap viewers that are sharing a single olap model. An instance of GraphOLAPDataSet should be shared among all graph viewers. Here is sample code for setting up a BarChart and a PieChart using the GraphOLAPDataSet:

 
  
   
    OLAPDataSetInterface olap=...
    GraphOLAPDataSet graphOlap=new GraphOLAPDataSet();
    graphOlap.setDelegateModel(olap);
    
    BarChartOLAPDataModel barData = new BarChartOLAPDataModel(graphOlap);
    BarChart barChart=new BarChart(barData);
    barChart.setActionProvider(actionProvider);
    
    PieChartOLAPDataModel pieData = new PieChartOLAPDataModel(graphOlap);
    PieChart pieChart=new PieChart(barData);
    pieChart.setActionProvider(actionProvider);
    
   
  
 
This class delegates all OLAPDataSetInterface method calls to the delegate model.


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
GraphOLAPDataSet()
           
 
Method Summary
 void addContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
          Add a listener for com.sas.commands.ActionProviderEvent events.
 void close()
          Close the ResultSetInterface
 void contentsChanged(com.sas.collection.ContentsChangedEvent e)
           
 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()
          Returns the connection to the OLAP server.
 int getContextType()
          Get the context type.
 java.lang.String getCubeName()
          Get the cubename associated with the current query
 MetadataInterface getDatabaseMetadata()
          This method returns an instance of the MetadataInterface which defines all of the Cubes' metadata on the OLAP Server to which the model is connected.
 OLAPDataSetInterface getDelegateModel()
          Get the delegate model.
 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.lang.Object getGraphInfo()
          Get olap graph information.
static java.lang.Object getGraphInfo(OLAPDataSetInterface olap)
          Get olap graph information given an OLAPDataSetInterface.
 java.util.Locale getLocale()
          Returns the locale used for the session.
 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()
          An instance of the OLAPDataSetInterface may be readOnly.
 void removeAllContentsChangedListeners()
          Remove all ContentsChangedListener's.
 void removeContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
          Remove a listener for ContentsChanged events.
 void setCells(long startCell, long endCell, java.lang.Object[] cellValues)
          Sets the values for the cells.
 void setConnection(java.lang.Object con)
          Sets the connection to the OLAP server.
 void setContextType(int contextType)
          Set the context type.
 void setDelegateModel(OLAPDataSetInterface olapDataSet)
          Set the delegate model.
 void setFormattedCells(long startCell, long endCell, java.lang.String[] cellValues)
          Sets the formatted values for the cells.
 void setLocale(java.util.Locale locale)
          Sets the locale for the session object
 void setPerformanceTuning(PerformanceTuning performanceTuning)
          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)
          Sets the updateable state of the OLAPDataSet.
 

Constructor Detail

GraphOLAPDataSet

public GraphOLAPDataSet()
Method Detail

setDelegateModel

public void setDelegateModel(OLAPDataSetInterface olapDataSet)
Set the delegate model.

Parameters:
olapDataSet -
Throws:
OLAPException
See Also:
getDelegateModel()

getDelegateModel

public OLAPDataSetInterface getDelegateModel()
Get the delegate model.

Returns:
@see setDelegateModel()

getGraphInfo

public static java.lang.Object getGraphInfo(OLAPDataSetInterface olap)
                                     throws OLAPException
Get olap graph information given an OLAPDataSetInterface. If the given OLAPDataSetInterface is an instance of a GraphOLAPDataSet, then its graph information is returned. Otherwise, new information is created and returned.

Parameters:
olap -
Returns:
@throws OLAPException
Throws:
OLAPException

getGraphInfo

public java.lang.Object getGraphInfo()
                              throws OLAPException
Get olap graph information.

Returns:
OLAPVariableFactory
Throws:
OLAPException

addContentsChangedListener

public void addContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
Add a listener for com.sas.commands.ActionProviderEvent events.

Specified by:
addContentsChangedListener in interface com.sas.collection.ContentsChangedSource
Parameters:
listener -

removeContentsChangedListener

public void removeContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
Remove a listener for ContentsChanged events.

Specified by:
removeContentsChangedListener in interface com.sas.collection.ContentsChangedSource
Parameters:
listener -

removeAllContentsChangedListeners

public void removeAllContentsChangedListeners()
Remove all ContentsChangedListener's.


contentsChanged

public void contentsChanged(com.sas.collection.ContentsChangedEvent e)
Specified by:
contentsChanged in interface com.sas.collection.ContentsChangedListener

close

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

Specified by:
close in interface ResultSetInterface
Throws:
OLAPException

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 -
endCell -
cellValues -
Throws:
OLAPException

setPerformanceTuning

public void setPerformanceTuning(PerformanceTuning performanceTuning)
                          throws OLAPException
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
Parameters:
performanceTuning -
Throws:
OLAPException

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 -
endCell -
Returns:
@throws com.sas.storage.olap.OLAPException
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:
@throws com.sas.storage.olap.OLAPException
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 -
endCell -
Returns:
@throws com.sas.storage.olap.OLAPException
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 -
Throws:
OLAPException

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

isReadOnly

public boolean isReadOnly()
                   throws OLAPException
Description copied from interface: ResultSetInterface
An instance of the OLAPDataSetInterface may be readOnly. Attempts to update a readOnly OLAPDataSet will result in an OLAPException being thrown.

Specified by:
isReadOnly in interface ResultSetInterface
Returns:
@throws com.sas.storage.olap.OLAPException
Throws:
OLAPException - If a database-access error occurs

getConnection

public java.lang.Object getConnection()
                               throws OLAPException
Description copied from interface: OLAPDataSetInterface
Returns the connection to the OLAP server. This value may be null in cases where the OLAPDataSet in not connected.

Specified by:
getConnection in interface OLAPDataSetInterface
Returns:
@throws com.sas.storage.olap.OLAPException
Throws:
OLAPException - if a database error occurs

setConnection

public void setConnection(java.lang.Object con)
                   throws OLAPException
Description copied from interface: OLAPDataSetInterface
Sets the connection to the OLAP server.

Specified by:
setConnection in interface OLAPDataSetInterface
Parameters:
con -
Throws:
OLAPException

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws OLAPException
Description copied from interface: OLAPDataSetInterface
Sets the updateable state of the OLAPDataSet. Not all OLAPDataSetInterfaces are updateable, and an OLAPException will be thrown if updates are not supported and readOnly is set to false.

Specified by:
setReadOnly in interface OLAPDataSetInterface
Parameters:
readOnly -
Throws:
OLAPException

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
Parameters:
contextType -
Throws:
OLAPException

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 -
endCell -
cellValues -
Throws:
OLAPException

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 -
Throws:
OLAPException

getCubeName

public java.lang.String getCubeName()
                             throws OLAPException
Description copied from interface: OLAPDataSetInterface
Get the cubename associated with the current query

Specified by:
getCubeName in interface OLAPDataSetInterface
Returns:
@throws com.sas.storage.olap.OLAPException
Throws:
OLAPException - if the cubename cannot be

getContextType

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

Specified by:
getContextType in interface OLAPDataSetInterface
Returns:
@throws com.sas.storage.olap.OLAPException
Throws:
OLAPException - if cannot set the context type.

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:
@throws com.sas.storage.olap.OLAPException
Throws:
OLAPException - if a database error occurs

getDatabaseMetadata

public MetadataInterface getDatabaseMetadata()
                                      throws OLAPException
Description copied from interface: OLAPDataSetInterface
This method returns an instance of the MetadataInterface which defines all of the Cubes' metadata on the OLAP Server to which the model is connected. Implementations which do not support this MetadataInterface should return null.

Specified by:
getDatabaseMetadata in interface OLAPDataSetInterface
Returns:
@throws com.sas.storage.olap.OLAPException
Throws:
OLAPException - If a database error occurs

getLocale

public java.util.Locale getLocale()
                           throws OLAPException
Description copied from interface: OLAPDataSetInterface
Returns the locale used for the session.

Specified by:
getLocale in interface OLAPDataSetInterface
Returns:
@throws com.sas.storage.olap.OLAPException
Throws:
OLAPException - if a database error occurs

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:
@throws com.sas.storage.olap.OLAPException
Throws:
OLAPException

setLocale

public void setLocale(java.util.Locale locale)
               throws OLAPException
Description copied from interface: OLAPDataSetInterface
Sets the locale for the session object

Specified by:
setLocale in interface OLAPDataSetInterface
Parameters:
locale -
Throws:
OLAPException

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:
@throws com.sas.storage.olap.OLAPException
Throws:
OLAPException - if a database error occurs



Copyright © 2009 SAS Institute Inc. All Rights Reserved.