com.sas.dataselectors.dataitems
Class TableRoles

com.sas.dataselectors.dataitems.TableRoles
All Implemented Interfaces:
DataItemSelectorInterface, com.sas.util.RoleProviderInterface
Direct Known Subclasses:
OLAPTableRoles

public class TableRoles
implements DataItemSelectorInterface

Defines and manages the roles for a relational, or two-dimensional, query.

Since:
3.1

Nested Class Summary
protected  class TableRoles.Role
           
 
Field Summary
protected  com.sas.iquery.metadata.business.BusinessModel _businessModel
           
static java.lang.String COLUMN
          Constant for the name of the column role.
protected  java.util.List dataItemRefList
           
static java.lang.String FILTER
          Constant for the name of the filter role.
protected  com.sas.iquery.metadata.business.InformationMap iMap
           
protected  java.util.List originalItemList
           
protected  java.lang.String queryType
           
static java.lang.String RB_KEY
          Key used to look up resources in the resource bundle
static java.lang.String RB_KEY2
           
protected  java.lang.String[] selectedItems
           
static java.lang.String SLICER
          Constant for the name of the slicer role.
 
Fields inherited from interface com.sas.dataselectors.dataitems.DataItemSelectorInterface
DISPLAY_DETAIL_VALUES, GROUP_BY_CATEGORY_VALUES
 
Constructor Summary
TableRoles(com.sas.iquery.metadata.business.BusinessQuery businessQuery)
          Constructor.
TableRoles(com.sas.iquery.metadata.business.BusinessQuery businessQuery, com.sas.iquery.metadata.business.InformationMap imap)
           
 
Method Summary
 void addRole(java.lang.String name, java.lang.String label, java.lang.String description, int minRoleItemCount, int maxRoleItemCount)
          Adds a role with the given criteria.
 boolean allQueryItemsAreDetailUsage()
          Indicates if all items selected for each role are set to detail usage.
 void cleanUp(java.lang.String mode)
          For each added role, removes from the business model all DataItemReference objects created during processing of the selector.
protected  void dumpThisItemList(java.util.List items)
          Debugging method for examining lists of dataitems
 java.util.List getAllAvailableNodeIds(boolean useOriginalIds)
          Returns a list of the ids for all items in the available list.
 java.util.List getAvailableEnabledNodeIds(java.lang.String selectedRole)
          Returns a list of the item ids for the items available for selection for the selected role.
 java.util.List getAvailableItemInfoList(java.lang.String selectedRole)
          Returns a list of DataItemTreeNodeInfo objects, representing the list of items available for the selected role.
protected  java.util.List getAvailableRoleItems(com.sas.util.RoleInterface role)
          Return the list of items available to add to the role
 javax.swing.tree.TreeModel getAvailableTreeModel(com.sas.util.transforms.TransformInterface transform, java.lang.String selectedRole)
          Creates a tree model representing the available items for the business model.
 java.lang.String getBaseItemId(java.lang.String itemid)
          Returns the base item id of the DataItemReference in the stored dataItem map identified by itemid.
 java.util.Map getDataItemMap()
          Returns the map of DataItems stored by their id
static java.lang.String getID(java.lang.Object object)
          Gets a unique String identifier for the given Object.
 java.lang.Object getItemFromItemMap(java.lang.String itemid)
          Returns the data item in the stored itemmap that corresponds to the itemid.
 java.util.Locale getLocale()
          Returns the locale object
 java.util.List getMoveTargetRoles()
          Returns a list of RoleInterface objects that the items contained in the selectedItems parameter can be moved to.
protected  java.util.List getOriginalItemList()
          Returns the list of items stored in the business model before any references were created by this adapter.
 java.lang.String getQueryType()
          Returns the current query type
 com.sas.util.RoleInterface getRole(java.lang.String name, java.lang.String label)
          Returns the role with the name and label specified.
 java.util.List getRoleItems()
          Returns all the items that can be assigned to the roles.
