All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Query |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

*** This class is subject to change. ***

## com.sas.iquery.util
Class BusinessQueryOLAPUtil

    com.sas.iquery.util.BusinessQueryOLAPUtil

    public class BusinessQueryOLAPUtil

Provides utility methods that enable consumers to obtain OLAP information such as the dimension name or dimension type of an OLAP item. The BusinessQueryOLAPUtil helps provide consumers utilizing OLAP data items set with ResourceAwareStringExpressions so that the following information can be retrieved:

- Dimension name
- Dimension type
- Cube name
- If it is not a measure, the unique name with hierarchy all member
- Names for com.sas.iquery.metadata.physical Dimensions, Hierarchies, Levels, and Measures

Note: Not all methods in this class will work when using results from a ROLAP query. An example that is supported occurs when a user is exporting a ROLAP (relational) data source shown in a crosstab (which is an OLAP visual component) to an Excel spreadsheet. There is a high probability that IQ clients will request OLAP metadata information for non-OLAP data items when rendering or exporting a crosstab.

Field Summary
`protected static java.lang.String` | `EXTENDED_ATTRIBUTE_IS_MEASURE`

Constructor Summary
`BusinessQueryOLAPUtil()`

Method Summary
`static void` | `cleanUpNullRolesInQuery(BusinessQuery model)` This method applies an appropriate role to any dataItem found in a data selection where it's role contains a null value.
`static java.util.List` | `filterOutRaggedDataItems(java.util.List dataItems)` Returns a List of data items that are not based on a ragged-balanced, ragged-unbalanced, or unbalanced hierarchy in an OLAP cube.
`static java.lang.String` | `getCubeName(BusinessModel businessModel, DataItem dataItem)` Get the cube name for an OLAP data item.
`static java.lang.String` | `getCubeRestrictions(DataSelection dataSelection)` Returns a String representing text that can be used to establish a cube query context.
`static java.lang.String` | `getDimensionName(BusinessModel businessModel, DataItem dataItem)` Get the dimension name for an OLAP data item.
`static int` | `getDimensionType(BusinessModel businessModel, java.lang.Object obj)` Get the dimension type for an OLAP data item.
`static java.lang.String` | `getHierarchyName(BusinessModel businessModel, DataItem dataItem)` Get the fully qualified hierarchy name for an OLAP data item.
`static java.util.List` | `getInvalidLabels(DataSelection ds)` Get a list of invalid Labels for a data selection.
`static java.lang.String` | `getMeasureName(BusinessModel businessModel, DataItem dataItem)` Get the measure name for an OLAP data item.
`static com.sas.storage.olap.MetadataInterface` | `getMetadataInterface(java.lang.Object iqObject)` Creates and returns a new OLAP MetadataInterface object usable to query OLAP related metadata from the OLAP server used by the given SAS Query Services object.
`static com.sas.storage.olap.OLAPDataSetInterface` | `getOLAPDataSet(java.lang.Object iqObject)` Creates and returns a new OLAP OLAPDataSetInterface object usable to obtain a resultSet from the OLAP server based on a given SAS Query Services object.
`static java.lang.String` | `getPhysDimensionName(com.sas.iquery.metadata.physical.Dimension dimension)` Get the physical dimension name for a physical dimension.
`static java.lang.String` | `getUniqueNameWithHierarchyAllMember(DataItem dataItem)` Get the unique name with hierarchy all for an OLAP data item.
`static boolean` | `isInMeasureDimension(BusinessModel businessModel, DataItem dataItem)` Get the dimension name for an OLAP data item.
`static void` | `releaseMetadataInterface(com.sas.storage.olap.MetadataInterface metadataInterface)` Release a MetadataInterface object that was constructed in BusinessQueryOLAPUtil.getMetadataInterface.
`static void` | `releaseOLAPDataSet(com.sas.storage.olap.OLAPDataSetInterface olapDataSet)` Release the specific OLAPDataSetInterface object that was constructed in BusinessQueryOLAPUtil.getOLAPDataSetInterface.

