com.sas.commands.dataselectors
Class SimpleCalculatedItemSelectorCommand

com.sas.commands.dataselectors.SimpleCalculatedItemSelectorCommand
All Implemented Interfaces:
CommandStatusInterface, CancelInterface, ContentsChangedInterface, DataSelectorCommandInterface, DynamicAttributeCommandInterface, PendingCommandInterface, BaseEntityInterface, BaseEntityValueInterface, EntityKeyInterface, com.sas.lang.StringDataInterface, com.sas.PublicClonable, com.sas.util.Command, com.sas.util.SimpleCommand, java.lang.Cloneable, java.rmi.Remote

public class SimpleCalculatedItemSelectorCommand
implements CommandStatusInterface

This class implements the command for processing calculated items in the simple calculated item selector command. This command is only supported when the associated data model is an instance of BusinessQueryProviderInterface.

The command is responsible for processing actions, via the Action Provider Framework, as they are initiated by the visual in response to user input. Actions include show, process, commit, and cancel. Each action causes a corresponding method on this command to be invoked.

The show action creates an instance of CalculatedItemListInterface to provide to the visual and then sets the state of the simple calculated item selector so it can be displayed to the user.

The commit action is invoked when the user leaves the selector visual by pressing the OK button. Commit first validates the items coming from the selector client visual; if there are invalid items, an event is generated to notify the visual that the user needs to correct the invalid items. If all the items are valid, then the command processes each item in an appropriate fashion in order to update the business query.

The cancel action is invoked when the user leaves the selector visual by pressing the Cancel button. There is no specific processing by this command for the cancel action.

The process action is not used by this command.

See Also:
SimpleCalculatedItemSelectorPanel, BusinessQueryProviderInterface, CalculatedItemListInterface, BusinessQueryToCalculatedItemListAdapter

Field Summary
static java.lang.String ADD_STATE
          Specifies that the given item is to be added to the list of calculated items.
protected  java.lang.String[] basePeriodList
           
protected  CalculatedItemListInterface calculatedItemList
          The list of calculated item objects processed by this command.
static java.lang.String DELETE_STATE
          Specifies that the given item is to be replaced in the list of calculated items.
protected  java.lang.String descriptionEntry
          Used to access the value of the description entry field on the visual driving this command.
protected  java.lang.String[] descriptionList
          Used to access the value of the descriptions of the calculated items on the visual driving this command.
protected  java.lang.String expressionArea
          Used to access the value of the expression area field on the visual driving this command.
protected  java.lang.String[] expressionList
          Used to access the value of the expressions of the calculated items on the visual driving this command.
protected  java.lang.String[] formatList
          Used to access the value of the expressions of the calculated items on the visual driving this command.
protected  java.lang.String[] functionList
           
protected  java.lang.String[] idList
          Used to access the value of the ids of the calculated items on the visual driving this command.
static java.lang.String INVALID_ITEM_KEY
          Key used to identify list of invalid items to SimpleCalculatedItemSelectorPanel so that appropriate action can be taken by the view.
protected  java.util.List invalidItemList
          Stores a list of any items received from the client which are invalid calculated items, usually because the expression for the calculated item is invalid.
protected  java.lang.String[] measureItems
           
protected  java.lang.String nameEntry
          Used to access the value of the name entry field on the visual driving this command.
protected  java.lang.String[] nameList
          Used to access the value of the names of the calculated items on the visual driving this command.
static java.lang.String RB_KEY
          Key used to find resources in the resource bundle for this command.
static java.lang.String REPLACE_STATE
          Specifies that the given item is to be replaced in the list of calculated items.
protected  java.lang.String[] stateList
          Used to access the value of the states for the calculated items on the visual driving this command.
static java.lang.String UPDATE_STATE
          Specifies that the given item is to be updated in the list of calculated items.
 
Fields inherited from class com.sas.commands.dataselectors.BaseSelectorCommand
actionClass, CANCEL_MODE, COMMIT_MODE, complete, contentsChanged, eventInfo, eventSource, modal, mode, model, PROCESS_MODE, selector, selectorModel, SHOW_MODE
 
