Class
caplin.trading.service

TOBOUserServiceProvider

The TOBOUserServiceProvider class provides a implementation of the caplin.trading.service.TOBOUserService which uses the caplin.trading.service.TOBOUserPermissionServiceListener and the provided caplin.trading.service.TradePermissionService to get the permissions of the currently logged-in user, which users he can trade on behalf of, and which of there TOBO users' accounts can be used to this end.

The TOBOUserServiceProvider maintains a state consisting of the logged-in user's type (TRADER or SALES) selected TOBO user and account, and the list of available TOBO users and accounts for the selected TOBO user, if any. (SALES users are allowed to trade on behalf of other users whereas TRADER users are not.) This state is kept up-to-date by the permission listener. It also keeps track of the number of trades started by the logged-in user, locking all listeners if at least one trade is started.

The TOBOUserServiceProvider also acts as a caplin.trading.trademodel.TradeOnBehalfOfListener, suspending trading while TOBO user changes are occurring in the application.

Constructor Summary

Attributes Name and Description
caplin.trading.service.TOBOUserServiceProvider(caplin.trading.trademodel.TradeOnBehalfOf oTradeOnBehalfOf)

Constructs an instance of caplin.trading.service.TOBOUserServiceProvider.

Method Summary

Attributes Name and Description
void addListener(caplin.trading.service.TOBOUserServiceListener oListener)

Add a listener to the TOBOUserServiceProvider to be notified of changes in the selected TOBO user, user type and account, the list of available TOBO users and accounts and the TOBO user service lock.

boolean canPerformTrade()

Returns true if the logged-in user can trade on behalf of other users and has selected a TOBO user to trade on behalf of.

boolean canTradeOnBehalfOf()

This method can be used to query whether the logged-in user can trade on behalf of other users.

String getAccount()

Returns the account of the currently selected TOBO user which is being used by the logged-in user.

String getTradeOnBehalfOfUser()

Returns the TOBO user whom the logged-in user is trading on behalf of.

String getUserType()

Returns the type of the logged-in user.

void removeListener(caplin.trading.service.TOBOUserServiceListener oListener)

Remove a listener of the TOBOUserServiceProvider.

void setAccount(String sAccount)

Sets the current TOBO user's account to be used for trading by the logged-in user.

void setTradeOnBehalfOfUser(String sUser)

This method sets the TOBO user and updates the account list with the accounts available for the new TOBO user.

void tradeFinished()

This method is called by the trading components.

void tradeOnBehalfOfChangeFailed( sReason)

A pending "trade on behalf of" change has failed, and any subsequent prices are from the old tier.

void tradeOnBehalfOfChangeInitiated( sPermissionable)

A "trade on behalf of" change has been initiated, and we are currently awaiting prices for the new tier.

void tradeOnBehalfOfUserChanged( sPermissionable)

A "trade on behalf of" change has been completed, and any subsequent prices are from the new tier.

void tradeStarted()

This method is called by the trading components, triggering caplin.trading.service.TOBOUserServiceListener#onLockChanged on all the TOBOUserService's listeners, enabling them to 'lock' their behaviour.

Constructor Detail

caplin.trading.service.TOBOUserServiceProvider(caplin.trading.trademodel.TradeOnBehalfOf oTradeOnBehalfOf)

Constructs an instance of caplin.trading.service.TOBOUserServiceProvider.

Parameters
caplin.trading.trademodel.TradeOnBehalfOf oTradeOnBehalfOf The trade-on-behalf-of object.

Method Detail

void addListener(caplin.trading.service.TOBOUserServiceListener oListener)

Add a listener to the TOBOUserServiceProvider to be notified of changes in the selected TOBO user, user type and account, the list of available TOBO users and accounts and the TOBO user service lock.

Parameters
caplin.trading.service.TOBOUserServiceListener oListener Listener object.
See
caplin.trading.service.TOBOUserServiceProvider#addListener

boolean canPerformTrade()

Returns true if the logged-in user can trade on behalf of other users and has selected a TOBO user to trade on behalf of.

Returns
{boolean}
See
caplin.trading.service.TOBOUserServiceProvider#canPerformTrade

boolean canTradeOnBehalfOf()

This method can be used to query whether the logged-in user can trade on behalf of other users.

Returns
{boolean} True if logged-in user can trade on behalf of other users.
See
caplin.trading.service.TOBOUserServiceProvider#canTradeOnBehalfOf

String getAccount()

Returns the account of the currently selected TOBO user which is being used by the logged-in user.

Returns
{String} The account name.
See
caplin.trading.service.TOBOUserServiceProvider#getAccount

String getTradeOnBehalfOfUser()

Returns the TOBO user whom the logged-in user is trading on behalf of.

Returns
{String} The current TOBO user's userName.
See
caplin.trading.service.TOBOUserServiceProvider#getTradeOnBehalfOfUser

String getUserType()

Returns the type of the logged-in user.

Returns
{String} The current logged-in user's type.
See
caplin.trading.service.TOBOUserServiceProvider#getUserType

void removeListener(caplin.trading.service.TOBOUserServiceListener oListener)

Remove a listener of the TOBOUserServiceProvider.

Parameters
caplin.trading.service.TOBOUserServiceListener oListener Listener object.
See
caplin.trading.service.TOBOUserServiceProvider#removeListener

void setAccount(String sAccount)

Sets the current TOBO user's account to be used for trading by the logged-in user. caplin.trading.service.TOBOUserServiceListener#onTOBOAccountChanged is called on all the TOBOUserService's listeners.

Parameters
String sAccount The account name.
See
caplin.trading.service.TOBOUserServiceProvider#setAccount

void setTradeOnBehalfOfUser(String sUser)

This method sets the TOBO user and updates the account list with the accounts available for the new TOBO user. caplin.trading.service.TOBOUserServiceListener#onTOBOUserChanged is called on all the TOBOUserService's listeners.

Parameters
String sUser The TOBO user's userName.
See
caplin.trading.service.TOBOUserServiceProvider#setTradeOnBehalfOfUser

void tradeFinished()

This method is called by the trading components. If the TOBOUserService detects that no more trades are executing, the caplin.trading.service.TOBOUserServiceListener#onLockChanged is called on all the TOBOUserService's listeners, enabling them to 'unlock' their behaviour.

See
caplin.trading.service.TOBOUserServiceProvider#tradeFinished

void tradeOnBehalfOfChangeFailed( sReason)

A pending "trade on behalf of" change has failed, and any subsequent prices are from the old tier.

Parameters
sReason {String} A string description of the reason for failure.

void tradeOnBehalfOfChangeInitiated( sPermissionable)

A "trade on behalf of" change has been initiated, and we are currently awaiting prices for the new tier. Any existing prices should be considered stale.

Parameters
sPermissionable {String} A string representing the permissionable item that we are going to "trade on behalf of".

void tradeOnBehalfOfUserChanged( sPermissionable)

A "trade on behalf of" change has been completed, and any subsequent prices are from the new tier.

Parameters
sPermissionable {String} A string representing the permissionable item that we are now "trading on behalf of".

void tradeStarted()

This method is called by the trading components, triggering caplin.trading.service.TOBOUserServiceListener#onLockChanged on all the TOBOUserService's listeners, enabling them to 'lock' their behaviour.

See
caplin.trading.service.TOBOUserServiceProvider#tradeStarted