protected  java.util.List getRoleItems(boolean isFilterRole)
           
 com.sas.util.RoleInterface[] getRoles()
          Returns the available roles.
protected  java.util.ArrayList getRolesList()
           
 java.util.List getSelectedItemInfoList(java.lang.String selectedRole)
          Returns a list of DataItemTreeNodeInfo objects, representing the list of items assigned to the selected role.
 javax.swing.tree.TreeModel getSelectedTreeModel(com.sas.util.transforms.TransformInterface transform, java.lang.String selectedRole)
          Creates a tree model representing the selected items for the business model.
 java.lang.String getStatusMessage()
          Checks for basic validity/completeness of the adapter and returns a status message indicating what is wrong with the adapter.
protected  boolean hasValidRoles()
           
 boolean isCalculatedItemSelected()
          Indicates if a calculated item is selected for any of the assigned roles.
 boolean isItemMoveDownValid()
          Returns true if the items contained in the selectedItems parameter can be moved down in the model order.
 boolean isItemMoveUpValid()
          Returns true if the items contained in the selectedItems parameter can be moved up in the model order.
 boolean isThisItemAReferenceInItemMap(java.lang.String itemid)
          Convenience method that indicates if the item in the stored dataitem map identified by the passed in id is a DataItemReference.
 boolean isThisItemInAvailableList(java.lang.String itemid, com.sas.util.RoleInterface role)
          Convenience method to determine if the data item identified by the passed in item id is available for selection for the indicated role.
 boolean isThisItemInRoleRefList(java.lang.String itemid, com.sas.util.RoleInterface role)
          Indicates if the item identified by the passed in item id is in the list of DataItemReferences created by addRoleItem for the indicated role.
protected  boolean isValidRole(java.lang.String name)
          Checks the role to see if a role with name is valid within this model Subclasses can override this method to allow other role types to be added.
 void mapDataSource()
          Creates a map of selected items with their item id as the key.
 boolean queryItemsSupportDetailUsage()
          Indicates if all items selected for each role support the detail usage.
 void removeAllRoles()
          Removes all roles.
protected  java.util.List removeCalculatedItemBaseItems(java.util.List listOfItems)
          Convenience method to remove the base DataItems of all calculated DataItemReferences from the passed in list of items.
protected  java.util.List removeDuplicateItems(java.util.List allDataItems)
          Convenience method to create a list of DataItems such that each item in the list has a unique base DataItem.
protected  java.util.List removeItemsNotSupportingDetail(java.util.List items)
          Removes the items from the passed in list that do not support the detail usage.
protected  java.util.List removeNotUsableItems(java.util.List allDataItems)
          Convenience method that removes all items in the list that are not usable in the query for some reason.
protected  java.util.List revertRefsToBaseItems(java.util.List allDataItems)
          Convenience method to create a list such that for every item in the input list that is a DataItemReference, return its baseDataitem.
 void setDataItemMap(java.util.Map map)
          Sets the map map of DataItems stored by their id
 void setLocale(java.util.Locale locale)
          Sets the locale object to ensure that all messages returned are properly translated.
protected  void setOriginalItemList(java.util.List allItems)
          Stores the items in the business model
 void setQueryType(java.lang.String queryType)
          Sets the value for the query type for relational queries.
 void setSelectedItems(java.lang.String[] items)
          Sets the array of selected data items.
 void setSelectedItemsQueryType(java.lang.String queryType)
          Sets the DataItem usage for each of the selected items.
 

Field Detail

COLUMN

public static final java.lang.String COLUMN
Constant for the name of the column role.

See Also:
SLICER, FILTER, Constant Field Values

SLICER

public static final java.lang.String SLICER
Constant for the name of the slicer role.

See Also:
COLUMN, FILTER, Constant Field Values

FILTER

public static final java.lang.String FILTER
Constant for the name of the filter role.

See Also:
COLUMN, SLICER, Constant Field Values

_businessModel

protected com.sas.iquery.metadata.business.BusinessModel _businessModel

dataItemRefList

