com.sas.dataselectors.ranking
Class BaseRankingSelectorAdapter

com.sas.dataselectors.ranking.BaseRankingSelectorAdapter
All Implemented Interfaces:
RankingSelectorInterface
Direct Known Subclasses:
OLAPRankingSelectorAdapter, RelationalRankingSelectorAdapter

public abstract class BaseRankingSelectorAdapter
implements RankingSelectorInterface

Base class that contains attributes and methods common to the different Ranking Selector adapters.

Since:
3.1

Field Summary
protected  java.util.ResourceBundle bundle
           
protected  java.util.Map dataItems
          Stores the ranking info for all the data items that are in the data model.
protected  com.sas.iquery.metadata.business.BusinessQuery dataModel
          The data model used by the adapter.
protected  java.util.Locale locale
          The locale used by the adapter
protected  java.lang.Object model
          The model that contains the data.
protected  java.util.Map rankStatuses
          The localized descriptions of the rank statuses for all the DataItems.
protected  java.lang.String RB_KEY
           
protected  boolean valuesFromDataModel
          Flag to indicate if the values must be read directly from the data model or from the internal variables.
 
Fields inherited from interface com.sas.dataselectors.ranking.RankingSelectorInterface
NO_RANK
 
Constructor Summary
BaseRankingSelectorAdapter()
          Default constructor.
 
Method Summary
 int countRankTypeValue()
          Returns the value associated to the "Count" ranking type.
abstract  java.lang.String dataItemRankStatus(java.lang.String dataItemID)
          Returns the localized string describing the rank status for a DataItem.
protected  java.util.Map dataItems()
          Returns the dataItems Map.
protected  void dataItems(java.util.Map dataItems)
          Sets the dataItems Map.
 com.sas.iquery.metadata.business.BusinessQuery dataModel()
          Returns the model that contains the data.
 void dataModel(com.sas.iquery.metadata.business.BusinessQuery model)
          Sets the model that contains the data.
 java.lang.String getIncludeTies()
          Says if the ties are included.
 java.lang.String getIncludeTies(java.lang.String dataItemID)
          Given a data item id says if the ties are included in the ranking.
 java.util.Locale getLocale()
          Returns the locale used by the adapter.
 java.lang.String getLocalizedInfoText(java.lang.String rankOrder, int rankValue, int rankType, java.lang.String includeTies, java.lang.String basedOnDesc)
          Returns the localized string describing a rank status.
 java.lang.String getLocalizedText(java.lang.String text)
          Returns the localized version of a text using the locale currently set on adapter and the related resource bundle.
 java.lang.Object getModel()
          Return the model that contains the data.
protected  java.lang.Object getRankFilter(java.lang.String dataItemID)
           
 boolean includeTies()
          Deprecated. replaced by getIncludeTies().
 void includeTies(boolean isIncludeTies)
          Deprecated. replaced by setIncludeTies().
 boolean includeTies(java.lang.String dataItemID)
          Deprecated. replaced by getIncludeTies(String dataItemID)
protected abstract  void initDataItems()
          Reading from the data model fills the dataItems instance variable with the ranking attributes of all the data items in the data model.
 boolean percentageRanking()
          Says if the ranking is percentage or absolute.
 void percentageRanking(boolean isPercentage)
          Sets the type of ranking to either percentage or absolute.
 int rankingCount()
          Returns the amount of elements to rank.
 void rankingCount(int count)
          Sets the amount of elements to rank.
 java.lang.String rankOrder(java.lang.String dataItemID)
          Given a data item id return the associated rank order
protected  java.util.Map rankStatuses()
          Returnss the rankStatuses attribute.
protected  void rankStatuses(java.util.Map rankStatuses)
          Sets the rankStatuses attribute.
 int rankType()
          Returns the rank type.
 void rankType(int rankType)
          Sets the rank type.
 int rankType(java.lang.String dataItemID)
          Given a data item id return the associated rank type.
abstract  java.util.Map rankTypes()
          Returns the list of the available rank types.
 int rankValue(java.lang.String dataItemID)
          Given a data item id return the associated rank value.
 void setIncludeTies(java.lang.String isIncludeTies)
          Sets if the ties are included.
 void setLocale(java.util.Locale locale)
          Sets the locale used by the adapter.
 void setModel(java.lang.Object model)
          Set the model that contains the data.
 boolean topRanking()
          Says if the ranking is top or bottom.
 void topRanking(boolean isTop)
          Sets the type of ranking to either top or bottom.
 boolean valuesFromDataModel()
          Returns true if the values must be read directly from the data model, false if the values must be read from the internal variables.
 void valuesFromDataModel(boolean valuesFromDataModel)
          Sets if the the values must be read directly from the Data Model or from the internal variables.
 

