celeboss.data
Class CelebrityManager

java.lang.Object
  extended byceleboss.data.CelebrityManager
All Implemented Interfaces:
java.io.Serializable

public final class CelebrityManager
extends java.lang.Object
implements java.io.Serializable

This class represents the model of all the Celebrity data. THis class provides a factory class that controls the creation and lookup for Celebrity and Portfolio entities. It is also response for loading and saving the state of the model at start-up and shutdown.

Version:
1.0
Author:
bevans
See Also:
Serialized Form

Field Summary
static java.lang.String CELEB_DELISTED
          Property name for a celeb has been de-listed
static java.lang.String CELEB_LISTED
          Propery name for a new Celebrity listing
static java.lang.String NEWCELEB
          Property name for a new celeb being added.
static java.lang.String NEWLEAGUE
          Property name for a new mini league
static java.lang.String NEWPORTFOLIO
          Property name for a new portfolio being added
static java.lang.String OLDLEAGUE
          Property name for a mini league removed
static java.lang.String OLDPORTFOLIO
          Property name for a old portfolio being added
 
Method Summary
 void activate(CelebDataSourceFactory newFactory)
          A the Celebrity Manager to current environment.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a property change listener.
static CelebrityManager createManager()
          Creates a new manager with the default name.
static CelebrityManager createManager(java.lang.String newName)
          Creates a new manager with the specified name.
 Portfolio createPortfolio(java.lang.String user, java.lang.String pass)
          Create a new portfolio entry for the specified user account.
 void deletePortfolio(Portfolio portfolio)
          Delete a portfolio from the manager.
 int getActiveCelebrityRefresh()
          The refrresh period in minutes for celebrities that are active.
 PropertyChangeMediator getCelebMediator()
          Get the PropertyChangeMediator for any Celebrity events.
 java.util.Collection getCelebrities()
          Returns a collection of the Celebrities already loaded.
 Celebrity getCelebrity(int issue)
          Factory method to either create or find an existing Celebrity instance based on the issue number.
 int getCelebrityRefresh()
          How many minutes between refreshed.
 CelebDataSource getDefaultDataSource()
          Get the default data source used by this manager.
 java.util.Date getDividendDay()
          Return the date at which teh dividends are calculated.
 CommandEngine getEngine()
          Returnt he Comamnd eigne instance used by this manager.
 java.util.Date getKneecappingDay()
          Return the date at which the kneecappings are done.
 java.util.Collection getLeagues()
          Return a collection of the discovered Mini League objects.
 java.util.List getNewCelebrities()
          Returns a list of newly listed celebrities
 java.util.List getOldCelebrities()
          Returns a list of newly listed celebrities
 int getPortfolioRefresh()
          How many minutes between refreshed.
 java.util.Collection getPortfolios()
          Return a collection of the managed portfolios.
 void refreshCelebrityList()
          This method scans the known entities into the updater
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Remove a previous listeners.
 void setActiveCelebrityRefresh(int refresh)
          Update how oftern active celebrities should be refreshed
 void setCelebrityRefresh(int i)
          Define how long in seconds between celebrities are refreshed.
 void setDefaultUser(java.lang.String username, java.lang.String password)
          This sets the default username and password for an account to use when updating the background Celebtiry information.
 void setPortfolioRefresh(int i)
          Define how long in seconds between portfolios are refreshed.
 void shutdown()
          Shutdown the manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CELEB_DELISTED

public static final java.lang.String CELEB_DELISTED
Property name for a celeb has been de-listed

See Also:
Constant Field Values

CELEB_LISTED

public static final java.lang.String CELEB_LISTED
Propery name for a new Celebrity listing

See Also:
Constant Field Values

NEWCELEB

public static final java.lang.String NEWCELEB
Property name for a new celeb being added. A later LISTED event may be generated

See Also:
Constant Field Values

NEWLEAGUE

public static final java.lang.String NEWLEAGUE
Property name for a new mini league

See Also:
Constant Field Values

NEWPORTFOLIO

public static final java.lang.String NEWPORTFOLIO
Property name for a new portfolio being added

See Also:
Constant Field Values

OLDLEAGUE

public static final java.lang.String OLDLEAGUE
Property name for a mini league removed

See Also:
Constant Field Values

OLDPORTFOLIO

public static final java.lang.String OLDPORTFOLIO
Property name for a old portfolio being added

See Also:
Constant Field Values
Method Detail

createManager

public static CelebrityManager createManager()
Creates a new manager with the default name. This method will attempt to load a previously saved model with the specified name. Currently this will use Serialization and look for a file with the specified name in the default directory.