Fields inherited from interface com.sas.actionprovider.CommandStatusInterface
DISABLED, ENABLED, IS_CURRENT_STATE_DISABLED, MODEL_MEMBER_DISABLED, MODEL_STATE_DISABLED, MODEL_TYPE_DISABLED
 
Fields inherited from interface com.sas.commands.DynamicAttributeCommandInterface
COMMAND_NAME_PREFIX
 
Constructor Summary
SimpleCalculatedItemSelectorCommand()
          Constructs the default version of the command.
SimpleCalculatedItemSelectorCommand(java.lang.String name)
          Constructor that accepts a command name.
SimpleCalculatedItemSelectorCommand(java.lang.String name, java.lang.String actionClass)
          Constructor that accepts a command name and an action class type.
 
Method Summary
protected  void addItem(int clientIndex)
          Adds a new calculated item from the client to the list.
 void cancel(java.lang.Object o)
           
protected  void commit(java.lang.Object o)
          Invoked when the user presses OK on the selector.
protected  void deleteItem(int clientIndex)
          Deletes an existing calculated item in the list.
 CalculatedItemListInterface getAdapter(java.lang.Object model)
          Returns an instance of a CalculatedItemListInterface based on the given model.
 java.lang.String[] getBasePeriodList()
           
protected  int getCalculatedItemIndex(java.lang.String calculatedItemId)
          Returns the index of a calculated item in the server-side calculated item list.
 int getCommandStatus(ActionSupportFilter filter)
          Returns a int value indicating whether the command is enabled for the given area as specified by the current area information encapsulated in the ActionSupportFilter.
 java.lang.String getDescriptionEntry()
          Get the value entered by the user in the description entry field.
 java.lang.String[] getDescriptionList()
          Gets the list of calculated item descriptions that were sent from the client to the server.
 java.lang.String getExpressionArea()
          Get the value entered by the user in the expression area.
 java.lang.String[] getExpressionList()
          Gets the list of calculated item expressions that were sent from the client to the server.
 java.lang.String getFormatEntry()
           
 java.lang.String[] getFormatList()
          Gets the list of calculated item formats that were sent from the client to the server.
 java.lang.String[] getFunctionList()
           
 java.lang.String[] getIdList()
          Gets the list of calculated item ids that were sent from the client to the server.
 com.sas.iquery.metadata.business.DataItem getMeasureItem(java.lang.String measureName, CalculatedItemV2Interface item)
           
 java.lang.String getNameEntry()
          Get the value entered by the user in the name entry field.
 java.lang.String[] getNameList()
          Gets the list of calculated item names that were sent from the client to the server.
 java.lang.String[] getStateList()
          Gets the list of calculated item states that were sent from the client to the server.
protected  void process(java.lang.Object o)
          Invoked to display the selector to the user.
protected  void processCalculatedItems()
          Processes the list of calculated items returned from the client and takes appropriate action based on the state of any given item.
 void setBasePeriodList(java.lang.String[] basePeriods)
           
 void setDescriptionEntry(java.lang.String description)
          Set the value entered by the user in the description entry field.
 void setDescriptionList(java.lang.String[] descriptions)
          Sets the list of calculated item descriptions that were sent from the client.
 void setExpressionArea(java.lang.String expression)
          Set the value entered by the user in the expression area.
 void setExpressionList(java.lang.String[] expressions)
          Sets the list of calculated item expressions that were sent from the client.
 void setFormatEntry(java.lang.String formatEntry)
           
 void setFormatList(java.lang.String[] formats)
          Sets the list of calculated item formats that were sent from the client.
 void setFunctionList(java.lang.String[] functionList)
           
 void setIdList(java.lang.String[] names)
          Sets the list of calculated item ids that were sent from the client.
 void setNameEntry(java.lang.String name)
          Set the value entered by the user in the name entry field.
 void setNameList(java.lang.String[] names)
          Sets the list of calculated item names that were sent from the client.
 void setStateList(java.lang.String[] states)
          Sets the list of calculated item states that were sent from the client.
protected  void show(java.lang.Object o)
          Invoked to display the selector to the user.
protected  void updateItem(int clientIndex)
          Updates an existing calculated item in the list.
 
