com.neoworks.jukex.sqlimpl
Class JukeXTrackStore

java.lang.Object
  |
  +--com.neoworks.jukex.sqlimpl.JukeXTrackStore
All Implemented Interfaces:
TrackStore

public class JukeXTrackStore
extends java.lang.Object
implements TrackStore

The JukeXTrackStore using a MySQL back end. This is where all core objects should be obtained from.

Author:
Nick Vincent nick@neoworks.com

Field Summary
static java.lang.String DB_NAME
          Name of the database to use
 
Method Summary
 Attribute createAttribute(java.lang.String name, int type)
          Create a new attribute for data to support in the jukebox schema
 Playlist createPlaylist(java.lang.String name)
          Create a playlist with the specified name
 java.util.Collection getAllPlaylists()
          Return all of the Playlists currently defined
 Attribute getAttribute(java.lang.String name)
          Return the Attribute object representing the attribute with that name
 java.util.Set getAttributes()
          Get a list of all the attributes currently supported by the system
 BatchTrackLoader getBatchTrackLoader()
          Return a batch track loader
 java.lang.String getDBName()
          Get the name of the database the TrackStore is using
static TrackStore getInstance()
          Get an instance of the TrackStore
 Playlist getPlaylist(java.lang.String name)
          Get the Playlist with the specified name
 Track getTrack(long id)
          Get a track from the database by database id
 Track getTrack(java.net.URL url)
          Get a track from the database by URL
 long getTrackCount()
          Get the total track count
 long[] getTrackIds()
          Get an array containing the ids of the tracks in the Track database
 java.util.List getTracks(java.util.List ids)
          Get a List of Tracks corresponding to a list of database ids
 java.util.List getTracks(long[] ids)
          Retrieve a List of Track objects with ids as specified in the passed array
 void initialise()
          Initialise track store
 Track storeTrack(java.net.URL url, java.util.Date modifiedTime)
          Create a track in the database with the specified url and return the object representing that track.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DB_NAME

public static final java.lang.String DB_NAME
Name of the database to use

See Also:
Constant Field Values
Method Detail

getInstance

public static TrackStore getInstance()
Get an instance of the TrackStore

Returns:
A TrackStore instance

initialise

public void initialise()
Initialise track store


getTrackCount

public long getTrackCount()
Get the total track count

Specified by:
getTrackCount in interface TrackStore
Returns:
The total number of tracks in the database

getTrack

public Track getTrack(java.net.URL url)
Get a track from the database by URL

Specified by:
getTrack in interface TrackStore
Parameters:
url - The URL of the track
Returns:
A Track object corresponding to the given URL

getTrack

public Track getTrack(long id)
Get a track from the database by database id

Specified by:
getTrack in interface TrackStore
Parameters:
id - The id of the track
Returns:
The Track corresponding to the id given

getTracks

public java.util.List getTracks(long[] ids)
Retrieve a List of Track objects with ids as specified in the passed array

Specified by:
getTracks in interface TrackStore
Parameters:
ids - The array of ids of Tracks to retrieve
Returns:
A List of Track objects

getTracks

public java.util.List getTracks(java.util.List ids)
Get a List of Tracks corresponding to a list of database ids

Specified by:
getTracks in interface TrackStore
Parameters:
ids - A List of database track ids
Returns:
A List of the tracks corresponding to the ids passed in

storeTrack

public Track storeTrack(java.net.URL url,
                        java.util.Date modifiedTime)
Description copied from interface: TrackStore
Create a track in the database with the specified url and return the object representing that track.

Specified by:
storeTrack in interface TrackStore
Parameters:
url - The URL of the track to be added to the database
modifiedTime - The date that this Track entry was modified
Returns:
The newly added Track

getAttribute

public Attribute getAttribute(java.lang.String name)
Description copied from interface: TrackStore
Return the Attribute object representing the attribute with that name

Specified by:
getAttribute in interface TrackStore
Returns:
The Attribute object representing the name passed, or null, if it is not found.

getAttributes

public java.util.Set getAttributes()
Get a list of all the attributes currently supported by the system

Specified by:
getAttributes in interface TrackStore
Returns:
The Set of all Attribute objects currently available in the database.

createAttribute

public Attribute createAttribute(java.lang.String name,
                                 int type)
                          throws java.lang.Exception
Create a new attribute for data to support in the jukebox schema

Specified by:
createAttribute in interface TrackStore
Parameters:
name - The name of the Attribute
type - The type of the Attribute
Returns:
An attribute with the corresponding name and type.
Throws:
java.lang.Exception

getDBName

public java.lang.String getDBName()
Get the name of the database the TrackStore is using

Returns:
The name of the database

getTrackIds

public long[] getTrackIds()
Description copied from interface: TrackStore
Get an array containing the ids of the tracks in the Track database

Specified by:
getTrackIds in interface TrackStore
Returns:
An array of track ids

getPlaylist

public Playlist getPlaylist(java.lang.String name)
Get the Playlist with the specified name

Specified by:
getPlaylist in interface TrackStore
Parameters:
name - The name of the playlist required
Returns:
The Playlist corresponding to the name given

createPlaylist

public Playlist createPlaylist(java.lang.String name)
Create a playlist with the specified name

Specified by:
createPlaylist in interface TrackStore
Returns:
A Playlist with the specified name

getAllPlaylists

public java.util.Collection getAllPlaylists()
Description copied from interface: TrackStore
Return all of the Playlists currently defined

Specified by:
getAllPlaylists in interface TrackStore
Returns:
A Collection of Playlist objects currently known by the TrackStore

getBatchTrackLoader

public BatchTrackLoader getBatchTrackLoader()
Return a batch track loader

Specified by:
getBatchTrackLoader in interface TrackStore
Returns:
A BatchTrackLoader from this TrackStore