protected java.util.List dataItemRefList

originalItemList

protected java.util.List originalItemList

queryType

protected java.lang.String queryType

selectedItems

protected java.lang.String[] selectedItems

RB_KEY

public static final java.lang.String RB_KEY
Key used to look up resources in the resource bundle

See Also:
Constant Field Values

RB_KEY2

public static final java.lang.String RB_KEY2
See Also:
Constant Field Values

iMap

protected com.sas.iquery.metadata.business.InformationMap iMap
Constructor Detail

TableRoles

public TableRoles(com.sas.iquery.metadata.business.BusinessQuery businessQuery)
Constructor.

Parameters:
businessquery - - the data model to query for the adapter information

TableRoles

public TableRoles(com.sas.iquery.metadata.business.BusinessQuery businessQuery,
                  com.sas.iquery.metadata.business.InformationMap imap)
Method Detail

addRole

public void addRole(java.lang.String name,
                    java.lang.String label,
                    java.lang.String description,
                    int minRoleItemCount,
                    int maxRoleItemCount)
Adds a role with the given criteria. Roles with the same name can be added but the label must be different.

Parameters:
name - the name of the role, must be either COLUMN. SLICER or FILTER
label - the role's label
description - the role's description
minRoleItemCount - the minimum number of items that must be assigned to the role
maxRoleItemCount - the maximum number of items that may be assigned to the role, zero if unlimited
See Also:
removeAllRoles()

isValidRole

protected boolean isValidRole(java.lang.String name)
Checks the role to see if a role with name is valid within this model Subclasses can override this method to allow other role types to be added.

Parameters:
name - the name of the role must be either COLUMN. SLICER or FILTER
Returns:
true if a role with that name can be added.

getRolesList

protected java.util.ArrayList getRolesList()

removeAllRoles

public void removeAllRoles()
Removes all roles.

See Also:
addRole(java.lang.String, java.lang.String, java.lang.String, int, int)

getRoles

public com.sas.util.RoleInterface[] getRoles()
Returns the available roles. The available roles are defined by calls to addRole().

Specified by:
getRoles in interface com.sas.util.RoleProviderInterface
Returns:
an array of roles; will never be null.
See Also:
addRole(java.lang.String, java.lang.String, java.lang.String, int, int)

getRoleItems

public java.util.List getRoleItems()
Returns all the items that can be assigned to the roles. The available items are defined by the business query given to the constructor.

Specified by:
getRoleItems in interface com.sas.util.RoleProviderInterface
Returns:
a list of items; If there are no items, an empty list is returned.

getRoleItems

protected java.util.List getRoleItems(boolean isFilterRole)

removeItemsNotSupportingDetail

protected java.util.List removeItemsNotSupportingDetail(java.util.List items)
Removes the items from the passed in list that do not support the detail usage.

Parameters:
items - - a list of DataItems
Returns:
the list of DataItems supporting detail usage

removeDuplicateItems

protected java.util.List removeDuplicateItems(java.util.List allDataItems)
Convenience method to create a list of DataItems such that each item in the list has a unique base DataItem.

Parameters:
allDataItems - - a list of DataItems
Returns:
the list of unique items

revertRefsToBaseItems

protected java.util.List revertRefsToBaseItems(java.util.List allDataItems)
Convenience method to create a list such that for every item in the input list that is a DataItemReference, return its baseDataitem. If an item in the list is a DataItem, return that item on the list.

Parameters:
allDataItems - - the list of data items (DataItems and/or DataItemReferences)
Returns:
the list of DataItems

mapDataSource

public void mapDataSource()
Creates a map of selected items with their item id as the key. For every selected DataItemReference, the map also contains the baseDataItem with its id as the key.


getItemFromItemMap

public java.lang.Object getItemFromItemMap(java.lang.String itemid)
Description copied from interface: DataItemSelectorInterface
Returns the data item in the stored itemmap that corresponds to the itemid. Returns null if the item is not found in the map.

Specified by:
getItemFromItemMap in interface DataItemSelectorInterface
Parameters:
itemid - - the id of the item to return
Returns:
the item in the map corresponding to the passed in item id

getBaseItemId

public java.lang.String getBaseItemId(java.lang.String itemid)
Description copied from interface: DataItemSelectorInterface
Returns the base item id of the DataItemReference in the stored dataItem map identified by itemid. Null will be returned if the item is not found in the map.

Specified by:
getBaseItemId in interface DataItemSelectorInterface
Parameters:
itemid - - the id of the DataItemReference to find in the map
Returns:
the id of the baseDataItem of the reference corresponding to the passed in item id

isThisItemAReferenceInItemMap

public boolean isThisItemAReferenceInItemMap(java.lang.String itemid)
Description copied from interface: DataItemSelectorInterface
Convenience method that indicates if the item in the stored dataitem map identified by the passed in id is a DataItemReference.

Specified by:
isThisItemAReferenceInItemMap in interface DataItemSelectorInterface
Parameters:
itemid - - the id of the item to search for in the dataitem map
Returns:
true if an item is in the dataitem map corresponding to the passed in id and the item is a DataItemReference, otherwise false

isThisItemInAvailableList

public boolean isThisItemInAvailableList(java.lang.String itemid,
                                         com.sas.util.RoleInterface role)
Description copied from interface: DataItemSelectorInterface
Convenience method to determine if the data item identified by the passed in item id is available for selection for the indicated role.

Specified by:
isThisItemInAvailableList in interface DataItemSelectorInterface
Parameters:
itemid - - the id of the item in the available list
role - - the role of interest
Returns:
true if the item was found in the available list, otherwise false

isThisItemInRoleRefList

public boolean isThisItemInRoleRefList(java.lang.String itemid,
                                       com.sas.util.RoleInterface role)
Description copied from interface: DataItemSelectorInterface
Indicates if the item identified by the passed in item id is in the list of DataItemReferences created by addRoleItem for the indicated role.

Specified by:
isThisItemInRoleRefList in interface DataItemSelectorInterface
Parameters:
itemid - - the id of the DataItem
role - - the role of interest
Returns:
true if the item is in the role available list, otherwise false

getOriginalItemList

protected java.util.List getOriginalItemList()
Returns the list of items stored in the business model before any references were created by this adapter.

Returns:
the item list

getDataItemMap

public java.util.Map getDataItemMap()
Description copied from interface: DataItemSelectorInterface
Returns the map of DataItems stored by their id

Specified by:
getDataItemMap in interface DataItemSelectorInterface
Returns:
the dataitem map

setDataItemMap

public void setDataItemMap(java.util.Map map)
Sets the map map of DataItems stored by their id

Parameters:
map - the dataitem map

getID

public static java.lang.String getID(java.lang.Object object)
Gets a unique String identifier for the given Object. The identifier is based on the Object's identity hash code and is guarenteed by the JVM to be unique to that Object during its lifetime and that execution of the JVM. These identifiers are not re-usable between JVM executions and should not be used for long term identifiers.

Parameters:
object - the Object to get an ID for
Returns:
the unique ID for the given object

setSelectedItemsQueryType

public void setSelectedItemsQueryType(java.lang.String queryType)
Sets the DataItem usage for each of the selected items. If the queryType is "group", the usage for each dataitem is set to DataItemActionType.USAGE_CATEGORY. If the queryType is "detail", the usage for each dataitem is set to DataitemActionType.USAGE_DETAIL. This is only used for relational queries, and provides the functionality to create a detail query or a query that is grouped by certain data items.

Specified by:
setSelectedItemsQueryType in interface DataItemSelectorInterface
Parameters:
queryType - - The query type string. This should be "group" or "detail".
See Also:
DataItemActionType

removeNotUsableItems

protected java.util.List removeNotUsableItems(java.util.List allDataItems)
Convenience method that removes all items in the list that are not usable in the query for some reason.

Parameters:
allDataItems - - a list of DataItems
Returns:
the list of usable items