Methods inherited from class com.sas.commands.dataselectors.BaseSelectorCommand
cancel, closeSelector, execute, getEventInfo, getEventSource, getMode, getModel, getSelector, getSelectorModel, isComplete, isContentsChanged, isModal, setComplete, setModal, setMode, setModel, setSelector, setSelectorModel
 
Methods inherited from class com.sas.commands.BaseCommand
getLocale, getName, getNextCommandName, getText, isExecutable, isUndoable, setLocale, setName, setText, undo
 
Methods inherited from class com.sas.entities.BaseEntity
clone, containsAttributeNamed, equals, equals, getAttribute, getAttribute, getAttributeCount, getAttributes, getEntityKey, getPropertyDescriptors, getStringAttribute, listAttributeNames, removeAllAttributes, removeAttribute, reset, sameEntity, setAttribute, setAttributes, setEntityKey, toString
 
Methods inherited from interface com.sas.entities.BaseEntityValueInterface
getAttribute, setAttribute
 
Methods inherited from interface com.sas.util.Command
clone
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
Key used to find resources in the resource bundle for this command.

See Also:
Constant Field Values

INVALID_ITEM_KEY

public static final java.lang.String INVALID_ITEM_KEY
Key used to identify list of invalid items to SimpleCalculatedItemSelectorPanel so that appropriate action can be taken by the view.

See Also:
Constant Field Values

calculatedItemList

protected CalculatedItemListInterface calculatedItemList
The list of calculated item objects processed by this command.


nameEntry

protected java.lang.String nameEntry
Used to access the value of the name entry field on the visual driving this command.


descriptionEntry

protected java.lang.String descriptionEntry
Used to access the value of the description entry field on the visual driving this command.


expressionArea

protected java.lang.String expressionArea
Used to access the value of the expression area field on the visual driving this command.


nameList

protected java.lang.String[] nameList
Used to access the value of the names of the calculated items on the visual driving this command. The values contained in nameList will be received from the client visual.


descriptionList

protected java.lang.String[] descriptionList
Used to access the value of the descriptions of the calculated items on the visual driving this command. The values contained in descriptionList will be received from the client visual.


expressionList

protected java.lang.String[] expressionList
Used to access the value of the expressions of the calculated items on the visual driving this command. The values contained in expressionList will be received from the client visual.


stateList

protected java.lang.String[] stateList
Used to access the value of the states for the calculated items on the visual driving this command. The values contained in stateList will be received from the client visual.


idList

protected java.lang.String[] idList
Used to access the value of the ids of the calculated items on the visual driving this command. The values contained in idList will be received from the client visual.


formatList

protected java.lang.String[] formatList
Used to access the value of the expressions of the calculated items on the visual driving this command. The values contained in expressionList will be received from the client visual.


invalidItemList

protected java.util.List invalidItemList
Stores a list of any items received from the client which are invalid calculated items, usually because the expression for the calculated item is invalid.


functionList

protected java.lang.String[] functionList

measureItems

protected java.lang.String[] measureItems

basePeriodList

protected java.lang.String[] basePeriodList

ADD_STATE

public static final java.lang.String ADD_STATE
Specifies that the given item is to be added to the list of calculated items.

See Also:
Constant Field Values

UPDATE_STATE

public static final java.lang.String UPDATE_STATE
Specifies that the given item is to be updated in the list of calculated items.

See Also:
Constant Field Values

DELETE_STATE

public static final java.lang.String DELETE_STATE
Specifies that the given item is to be replaced in the list of calculated items.

See Also:
Constant Field Values

REPLACE_STATE

public static final java.lang.String REPLACE_STATE
Specifies that the given item is to be replaced in the list of calculated items. An item that is to be replaced is first deleted and then added so that any default properties on the calculated item are restored.

See Also:
Constant Field Values
Constructor Detail

SimpleCalculatedItemSelectorCommand

public SimpleCalculatedItemSelectorCommand()
Constructs the default version of the command.


SimpleCalculatedItemSelectorCommand

public SimpleCalculatedItemSelectorCommand(java.lang.String name)
Constructor that accepts a command name.

Parameters:
name - the name of the command

SimpleCalculatedItemSelectorCommand