Field Detail

dataModel

protected com.sas.iquery.metadata.business.BusinessQuery dataModel
The data model used by the adapter.


valuesFromDataModel

protected boolean valuesFromDataModel
Flag to indicate if the values must be read directly from the data model or from the internal variables.


model

protected java.lang.Object model
The model that contains the data.


rankStatuses

protected java.util.Map rankStatuses
The localized descriptions of the rank statuses for all the DataItems. In the Map there's one element for each DataItem, the key of the element is the id of the DataItem, the value of the element is the localized description of the rank status for that DataItem


locale

protected java.util.Locale locale
The locale used by the adapter


RB_KEY

protected java.lang.String RB_KEY

bundle

protected java.util.ResourceBundle bundle

dataItems

protected java.util.Map dataItems
Stores the ranking info for all the data items that are in the data model. For each data item there's an element in the map, the key of the map element is the data item unique id the value of the map element is another map that has as many elements as the ranking attributes of a data item like rankOrder, rankType etc., the key of a map element is the ranking attribute name (rankOrder, rankType etc.) the value of a map element is the value of the ranking attribute

Constructor Detail

BaseRankingSelectorAdapter

public BaseRankingSelectorAdapter()
Default constructor. Initializes the RB_KEY attribute.

Method Detail

topRanking

public boolean topRanking()
Description copied from interface: RankingSelectorInterface
Says if the ranking is top or bottom.

Specified by:
topRanking in interface RankingSelectorInterface
Returns:
true if it's a top ranking, false if it's a bottom one

rankingCount

public int rankingCount()
Description copied from interface: RankingSelectorInterface
Returns the amount of elements to rank.

Specified by:
rankingCount in interface RankingSelectorInterface
Returns:
the amount of elements to rank

percentageRanking

public boolean percentageRanking()
Description copied from interface: RankingSelectorInterface
Says if the ranking is percentage or absolute.

Specified by:
percentageRanking in interface RankingSelectorInterface
Returns:
true if the the ranking is percentage, false if the ranking is absolute

topRanking

public void topRanking(boolean isTop)
Description copied from interface: RankingSelectorInterface
Sets the type of ranking to either top or bottom.

Specified by:
topRanking in interface RankingSelectorInterface
Parameters:
isTop - true if it's a top ranking, false if it's a bottom ranking

percentageRanking

public void percentageRanking(boolean isPercentage)
Description copied from interface: RankingSelectorInterface
Sets the type of ranking to either percentage or absolute.

Specified by:
percentageRanking in interface RankingSelectorInterface
Parameters:
isPercentage - true if it's a percentage ranking, false if it's an absolute ranking

rankingCount

public void rankingCount(int count)
Description copied from interface: RankingSelectorInterface
Sets the amount of elements to rank.

Specified by:
rankingCount in interface RankingSelectorInterface
Parameters:
count - the amount of elements to rank, > 0.

dataItems

protected java.util.Map dataItems()
Returns the dataItems Map.

Returns:
the dataItems Map

dataItems

protected void dataItems(java.util.Map dataItems)
Sets the dataItems Map.

Parameters:
dataItems - the dataItems Map

dataModel

public void dataModel(com.sas.iquery.metadata.business.BusinessQuery model)
Sets the model that contains the data.

Parameters:
model - the model that contains the data.

dataModel

public com.sas.iquery.metadata.business.BusinessQuery dataModel()
Returns the model that contains the data.

Returns:
com.sas.iquery.metadata.business.BusinessQuery the model that contains the data.

initDataItems

protected abstract void initDataItems()
Reading from the data model fills the dataItems instance variable with the ranking attributes of all the data items in the data model.


includeTies

public void includeTies(boolean isIncludeTies)
Deprecated. replaced by setIncludeTies().

Description copied from interface: RankingSelectorInterface
Sets if the ties are included.

Specified by:
includeTies in interface RankingSelectorInterface
Parameters:
isIncludeTies - true if the ties are included, false otherwise

includeTies

public boolean includeTies()
Deprecated. replaced by getIncludeTies().

Description copied from interface: RankingSelectorInterface
Says if the ties are included.

Specified by:
includeTies in interface RankingSelectorInterface
Returns:
true if the the ties are included, false otherwise

setIncludeTies