getAvailableTreeModel

public javax.swing.tree.TreeModel getAvailableTreeModel(com.sas.util.transforms.TransformInterface transform,
                                                        java.lang.String selectedRole)
Description copied from interface: DataItemSelectorInterface
Creates a tree model representing the available items for the business model. By default, the tree nodes are of type DefaultMutableTreeNode, but a transform can be passed in to transform the tree nodes to a different type.

Specified by:
getAvailableTreeModel in interface DataItemSelectorInterface
Parameters:
transform - - an optional transform object
selectedRole - - the currently selected role
Returns:
a TreeModel representing the available items

dumpThisItemList

protected void dumpThisItemList(java.util.List items)
Debugging method for examining lists of dataitems


setOriginalItemList

protected void setOriginalItemList(java.util.List allItems)
Stores the items in the business model


getAvailableEnabledNodeIds

public java.util.List getAvailableEnabledNodeIds(java.lang.String selectedRole)
Description copied from interface: DataItemSelectorInterface
Returns a list of the item ids for the items available for selection for the selected role.

Specified by:
getAvailableEnabledNodeIds in interface DataItemSelectorInterface
Parameters:
selectedRole - - the currently selected role
Returns:
the list of available item ids

cleanUp

public void cleanUp(java.lang.String mode)
Description copied from interface: DataItemSelectorInterface
For each added role, removes from the business model all DataItemReference objects created during processing of the selector. This is typically done when the user cancels out of the selector to restore the business model to its original state.

Specified by:
cleanUp in interface DataItemSelectorInterface
Parameters:
mode - - an optional mode identifier (this can be null)

getAllAvailableNodeIds

public java.util.List getAllAvailableNodeIds(boolean useOriginalIds)
Description copied from interface: DataItemSelectorInterface
Returns a list of the ids for all items in the available list. Some or all of these items may not be available for selection for the selected role.

Specified by:
getAllAvailableNodeIds in interface DataItemSelectorInterface
Returns:
the list of ids for the available list

removeCalculatedItemBaseItems

protected java.util.List removeCalculatedItemBaseItems(java.util.List listOfItems)
Convenience method to remove the base DataItems of all calculated DataItemReferences from the passed in list of items.

Parameters:
listOfItems - - a list of DataItems
Returns:
the list of items with the base Dataitems removed

getAvailableItemInfoList

public java.util.List getAvailableItemInfoList(java.lang.String selectedRole)
Description copied from interface: DataItemSelectorInterface
Returns a list of DataItemTreeNodeInfo objects, representing the list of items available for the selected role.

Specified by:
getAvailableItemInfoList in interface DataItemSelectorInterface
Returns:
items The list of available items
See Also:
DataItemTreeNodeInfo

getSelectedItemInfoList

public java.util.List getSelectedItemInfoList(java.lang.String selectedRole)
Description copied from interface: DataItemSelectorInterface
Returns a list of DataItemTreeNodeInfo objects, representing the list of items assigned to the selected role.

Specified by:
getSelectedItemInfoList in interface DataItemSelectorInterface
Parameters:
selectedRole - The role of interest
Returns:
The list of available items
See Also:
DataItemTreeNodeInfo

getSelectedTreeModel

public javax.swing.tree.TreeModel getSelectedTreeModel(com.sas.util.transforms.TransformInterface transform,
                                                       java.lang.String selectedRole)
Description copied from interface: DataItemSelectorInterface
Creates a tree model representing the selected items for the business model. By default, the tree nodes are of type DefaultMutableTreeNode, but a transform can be passed in to transform the tree nodes to a different type.

Specified by:
getSelectedTreeModel in interface DataItemSelectorInterface
Parameters:
transform - - an optional transform object
selectedRole - - the currently selected role
Returns:
a TreeModel representing the selected items

getAvailableRoleItems

protected java.util.List getAvailableRoleItems(com.sas.util.RoleInterface role)
Return the list of items available to add to the role


getRole