public SimpleCalculatedItemSelectorCommand(java.lang.String name,
                                           java.lang.String actionClass)
Constructor that accepts a command name and an action class type.

Parameters:
name - the name of the command
actionClass - the class name of the associated action
Method Detail

show

protected void show(java.lang.Object o)
Invoked to display the selector to the user.

Overrides:
show in class BaseSelectorCommand
Parameters:
o - not used by this method

process

protected void process(java.lang.Object o)
Invoked to display the selector to the user.

Overrides:
process in class BaseSelectorCommand
Parameters:
o - not used by this method

commit

protected void commit(java.lang.Object o)
               throws java.io.IOException
Invoked when the user presses OK on the selector.

Overrides:
commit in class BaseSelectorCommand
Parameters:
o - not used by this method.
Throws:
java.io.IOException

getMeasureItem

public com.sas.iquery.metadata.business.DataItem getMeasureItem(java.lang.String measureName,
                                                                CalculatedItemV2Interface item)

getAdapter

public CalculatedItemListInterface getAdapter(java.lang.Object model)
Returns an instance of a CalculatedItemListInterface based on the given model.

Parameters:
model - is an object from which a CalculatedItemListInterface can be created. The model must be an instance of a BusinessQueryProviderInterface.
Returns:
an instance of a CalculatedItemListInterface if one can be created from the model; null otherwise.

getNameEntry

public java.lang.String getNameEntry()
Get the value entered by the user in the name entry field.

Returns:
the value entered by the user in the name entry field.

setNameEntry

public void setNameEntry(java.lang.String name)
Set the value entered by the user in the name entry field.

Parameters:
name - is the user entered value for the name entry field.

getDescriptionEntry

public java.lang.String getDescriptionEntry()
Get the value entered by the user in the description entry field.

Returns:
the value entered by the user in the description entry field.

setDescriptionEntry

public void setDescriptionEntry(java.lang.String description)
Set the value entered by the user in the description entry field.

Parameters:
description - is the user entered value for the description entry field.

getExpressionArea

public java.lang.String getExpressionArea()
Get the value entered by the user in the expression area.

Returns:
the value entered by the user in the expression area.

setExpressionArea

public void setExpressionArea(java.lang.String expression)
Set the value entered by the user in the expression area.

Parameters:
expression - is the user entered value for the expression area.

getNameList

public java.lang.String[] getNameList()
Gets the list of calculated item names that were sent from the client to the server.

Returns:
the list of calculated item names from the client.

setNameList

public void setNameList(java.lang.String[] names)
Sets the list of calculated item names that were sent from the client. These names should be passed from the client and set by the Action Provider.

Parameters:
names - is an array of calculated item names from the client.

getDescriptionList

public java.lang.String[] getDescriptionList()
Gets the list of calculated item descriptions that were sent from the client to the server.

Returns:
the list of calculated item descriptions from the client.

setDescriptionList

public void setDescriptionList(java.lang.String[] descriptions)
Sets the list of calculated item descriptions that were sent from the client. These descriptions should be passed from the client and set by the Action Provider.

Parameters:
descriptions - is an array of calculated item descriptions from the client.

getExpressionList

public java.lang.String[] getExpressionList()
Gets the list of calculated item expressions that were sent from the client to the server.

Returns:
the list of calculated item expressions from the client.

setExpressionList

public void setExpressionList(java.lang.String[] expressions)
Sets the list of calculated item expressions that were sent from the client. These expressions should be passed from the client and set by the Action Provider.

Parameters:
expressions - is an array of calculated item expressions from the client.

getStateList

public java.lang.String[] getStateList()
Gets the list of calculated item states that were sent from the client to the server.

Returns:
the list of calculated item states from the client.
See Also:
ADD_STATE, UPDATE_STATE, DELETE_STATE, REPLACE_STATE

getFormatList

public java.lang.String[] getFormatList()
Gets the list of calculated item formats that were sent from the client to the server.

Returns:
the list of calculated item formats from the client.

setFormatList

public void setFormatList(java.lang.String[] formats)
Sets the list of calculated item formats that were sent from the client. These formats should be passed from the client and set by the Action Provider.

Parameters:
names - is an array of calculated item formats from the client.