public void setIncludeTies(java.lang.String isIncludeTies)
Description copied from interface: RankingSelectorInterface
Sets if the ties are included.

Specified by:
setIncludeTies in interface RankingSelectorInterface
Parameters:
isIncludeTies - valid values are: RankingSelectorComponents.INCLUDE_TIES, RankingSelectorComponents.NOT_INCLUDE_TIES, RankingSelectorComponents.TIES_NOT_APPLICABLE

getIncludeTies

public java.lang.String getIncludeTies()
Description copied from interface: RankingSelectorInterface
Says if the ties are included.

Specified by:
getIncludeTies in interface RankingSelectorInterface
Returns:
true either one of the following: RankingSelectorComponents.INCLUDE_TIES, RankingSelectorComponents.NOT_INCLUDE_TIES, RankingSelectorComponents.TIES_NOT_APPLICABLE

rankType

public void rankType(int rankType)
Description copied from interface: RankingSelectorInterface
Sets the rank type.

Specified by:
rankType in interface RankingSelectorInterface
Parameters:
rankType - the rank type,

for OLAP valid values are: DataItemRankFilter.COUNT DataItemRankFilter.PERCENT DataItemRankFilter.SUM

for relational DataItemRankFilter.COUNT


rankType

public int rankType()
Description copied from interface: RankingSelectorInterface
Returns the rank type.

Specified by:
rankType in interface RankingSelectorInterface
Returns:
for OLAP iether one of the following values: DataItemRankFilter.COUNT DataItemRankFilter.PERCENT DataItemRankFilter.SUM

for relational DataItemRankFilter.COUNT


rankTypes

public abstract java.util.Map rankTypes()
Returns the list of the available rank types.

Specified by:
rankTypes in interface RankingSelectorInterface
Returns:
Map the rank types. In the Map there's one element for each rank type, for each element in the map its key is the rank type description and its value is the rank type value.

valuesFromDataModel

public boolean valuesFromDataModel()
Description copied from interface: RankingSelectorInterface
Returns true if the values must be read directly from the data model, false if the values must be read from the internal variables.

Specified by:
valuesFromDataModel in interface RankingSelectorInterface
Returns:
true if the values must be read directly from the data model, false if the values must be read from the internal variables

valuesFromDataModel

public void valuesFromDataModel(boolean valuesFromDataModel)
Description copied from interface: RankingSelectorInterface
Sets if the the values must be read directly from the Data Model or from the internal variables.

Specified by:
valuesFromDataModel in interface RankingSelectorInterface
Parameters:
valuesFromDataModel - true if the the values must be read directly from the data model, false if the values must be read from the internal variables

dataItemRankStatus

public abstract java.lang.String dataItemRankStatus(java.lang.String dataItemID)
Returns the localized string describing the rank status for a DataItem.

Specified by:
dataItemRankStatus in interface RankingSelectorInterface
Parameters:
dataItemID - the DataItam id
Returns:
the localized string describing the rank status for the DataItem

rankStatuses

protected void rankStatuses(java.util.Map rankStatuses)
Sets the rankStatuses attribute.

Parameters:
rankStatuses - the rankStatuses attribute

rankStatuses

protected java.util.Map rankStatuses()
Returnss the rankStatuses attribute.

Parameters:
rankStatuses - the rankStatuses attribute

rankOrder

public java.lang.String rankOrder(java.lang.String dataItemID)
Description copied from interface: RankingSelectorInterface
Given a data item id return the associated rank order

Specified by:
rankOrder in interface RankingSelectorInterface
Parameters:
dataItemID - the data item unique identifier
Returns:
the associated rank order, valid values are RankingSelectorComponents.TOP_RANKING, RankingSelectorComponents.BOTTOM_RANKING a null string is returned if the received dataItemID is either null or not found in the data model or there's no ranking applied

rankValue

public int rankValue(java.lang.String dataItemID)
Description copied from interface: RankingSelectorInterface
Given a data item id return the associated rank value.

Specified by:
rankValue in interface RankingSelectorInterface
Parameters:
dataItemID - the data item unique identifier
Returns:
the associated rank value, valid values are all the positive numbers, or RankingSelectorInterface.NO_RANK when the dataItemID has no ranking applied or when the received dataItemID is either null or not found in the data model

rankType

public int rankType(java.lang.String dataItemID)
Description copied from interface: RankingSelectorInterface
Given a data item id return the associated rank type.