Returns:
New Celebrity manager
See Also:
createManager(String)

createManager

public static CelebrityManager createManager(java.lang.String newName)
Creates a new manager with the specified name. This method will attempt to load a previously saved model with the specified name. Currently this will use Serialization and look for a file with the specified name in the default directory. The manager can be later initialised with a data source factory.

Parameters:
newName - Name of the manager.
Returns:
New Celebrity manager
See Also:
activate(CelebDataSourceFactory)

activate

public void activate(CelebDataSourceFactory newFactory)
A the Celebrity Manager to current environment. This will trigger the dynamic upodate of the manager.

Parameters:
newFactory - Factory to use to create any data sources.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener.

Parameters:
listener - Listener.

createPortfolio

public Portfolio createPortfolio(java.lang.String user,
                                 java.lang.String pass)
Create a new portfolio entry for the specified user account.

Parameters:
user - Account id.
pass - Password for account
Returns:
Newly crfeate portfolio.

deletePortfolio

public void deletePortfolio(Portfolio portfolio)
Delete a portfolio from the manager.

Parameters:
portfolio - One to delete

getActiveCelebrityRefresh

public int getActiveCelebrityRefresh()
The refrresh period in minutes for celebrities that are active. Active celebs are those that have a price change.

Returns:
Returns the activeCelebrityRefresh.

getCelebMediator

public PropertyChangeMediator getCelebMediator()
Get the PropertyChangeMediator for any Celebrity events.

Returns:
Returns the celebMediator.

getCelebrities

public java.util.Collection getCelebrities()
Returns a collection of the Celebrities already loaded.

Returns:
Collection of Celebrity instances.

getCelebrity

public Celebrity getCelebrity(int issue)
Factory method to either create or find an existing Celebrity instance based on the issue number.

Parameters:
issue - Issue number.
Returns:
Celebrity instance with issue.

getCelebrityRefresh

public int getCelebrityRefresh()
How many minutes between refreshed.

Returns:
Minutes for refresh.

getDefaultDataSource

public CelebDataSource getDefaultDataSource()
Get the default data source used by this manager.

Returns:
The default data sourse assigned to this manager.

getDividendDay

public java.util.Date getDividendDay()
Return the date at which teh dividends are calculated. This marks the end of the dividend week.

Returns:
Date.

getEngine

public CommandEngine getEngine()
Returnt he Comamnd eigne instance used by this manager.

Returns:
Command engine in use.

getKneecappingDay

public java.util.Date getKneecappingDay()
Return the date at which the kneecappings are done. This marks the end of the dividend week.

Returns:
Date.

getLeagues

public java.util.Collection getLeagues()
Return a collection of the discovered Mini League objects.

Returns:
Collection of MiniLeagues

getNewCelebrities

public java.util.List getNewCelebrities()
Returns a list of newly listed celebrities

Returns:
Returns the newCelebrities.

getOldCelebrities

public java.util.List getOldCelebrities()
Returns a list of newly listed celebrities

Returns:
Returns the oldCelebrities.

getPortfolioRefresh

public int getPortfolioRefresh()
How many minutes between refreshed.

Returns:
Minutes for refresh.

getPortfolios

public java.util.Collection getPortfolios()
Return a collection of the managed portfolios.

Returns:
Collection of Portfolios instanced.

refreshCelebrityList

public void refreshCelebrityList()
This method scans the known entities into the updater


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a previous listeners.

Parameters:
listener - Listener

setActiveCelebrityRefresh

public void setActiveCelebrityRefresh(int refresh)
Update how oftern active celebrities should be refreshed

Parameters:
refresh - The activeCelebrityRefresh to set.

setCelebrityRefresh

public void setCelebrityRefresh(int i)
Define how long in seconds between celebrities are refreshed. This does not effect already queued entries.

Parameters:
i - Number of minutes between updates.

setDefaultUser

public void setDefaultUser(java.lang.String username,
                           java.lang.String password)
This sets the default username and password for an account to use when updating the background Celebtiry information.

Parameters:
username - Celebdaq account.
password - Correct password.

setPortfolioRefresh

public void setPortfolioRefresh(int i)
Define how long in seconds between portfolios are refreshed. This does not effect already queued entries.

Parameters:
i - Number of minutes between updates.

shutdown

public void shutdown()
              throws java.io.IOException
Shutdown the manager. This stops the updater Thread and saves all state to external source.

Throws:
java.io.IOException - Problem with store