Field Detail

### EXTENDED_ATTRIBUTE_IS_MEASURE

    protected static final java.lang.String EXTENDED_ATTRIBUTE_IS_MEASURE

See Also:
  Constant Field Values

Constructor Detail

### BusinessQueryOLAPUtil

    public BusinessQueryOLAPUtil()

Method Detail

### getInvalidLabels

    public static java.util.List getInvalidLabels(DataSelection ds)

  Get a list of invalid Labels for a data selection. This method returns a list of Reason object describing what is wrong with the label. The localized text can be returned by using reason.getReasonString(Locale).

  Parameters:
    `ds` -
  Returns:
    list of invalid labels and why they are invalid.

### getCubeRestrictions

    public static java.lang.String getCubeRestrictions(DataSelection dataSelection)
                                                throws GenerationException

  Returns a String representing text that can be used to establish a cube query context.

  Parameters:
    `dataSelection` -
  Returns:
  Throws:
    `GenerationException`

### cleanUpNullRolesInQuery

    public static void cleanUpNullRolesInQuery(BusinessQuery model)
                                        throws MetadataException

  This method applies an appropriate role to any dataItem found in a data selection where it's role contains a null value. The result of this query is a query with dataItems that contains either ROW, COLUMN, PAGE, or BACKGROUND role.

  Parameters:
    `model` - BusinessQuery that contain OLAP dataItem that could contain null role definition.
  Throws:
    `MetadataException`

### filterOutRaggedDataItems

    public static java.util.List filterOutRaggedDataItems(java.util.List dataItems)
                                                   throws MetadataException

  Returns a List of data items that are not based on a ragged-balanced, ragged-unbalanced, or unbalanced hierarchy in an OLAP cube.

  The input List of data items may contain data items that are based on a ragged or unbalanced hierarchy. This is a convenience method for internal consumers to filter out ragged-balanced, ragged-unbalanced, unbalanced data items. This method should not be used by external consumers. It will probably be removed in the next release.

  Parameters:
    `dataItems` - the List of data items to be checked whether any data items contained in the list are based on a ragged-balanced hierarchy.
  Returns:
    The List of data items not based on a ragged-balanced hierarchy.
  Throws:
    `MetadataException` - One situation where a MetadataException can be thrown is when the OLAP server is unresolved. In this case, the caller can determine this occurred by calling MetadataException.hasReasonWithCodes(int reasonCode, int subreasonCode) where reasonCode = Reason.REASON_NOT_USABLE_IN_QUERY, subreasonCode = Reason.SUBREASON_OBJECT_IS_UNRESOLVED.

### getCubeName

    public static java.lang.String getCubeName(BusinessModel businessModel,
                                               DataItem dataItem)
                                        throws MetadataException

  Get the cube name for an OLAP data item. The data item may have either an OlapItem or a calculated item that has been set on for its underlying expression.

  Parameters:
    `businessModel` - the containing business model object such as, an information map or data selection.
    `dataItem` - dataItem containing either an OlapItem or calculated item.
  Returns:
    The String representing the cube name for the data item.
  Throws:
    `MetadataException`

### getDimensionName

    public static java.lang.String getDimensionName(BusinessModel businessModel,
                                                    DataItem dataItem)
                                             throws MetadataException

  Get the dimension name for an OLAP data item. The data item may have either an OlapItem or a calculated item that has been set on for its underlying expression.

  Note: If the dimension name is unknown, null is returned.

  Parameters:
    `businessModel` - the containing business model object such as, an information map or data selection.
    `dataItem` - dataItem containing either an OlapItem or calculated item.
  Returns:
    The String representing the dimension name for the data item.
  Throws:
    `MetadataException`

### getDimensionType

    public static int getDimensionType(BusinessModel businessModel,
                                       java.lang.Object obj)
                                throws MetadataException

  Get the dimension type for an OLAP data item. The data item may have either an OlapItem or a calculated item that has been set on for its underlying expression. To call this method, the consumer must first extract the expression from the OLAP data item like so:

  ExpressionInterface expr = dataItem.getExpression(); int type = getDimensionType( businessModel, expr );

  Note: If the dimension type is unknown, DimensionInterface.TYPE_UNKNOWN is returned.

  Parameters:
    `businessModel` - the containing business model object such as, an information map or data selection.
    `obj` - The obj obtained from calling dataItem.getExpression() and resolving to either: Dimension, Hierarchy, Level, Measure, or ResourceAwareStringExpression
  Returns:
    The int representing the dimension type for the data item.
  Throws:
    `MetadataException`

### getHierarchyName

    public static java.lang.String getHierarchyName(BusinessModel businessModel,
                                                    DataItem dataItem)
                                             throws MetadataException

  Get the fully qualified hierarchy name for an OLAP data item. The data item may have either an OlapItem or a calculated item that has been set on for its underlying expression.

  Note: If the hierarchy name is unknown, null is returned.

  Parameters:
    `businessModel` - the containing business model object such as, an information map or data selection.
    `dataItem` - dataItem containing either an OlapItem or calculated item.
  Returns:
    The String representing the hierarchy name for the data item.
  Throws:
    `MetadataException`

### getMeasureName

    public static java.lang.String getMeasureName(BusinessModel businessModel,
                                                  DataItem dataItem)
                                           throws MetadataException

  Get the measure name for an OLAP data item. The data item may have either an OlapItem or a calculated item that has been set on for its underlying expression.

  Note: If the measure name is unknown, null is returned.

  Parameters:
    `businessModel` - the containing business model object such as, an information map or data selection.
    `dataItem` - dataItem containing either an OlapItem or calculated item.
  Returns:
    The String representing the measure name for the data item.
  Throws:
    `MetadataException`

### getMetadataInterface

    public static com.sas.storage.olap.MetadataInterface getMetadataInterface(java.lang.Object iqObject)
                                                                       throws ExecutionException,
                                                                              MetadataException

  Creates and returns a new OLAP MetadataInterface object usable to query OLAP related metadata from the OLAP server used by the given SAS Query Services object.

  This method uses a user-defined context system for managing OLAP connection resources.

  The filtering state is defined as:

  - "Filtered" conversation with the server - the effective filters applied to the base model are respected. A base model is given by the BusinessQuery.getBusinessModel().getBaseModel() method. A MetadataInterface using this filtering state is returned when a LookThroughBusinessQuery is provided as input.

  - "Unfiltered" conversation with the server - the effective filters applied to a non-LookThroughBusinessQuery are ignored. This state is initiated by the input of any other BusinessModel or BusinessQuery such as a InformationMap.

    It can not be stated that the conversation is completely clean of all filtering -- only that it is clean of filtering for the object being input. Therefore, a "filtered" conversation would result in a restricted view of levels and members while a "unfiltered" conversation would result in a unrestricted view of levels and members.

  Callers of this method must release the returned object by calling BusinessQueryOLAPUtil.releaseMetadataInterface(metadataInterface). Until a release is done, resources will remain allocated until the session context is destroyed (i.e. the user logs off).

  The IQ object given must be either a BusinessQuery or BusinessModel.

  Parameters:
    `iqObject` - - the object that provides the context for creating a MetadataInterface object to. The object given must be either a BusinessQuery or BusinessModel object.
  Returns:
    a MetdataInterface based on the input object.
  Throws:
    `ExecutionException` - - if a problem was found and could not create a MetadataInterface object to return
    `MetadataException`
  See Also:
    `releaseMetadataInterface`

### getOLAPDataSet

    public static com.sas.storage.olap.OLAPDataSetInterface getOLAPDataSet(java.lang.Object iqObject)
                                                                    throws IQueryServicesException

  Creates and returns a new OLAP OLAPDataSetInterface object usable to obtain a resultSet from the OLAP server based on a given SAS Query Services object.

  This method uses a user-defined context system for managing OLAP connection resources.

  The filtering state is defined as:

  - "Filtered" conversation with the server - the effective filters applied to the base model are respected. A base model is given by the BusinessQuery.getBusinessModel().getBaseModel() method. A OLAPDataSetInterface using this filtering state is returned when a LookThroughBusinessQuery is provided as input.

  - "Unfiltered" conversation with the server - the effective filters applied to a non-LookThroughBusinessQuery are ignored. This state is initiated by the input of any other BusinessModel or BusinessQuery such as a InformationMap.

    It can not be stated that the conversation is completely clean of all filtering -- only that it is clean of filtering for the object being input. Therefore, a "filtered" conversation would provide a resultSet from a restricted number levels and/or members while a "unfiltered" conversation would provide a resultSet from a unrestricted number levels and/or members.

  Callers of this method must release the returned object by calling BusinessQueryOLAPUtil.releaseOLAPDataSetInterface(OLAPDataSetInterface). Until a release is done, resources will remain allocated until the session context is destroyed (i.e. the user logs off).

  The IQ object given must be either a BusinessQuery or BusinessModel.

  Parameters:
    `iqObject` - - the object that provides the context for creating a OLAPDataSetInterface object to. The object given must be either a BusinessQuery or BusinessModel object.
  Returns:
    a MetdataInterface based on the input object.
  Throws:
    `IQueryServicesException` - - if a problem was found and could not create a OLAPDataSetInterface object to return
  See Also:
    `releaseOLAPDataSetInterface`

### getPhysDimensionName

    public static java.lang.String getPhysDimensionName(com.sas.iquery.metadata.physical.Dimension dimension)

  Get the physical dimension name for a physical dimension.

  Parameters:
    `dimension` - the com.sas.iquery.metadata.physical.dimension object.
  Returns:
    The String representing the dimension name for the physical item or null.

### getUniqueNameWithHierarchyAllMember

    public static java.lang.String getUniqueNameWithHierarchyAllMember(DataItem dataItem)
                                                                throws MetadataException

  Get the unique name with hierarchy all for an OLAP data item. The data item may have either an OlapItem or a calculated item that has been set on for its underlying expression.

  Note: null is returned if the data item is a measure or is a calculated item that resolves to a measure.

  Parameters:
    `dataItem` - dataItem containing either an OlapItem or calculated item.
  Returns:
    The String representing the dimension name for the data item or null.
  Throws:
    `MetadataException`

### isInMeasureDimension

    public static boolean isInMeasureDimension(BusinessModel businessModel,
                                               DataItem dataItem)
                                        throws MetadataException

  Get the dimension name for an OLAP data item. The data item may have either an OlapItem or a calculated item that has been set on for its underlying expression.

  Note: If it cannot be determined whether the dimension for the data item is in a measure, false is returned.

  Parameters:
    `businessModel` - the containing business model object such as, an information map or data selection.
    `dataItem` - dataItem containing either an OlapItem or calculated item.
  Returns:
    The boolean determining whether the data item is in the measure dimension.
  Throws:
    `MetadataException`

### releaseMetadataInterface

    public static void releaseMetadataInterface(com.sas.storage.olap.MetadataInterface metadataInterface)

  Release a MetadataInterface object that was constructed in BusinessQueryOLAPUtil.getMetadataInterface. This allows OLAP resources used by this object to released which allows them to be either removed or recycled. Once this object has been released, it is sent to garbage collection.

  Parameters:
    `metadataInterface` -

### releaseOLAPDataSet

    public static void releaseOLAPDataSet(com.sas.storage.olap.OLAPDataSetInterface olapDataSet)

  Release the specific OLAPDataSetInterface object that was constructed in BusinessQueryOLAPUtil.getOLAPDataSetInterface. This allows OLAP resources used by this object to released which allows them to be either removed or recycled. Once this object has been released, it is sent to garbage collection.

  Parameters:
    `metadataInterface@throws` - IQueryServicesException

*** This class is subject to change. ***

All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Query |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 SAS Institute Inc. All Rights Reserved.