Specified by:
rankType in interface RankingSelectorInterface
Parameters:
dataItemID - the data item unique identifier
Returns:
the associated rank type, valid values are for OLAP DataItemRankFilter.COUNT DataItemRankFilter.PERCENT DataItemRankFilter.SUM for relational DataItemRankFilter.COUNT and in general RankingSelectorInterface.NO_RANK when the dataItemID has no ranking applied or when the received dataItemID is either null or not found in the data model

includeTies

public boolean includeTies(java.lang.String dataItemID)
Deprecated. replaced by getIncludeTies(String dataItemID)

Description copied from interface: RankingSelectorInterface
Given a data item id says if the ties are included in the ranking.

Specified by:
includeTies in interface RankingSelectorInterface
Parameters:
dataItemID - the data item unique identifier
Returns:
true if the the ties are included in the ranking, false otherwise

getIncludeTies

public java.lang.String getIncludeTies(java.lang.String dataItemID)
Description copied from interface: RankingSelectorInterface
Given a data item id says if the ties are included in the ranking.

Specified by:
getIncludeTies in interface RankingSelectorInterface
Parameters:
dataItemID - the data item unique identifier
Returns:
one of the following: RankingSelectorComponents.INCLUDE_TIES, RankingSelectorComponents.NOT_INCLUDE_TIES, RankingSelectorComponents.TIES_NOT_APPLICABLE

countRankTypeValue

public int countRankTypeValue()
Description copied from interface: RankingSelectorInterface
Returns the value associated to the "Count" ranking type.

Specified by:
countRankTypeValue in interface RankingSelectorInterface
Returns:
the value associated to the "Count" ranking type

getRankFilter

protected java.lang.Object getRankFilter(java.lang.String dataItemID)

setModel

public void setModel(java.lang.Object model)
Description copied from interface: RankingSelectorInterface
Set the model that contains the data. Something like a BusinessQueryToOLAPDataSetAdapter or similar.

Specified by:
setModel in interface RankingSelectorInterface
Parameters:
model - the model that contains the data.

getModel

public java.lang.Object getModel()
Description copied from interface: RankingSelectorInterface
Return the model that contains the data.

Specified by:
getModel in interface RankingSelectorInterface
Returns:
Object the model that contains the data, something like a BusinessQueryToOLAPDataSetAdapter or similar.

setLocale

public void setLocale(java.util.Locale locale)
Description copied from interface: RankingSelectorInterface
Sets the locale used by the adapter. The bundle attribute is set too on the adapter according with the locale.

Specified by:
setLocale in interface RankingSelectorInterface
Parameters:
locale - The locale the adapter will use

getLocale

public java.util.Locale getLocale()
Description copied from interface: RankingSelectorInterface
Returns the locale used by the adapter.

Specified by:
getLocale in interface RankingSelectorInterface
Returns:
the locale used by the adapter

getLocalizedInfoText

public java.lang.String getLocalizedInfoText(java.lang.String rankOrder,
                                             int rankValue,
                                             int rankType,
                                             java.lang.String includeTies,
                                             java.lang.String basedOnDesc)
Description copied from interface: RankingSelectorInterface
Returns the localized string describing a rank status. Something like "Top 2 Count (including ties) based on ACTUAL_SUM for (1994, SOFA)"

Specified by:
getLocalizedInfoText in interface RankingSelectorInterface
Parameters:
rankOrder - the rank order like top or bottom
rankValue - the amount of elements to rank
rankType - the rank type

for OLAP valid values are: DataItemRankFilter.COUNT DataItemRankFilter.PERCENT DataItemRankFilter.SUM

for relational DataItemRankFilter.COUNT

includeTies - if the ties must be included or not included RankingSelectorComponents.INCLUDE_TIES, RankingSelectorComponents.NOT_INCLUDE_TIES, RankingSelectorComponents.TIES_NOT_APPLICABLE
basedOnDesc - the description of the based on measure, something like "ACTUAL_SUM for (1994, SOFA)" for OLAP, a null String for relational
Returns:
the localized string describing a rank status. Something like "Top 2 Count (including ties) based on ACTUAL_SUM for (1994, SOFA)"

getLocalizedText

public java.lang.String getLocalizedText(java.lang.String text)
Description copied from interface: RankingSelectorInterface
Returns the localized version of a text using the locale currently set on adapter and the related resource bundle.

Specified by:
getLocalizedText in interface RankingSelectorInterface
Parameters:
text - The text to be localized.
Returns:
the localized text, null if the received text cannot be localized



Copyright © 2009 SAS Institute Inc. All Rights Reserved.