getFunctionList

public java.lang.String[] getFunctionList()

getBasePeriodList

public java.lang.String[] getBasePeriodList()

setStateList

public void setStateList(java.lang.String[] states)
Sets the list of calculated item states that were sent from the client. These states should be passed from the client and set by the Action Provider.

Parameters:
states - is an array of calculated item states from the client.
See Also:
ADD_STATE, UPDATE_STATE, DELETE_STATE, REPLACE_STATE

setFunctionList

public void setFunctionList(java.lang.String[] functionList)

setBasePeriodList

public void setBasePeriodList(java.lang.String[] basePeriods)

getIdList

public java.lang.String[] getIdList()
Gets the list of calculated item ids that were sent from the client to the server.

Returns:
the list of calculated item ids from the client.

setIdList

public void setIdList(java.lang.String[] names)
Sets the list of calculated item ids that were sent from the client. These ids should be passed from the client and set by the Action Provider.

Parameters:
names - is an array of calculated item ids from the client.

getCalculatedItemIndex

protected int getCalculatedItemIndex(java.lang.String calculatedItemId)
Returns the index of a calculated item in the server-side calculated item list. If the calculated item is not in the list, then -1 is returned.

Parameters:
calculatedItemId - is a string representing the id of the item to find.
Returns:
the index (>= 0) of the calculated item in the server-side calculated item list if the item is found; -1 otherwise

processCalculatedItems

protected void processCalculatedItems()
Processes the list of calculated items returned from the client and takes appropriate action based on the state of any given item. This method first validates all items received from the client. If there is at least one invalid item, no further processing occurs. If all items are valid, then the each item is examined to determine if it is an add, update, delete, or replace, and the appropriate method is called.

See Also:
ADD_STATE, UPDATE_STATE, DELETE_STATE, REPLACE_STATE, addItem(int), updateItem(int), deleteItem(int)

addItem

protected void addItem(int clientIndex)
Adds a new calculated item from the client to the list. The label, description, and expression of the calculated item are set based on the values received from the client for this item.

Parameters:
clientIndex - is the index of the item to be added from the array received from the client

updateItem

protected void updateItem(int clientIndex)
Updates an existing calculated item in the list. This method finds the existing item in the list and updates it in place. The label, description, and expression of the calculated item are updated based on the values received from the client; all other properties remain unchanged.

Parameters:
clientIndex - is the index of the item to be updated from the array received from the client

deleteItem

protected void deleteItem(int clientIndex)
Deletes an existing calculated item in the list. This method finds the existing item in the list and deletes it from the list if it is found.

Note: items can only be deleted from the server list if they have previously been added. In other words, if an item is added on the client and then deleted on the client, within the same selector invocation, it will never be sent to the server to be deleted. However, if it is added, and the user launches the selector again to delete the item, then this method will process that deletion.

Parameters:
clientIndex - is the index of the item to be deleted from the array received from the client

getCommandStatus

public int getCommandStatus(ActionSupportFilter filter)
Returns a int value indicating whether the command is enabled for the given area as specified by the current area information encapsulated in the ActionSupportFilter. If not enabled, the key indicates a reason why the command is not enabled. The Calculated item selector is disabled when all items in the query are set to detail usage. Calculated items do not support detail usage, and this prevents the query from getting in a state where the items are of mixed usage which could produce enexpected results. The selector can also be disabled if the BusinessQuery does not allow manipulation of the result items.

Specified by:
getCommandStatus in interface CommandStatusInterface
Parameters:
filter - The ActionSupportFilter that encapsulates all the necessary information to describe the current area.
Returns:
MODEL_MEMBER_DISABLED if all items in the query are set to detail usage
See Also:
BaseAction.setReturnStatus(int)

getFormatEntry

public java.lang.String getFormatEntry()
Returns:
Returns the formatEntry.

setFormatEntry

public void setFormatEntry(java.lang.String formatEntry)
Parameters:
formatEntry - The formatEntry to set.

cancel

public void cancel(java.lang.Object o)
Overrides:
cancel in class BaseSelectorCommand
Parameters:
o - ignored in this implementation



Copyright © 2009 SAS Institute Inc. All Rights Reserved.