public com.sas.util.RoleInterface getRole(java.lang.String name,
                                          java.lang.String label)
Returns the role with the name and label specified.

Parameters:
name - the name of the role,
label - the role's label
Returns:
a role with name and label matching those passed in. null if not found.
See Also:
addRole(java.lang.String, java.lang.String, java.lang.String, int, int)

hasValidRoles

protected boolean hasValidRoles()

getStatusMessage

public java.lang.String getStatusMessage()
Description copied from interface: DataItemSelectorInterface
Checks for basic validity/completeness of the adapter and returns a status message indicating what is wrong with the adapter. If the adapter contains complete or valid data that can be applied to the model, a null string is returned.

Specified by:
getStatusMessage in interface DataItemSelectorInterface
Returns:
The adapter status message

getLocale

public java.util.Locale getLocale()
Description copied from interface: DataItemSelectorInterface
Returns the locale object

Specified by:
getLocale in interface DataItemSelectorInterface
Returns:
the locale

setLocale

public void setLocale(java.util.Locale locale)
Description copied from interface: DataItemSelectorInterface
Sets the locale object to ensure that all messages returned are properly translated.

Specified by:
setLocale in interface DataItemSelectorInterface
Parameters:
locale - - the locale object

isCalculatedItemSelected

public boolean isCalculatedItemSelected()
Description copied from interface: DataItemSelectorInterface
Indicates if a calculated item is selected for any of the assigned roles.

Specified by:
isCalculatedItemSelected in interface DataItemSelectorInterface
Returns:
true if a calculated item is selected

queryItemsSupportDetailUsage

public boolean queryItemsSupportDetailUsage()
Description copied from interface: DataItemSelectorInterface
Indicates if all items selected for each role support the detail usage.

Specified by:
queryItemsSupportDetailUsage in interface DataItemSelectorInterface
Returns:
true if every selected item supports detail
See Also:
DataItemActionType

allQueryItemsAreDetailUsage

public boolean allQueryItemsAreDetailUsage()
Description copied from interface: DataItemSelectorInterface
Indicates if all items selected for each role are set to detail usage.

Specified by:
allQueryItemsAreDetailUsage in interface DataItemSelectorInterface
Returns:
true if every selected item is set to detail usage
See Also:
DataItemActionType

setQueryType

public void setQueryType(java.lang.String queryType)
Description copied from interface: DataItemSelectorInterface
Sets the value for the query type for relational queries.

Specified by:
setQueryType in interface DataItemSelectorInterface

getQueryType

public java.lang.String getQueryType()
Description copied from interface: DataItemSelectorInterface
Returns the current query type

Specified by:
getQueryType in interface DataItemSelectorInterface
Returns:
The current query type

isItemMoveUpValid

public boolean isItemMoveUpValid()
Description copied from interface: DataItemSelectorInterface
Returns true if the items contained in the selectedItems parameter can be moved up in the model order.

Specified by:
isItemMoveUpValid in interface DataItemSelectorInterface
Returns:
True if items can move up, otherwise false

isItemMoveDownValid

public boolean isItemMoveDownValid()
Description copied from interface: DataItemSelectorInterface
Returns true if the items contained in the selectedItems parameter can be moved down in the model order.

Specified by:
isItemMoveDownValid in interface DataItemSelectorInterface
Returns:
True if items can move down, otherwise false

getMoveTargetRoles

public java.util.List getMoveTargetRoles()
Description copied from interface: DataItemSelectorInterface
Returns a list of RoleInterface objects that the items contained in the selectedItems parameter can be moved to.

Specified by:
getMoveTargetRoles in interface DataItemSelectorInterface
Returns:
The list of roles the items can move to

setSelectedItems

public void setSelectedItems(java.lang.String[] items)
Description copied from interface: DataItemSelectorInterface
Sets the array of selected data items.

Specified by:
setSelectedItems in interface DataItemSelectorInterface
Parameters:
items - The array of selected items



Copyright © 2009 SAS Institute Inc. All Rights Reserved.