|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.cutunes.server.DatabaseController
Contains all logic for connecting/querying/updating the top40db database. Written as a Java singleton so only a single database connection can be opened by an application at any given time.
Methods mainly called through the RequestHandler in response to XML-RPC messages. A couple methods, updateTop40Caches() and updatePlayCountWeek() are called by cron jobs on a regular basis.
Method Summary | |
void |
bulkLoadHasSongData(int userID,
java.lang.String hasSongsFile)
Uses MySQL's load data function to bulk load a file full of information into the has_songs table. |
void |
bulkLoadSongData(int userID,
java.lang.String songsFile)
Uses MySQL's load data function to bulk load a file full of information into the songs table. |
static DatabaseController |
getInstance()
Java singleton getInstance() method. |
java.sql.Timestamp |
getLastSync(int userID,
java.lang.String version)
Queries database to get the last time a user synced. |
int |
getUserID(java.lang.String user,
java.lang.String password)
Queries database with username and password to find the unique ID for a given user. |
void |
logMessage(boolean error,
java.lang.String function,
java.lang.String message)
Logs messages into the message_logs table of the database. |
static void |
main(java.lang.String[] args)
Simple main method used for testing the database controller. |
void |
setLastSync(int userID,
java.lang.String version)
Sets the last sync time for a user to the current time in UTC, and logs the sync in the sync_logs table. |
void |
updateHasSong(int userID,
java.util.Date lastSyncDate,
java.util.Vector songGroup)
Method updates the playcount/last_played information in the has_song table for a given user. |
void |
updatePlayCountWeek()
Automatically 'decays' the play_count_week field for all rows in the has_songs table. |
void |
updateTop40Caches()
Caches the Top40 artists, albums, songs (both week and all-time views) in extra table in the database (called top_songs, top_artists, etc). |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static DatabaseController getInstance()
public void logMessage(boolean error, java.lang.String function, java.lang.String message)
error
- Boolean error is true is message is an error, false if just
a friendly messagefunction
- String describing method/function issuing messagemessage
- String with message to be loggedpublic int getUserID(java.lang.String user, java.lang.String password)
user
- String usernamepassword
- String password
public java.sql.Timestamp getLastSync(int userID, java.lang.String version)
userID
- Unique ID identifying userversion
- String version of client used
public void setLastSync(int userID, java.lang.String version)
userID
- Unique ID identifying userversion
- String version of client softwarepublic void updateHasSong(int userID, java.util.Date lastSyncDate, java.util.Vector songGroup)
Three steps are involved in updated this information:
We have attempted to optimize this method so it runs as fast as possible, and prepared statements are used to keep things quick
userID
- Unique ID identifying userlastSyncDate
- Timestamp of user's last syncsongGroup
- Vector of songs to update has_song information forpublic void bulkLoadSongData(int userID, java.lang.String songsFile)
userID
- Unique ID identifying usersongsFile
- String with path to file to bulk loadpublic void bulkLoadHasSongData(int userID, java.lang.String hasSongsFile)
userID
- Unique ID identifying userhasSongsFile
- String with path to file to bulk loadpublic void updateTop40Caches()
public void updatePlayCountWeek()
public static void main(java.lang.String[] args)
args
- No command line args are needed.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |