org.musicontroller.dao
Interface Dao

All Superinterfaces:
UserDao
All Known Implementing Classes:
HibernateDao

public interface Dao
extends UserDao


Method Summary
 int count(java.lang.String hql, java.util.Map<java.lang.String,java.lang.Object> params)
           
 void deleteAiBag(AIBag delete)
          Deletes an AIBag.
 void deleteArtist(Artist delete)
          Deletes an artist.
 void evict(java.lang.Object o)
           
 void evictSong(long songid)
           
 IUser findUserByName(java.lang.String username)
          Searches for a User, and returns if, if found.
 AIBag getAIBagById(long id)
          Retrieves the ai_bag with the given id from the database.
 AIBag getArtistAppearances(long artistid)
          Return a list of all appearances of an artist in songs.
 Artist getArtistById(long id)
          Retrieves the artist with the given id from the database.
 Band getBandById(long id)
          Retrieves the band with the given id from the database.
 Band getBandByName(java.lang.String name)
          Retrieves the band with the given name from the database.
 java.util.List<java.lang.Long[]> getDoubleSongs()
          Searches the database for songs that are stored more than one time in the database.
 Instrument getInstrumentById(long id)
          Retrieves the instrument with the given id from the database.
 Keywordbag getKeywordBagById(long id)
          Retrieves the keyword bag with the given id from the database.
 Keyword getKeywordById(long id)
          Retrieves the keyword with the given id from the database.
 Keywordbag getKeywordsBag(java.util.Collection<Keyword> keywords)
           
 AIBag getMostUsedAIBag(Band band)
          Searches the database for the most used AIBag for this band.
 Playlist getNeighbours(long songid, IUser user)
          Returns a Playlist containing Songs that are neighbours of the given Song and User.
 Playlist getPlaylistById(long playlistid, IUser user)
          Returns a specific Playlist
 Playlist getPlaylistByName(java.lang.String name)
          Retrieves the Playlist with the given name from the database.
 org.hibernate.SessionFactory getSessionFactory2()
          Returns the SessionFactory.
 Song getSong(Band band, java.lang.String songname)
          Find a song with the given name performed by the specified band.
 Song getSongById(long id)
          Retrieves the song with the given id from the database.
 java.util.List<java.lang.Long> getSongIds()
           
 java.util.List<Song> getSongsById(java.util.Collection<java.lang.Long> ids)
          Retrieves a number of songs from the database, corresponding with the given Ids.
 org.springframework.orm.hibernate3.HibernateTemplate getSupport()
           
 java.util.List<AIBag> listAIBags()
          Returns a list of all Artist-Instrument bags.
 java.util.List<java.lang.Object[]> listBands(IUser user)
           
 java.util.List<Keywordbag> listKeywordbags()
          Returns a list of all Keyword bags.
 java.util.List<Keyword> listKeywords()
          Lists all known Keywords.
 java.util.List<java.lang.Object[]> listKeywords(IUser user, java.util.List<Keywordbag> bags)
           
 java.util.List<Keywordbag> listKeywordsBags(java.util.List<Keyword> keywords)
          Returns a list with all keyword bags that contain at least all keywords given in the "keywords" parameter.
 java.util.List<java.lang.Object[]> listMonthlySongCounts()
           
 java.util.Map<java.lang.String,java.lang.Integer> listMonthlyStatistics(IUser user)
          Returns per-user play-statistics.
 java.util.List<java.lang.Object[]> listNamableItems()
           
 java.util.List<Playlist> listPlaylists()
          Lists all Playlists.
 java.util.List<Playlist> listPlaylists(Band band)
          Lists all playlists on which a band is present.
 java.util.List<Playlist> listPlaylists(Song song)
           
 java.util.List<Playlist> listPodcasts()
          Lists all Playlists that contain Podcasts.
 void mergeBands(Band keep, Band remove)
          Merge two bands, moving all songs from one to the other.
 void mergePlaylists(Playlist keep, Playlist delete)
          Merge the two playlists into one.
 void mergeSongs(Song keep, Song remove)
          Merges two songs to one.
 void registerSongChangeListener(SongChangeListener listener)
          Adds a SongChangeListener to the internal list of listeners.
 void save(AIBag aibag)
          Persist the properties of this AIBag.
 void save(Artist artist)
          Persist the properties of this artist.
 void save(Band band)
          Persist the properties of this band.
 void save(Instrument instr)
          Persist the properties of this Instrument.
 void save(Keyword keyword)
          Persist the properties of this keyword.
 void save(Keywordbag keywordbag)
          Persist a keyword bag.
 void save(Link link)
          Persist the properties of this link.
 void save(Playlist playlist)
          Persist the properties of this playlist.
 void save(Song song)
          Persist the properties of this song.
 java.util.List search(java.lang.String hql, java.util.Map<java.lang.String,java.lang.Object> params, int maxResults)
          Searches in the Database, and returns the objects that were selected.
 java.util.List search(java.lang.String hql, java.util.Map<java.lang.String,java.lang.Object> params, int maxResults, int offset)
          Searches in the Database, and returns the objects that were selected.
 Artist searchArtist(java.lang.String artistfirstname, java.lang.String artistlastname)
          Find an artist matching the given first and last name.
 Band searchBand(java.lang.String bandname)
          Locate and load the band with the given name.
 Instrument searchInstrument(java.lang.String instrname)
          Returns the instrument with the given instrument name or NULL if there is no instrument with the given name.
 Keyword searchKeyword(java.lang.String keyworddesc)
          Find a keyword matching the given keyword-string.
 java.util.List<Playlist> searchPlaylist(java.lang.String playlistname)
          Find a playlist matching the given name.
 Playlist songsByBand(long bandid)
           
 Playlist songsByKeyword(long keywordid)
           
 Playlist songsByKeywordbags(java.util.List<Keywordbag> bags, IUser user, int maxResults)
          Generates a Playlist containing songs that belong to the specified Keywordbags.
 Playlist songsByKeywordIds(java.util.List<java.lang.Long> keywordIds, IUser user)
           
 Playlist songsByKeywords(java.util.List<Keyword> keywords, IUser user)
           
 
Methods inherited from interface org.musicontroller.security.UserDao
delete, findUserByLoginname, findUserByNamePassword, getUserById, getUserByLoginname, listRoles, listUsers, save
 

Method Detail

getSongIds

java.util.List<java.lang.Long> getSongIds()

getSongById

Song getSongById(long id)
Retrieves the song with the given id from the database.

Parameters:
id - The song id.
Returns:
The song with the given identifier.

getSongsById

java.util.List<Song> getSongsById(java.util.Collection<java.lang.Long> ids)
Retrieves a number of songs from the database, corresponding with the given Ids.

Parameters:
ids - The ids to get. This must not be null.
Returns:
A List of Song-objects

getBandById

Band getBandById(long id)
Retrieves the band with the given id from the database.

Parameters:
id - The band id.
Returns:
The band with the given identifier.

getBandByName

Band getBandByName(java.lang.String name)
Retrieves the band with the given name from the database. If there ares more than one Band with this name, the result is the Band that has been in the Database longest.

Parameters:
name - The band name.
Returns:
The band with the given name.

getKeywordById

Keyword getKeywordById(long id)
Retrieves the keyword with the given id from the database.

Parameters:
id - The keyword id.
Returns:
The keyword with the given identifier.

getKeywordBagById

Keywordbag getKeywordBagById(long id)
Retrieves the keyword bag with the given id from the database.

Parameters:
id - The keyword bag id.
Returns:
The keyword bagwith the given identifier.

getArtistById

Artist getArtistById(long id)
Retrieves the artist with the given id from the database.

Parameters:
id - The artist id.
Returns:
The artist with the given identifier.

getAIBagById

AIBag getAIBagById(long id)
Retrieves the ai_bag with the given id from the database.

Parameters:
id - The ai_bag id.
Returns:
The ai_bag with the given identifier.

getInstrumentById

Instrument getInstrumentById(long id)
Retrieves the instrument with the given id from the database.

Parameters:
id - The instrument id.
Returns:
The instrument with the given identifier.

getPlaylistById

Playlist getPlaylistById(long playlistid,
                         IUser user)
Returns a specific Playlist

Parameters:
playlistid - The requested playlist id.
user - The user to use for retrieving "special" playlists.
Returns:
The Playlist, or null if a Playlist with the given id doesn't exist.

getPlaylistByName

Playlist getPlaylistByName(java.lang.String name)
Retrieves the Playlist with the given name from the database. If there are more than one Playlists with this name, the result is the Playlist that has been in the Database longest.

Parameters:
name - The playlist name.
Returns:
The Playlist with the given name.

songsByBand

Playlist songsByBand(long bandid)

songsByKeyword

Playlist songsByKeyword(long keywordid)

songsByKeywordbags

Playlist songsByKeywordbags(java.util.List<Keywordbag> bags,
                            IUser user,
                            int maxResults)
Generates a Playlist containing songs that belong to the specified Keywordbags. The songs in the Playlist are ordered by the amount of play-events of the specified User during the last year.

Parameters:
bags - The Keywordbag(s) the Song could be in. If this parameter is null, an empty Playlist is returned.
user - The User-object (Used for sorting according to listening-habits). If this parameter is null, anonymous sorting is used.
maxResults - Specifiec the maximum amount of records to return. Pass a value >0 to show all matches.
Returns:
A Playlist consisting of Songs that matched any of the given Keywordbags.

songsByKeywords

Playlist songsByKeywords(java.util.List<Keyword> keywords,
                         IUser user)

songsByKeywordIds

Playlist songsByKeywordIds(java.util.List<java.lang.Long> keywordIds,
                           IUser user)

getNeighbours

Playlist getNeighbours(long songid,
                       IUser user)
Returns a Playlist containing Songs that are neighbours of the given Song and User. Neighbours are Songs that are played or requested at least five times 10 minutes before or after this song was played or requested. The resulting Playlist is sorted by the amount of 'together-played'-hits.

Parameters:
songid - The Song to get the neighbours for.
user - The User for whom to inspect the played and requested-Events
Returns:
A Playlist, containing the Neighbouring Songs.

getDoubleSongs

java.util.List<java.lang.Long[]> getDoubleSongs()
Searches the database for songs that are stored more than one time in the database.

Returns:
A List of Long-pairs with songIDs.

mergeSongs

void mergeSongs(Song keep,
                Song remove)
Merges two songs to one. All events, occurences on playlists, etc. will be merged.

Parameters:
keep - This song stays.
remove - This song will be removed.

search

java.util.List search(java.lang.String hql,
                      java.util.Map<java.lang.String,java.lang.Object> params,
                      int maxResults)
Searches in the Database, and returns the objects that were selected.

Parameters:
hql - The HQL-query.
params - Query parameters as name,value pairs
maxResults - The maximum amount of objects to return. Use 0 for all results.
Returns:
The objects that fit to the search-query.

search

java.util.List search(java.lang.String hql,
                      java.util.Map<java.lang.String,java.lang.Object> params,
                      int maxResults,
                      int offset)
Searches in the Database, and returns the objects that were selected.

Parameters:
hql - The HQL-query.
params - Query parameters as name,value pairs
maxResults - The maximum amount of objects to return. Use 0 for all results.
offset - The first offset objects will not be returned
Returns:
The objects that fit to the search-query.

searchBand

Band searchBand(java.lang.String bandname)
Locate and load the band with the given name. Returns NULL if there is no band with the given name. If there are more bands with this name this method returns one of them.

Parameters:
bandname - The band name.
Returns:
The band with the given name.

mergeBands

void mergeBands(Band keep,
                Band remove)
Merge two bands, moving all songs from one to the other. The artists relations of the removed band are lost.

Parameters:
keep - Keep this band. Add all songs of the other band to this band.
remove - The band to remove, moving all songs to the other band.

searchKeyword

Keyword searchKeyword(java.lang.String keyworddesc)
Find a keyword matching the given keyword-string.

Parameters:
keyworddesc - The desired keyword string.
Returns:
A keyword with the desired text or null if it does not exist.

searchPlaylist

java.util.List<Playlist> searchPlaylist(java.lang.String playlistname)
Find a playlist matching the given name. The search is case sensitive. Returns an empty list if the playlist name parameter is null or if no playlist with that name exists.

Parameters:
playlistname - The desired playlist name.
Returns:
A playlist with the desired name or null if it does not exist.

searchArtist

Artist searchArtist(java.lang.String artistfirstname,
                    java.lang.String artistlastname)
Find an artist matching the given first and last name.

Parameters:
artistfirstname - The desired artist name. May be null.
artistlastname - The desired artist last name. The result is null if this is null.
Returns:
An artist with the desired name or null if it does not exist.

getArtistAppearances

AIBag getArtistAppearances(long artistid)
Return a list of all appearances of an artist in songs.

Parameters:
artistid - The artist to search.
Returns:

save

void save(Band band)
Persist the properties of this band.

Parameters:
band - The band to persist.

save

void save(Keyword keyword)
Persist the properties of this keyword.

Parameters:
keyword - The keyword to persist.

save

void save(Keywordbag keywordbag)
Persist a keyword bag.

Parameters:
keywordbag - The keyword bag to persist.

save

void save(Playlist playlist)
Persist the properties of this playlist.

Parameters:
playlist - The playlist to persist.

save

void save(Link link)
Persist the properties of this link.

Parameters:
link - The link to persist.

save

void save(Song song)
Persist the properties of this song.

Parameters:
song - The song to persist.

save

void save(Artist artist)
Persist the properties of this artist.

Parameters:
artist - The artist to persist.

save

void save(Instrument instr)
Persist the properties of this Instrument.

Parameters:
instr - The instrument to persist.

save

void save(AIBag aibag)
Persist the properties of this AIBag.

Parameters:
aibag - The AIBag to persist.

getSong

Song getSong(Band band,
             java.lang.String songname)
Find a song with the given name performed by the specified band. If there is more than 1 song matching the name and band, this method returns one of them. Returns if a matching song does not exist.

Parameters:
band - The band
songname - The song name.
Returns:
A song matching the band and song name, or NULL if there is no such song.

findUserByName

IUser findUserByName(java.lang.String username)
Searches for a User, and returns if, if found.

Parameters:
username - The username to search for
Returns:
The User, or null if no User with a matching name could be found

listPlaylists

java.util.List<Playlist> listPlaylists(Band band)
Lists all playlists on which a band is present.

Parameters:
band - The Band to search Playlists for.
Returns:
A list of Playlists on which songs exist of the Band

listPlaylists

java.util.List<Playlist> listPlaylists(Song song)

listPlaylists

java.util.List<Playlist> listPlaylists()
Lists all Playlists.

Returns:
All Playlists.

listPodcasts

java.util.List<Playlist> listPodcasts()
Lists all Playlists that contain Podcasts.

Returns:
All Playlists that contain Podcasts.

evictSong

void evictSong(long songid)

evict

void evict(java.lang.Object o)

listBands

java.util.List<java.lang.Object[]> listBands(IUser user)
Parameters:
user - The User to get this list for.
Returns:
Returns a list of String-arrays. The first element of the array is the bandId. The second element is the bandname, the third element is the amount of play-events for that band for the given User during the last year, the fourth element en the amount of skip-events for that band during the last year.

listKeywords

java.util.List<Keyword> listKeywords()
Lists all known Keywords.

Returns:
All Keywords in no particular order.

listKeywords

java.util.List<java.lang.Object[]> listKeywords(IUser user,
                                                java.util.List<Keywordbag> bags)
Parameters:
user - The User to get this list for.
bags - The Keywordbags to show Keywords of (or null to show all keywords)
Returns:
Returns a list of String-arrays. The first element of the array is the keywordId. The second element is the keywordname, the third element is the amount of play-events for that keyword for the given User during the last year, the fourth element is the amount of skip-events for that keyword during the last year. If the bags parameter is non-null, then only keywords occurring in the ketword bags in bags are included.

listKeywordsBags

java.util.List<Keywordbag> listKeywordsBags(java.util.List<Keyword> keywords)
Returns a list with all keyword bags that contain at least all keywords given in the "keywords" parameter.

Parameters:
keywords - The list of keywords that hava to be present in each keyword bag in the result. If this parameter is null or empty, the result is null.
Returns:
A list of Keywordbags containing all keywords given.

getKeywordsBag

Keywordbag getKeywordsBag(java.util.Collection<Keyword> keywords)
Parameters:
keywords -
Returns:
A list of Keywordbags containing exactly all keywords given, no more, no less.

listMonthlySongCounts

java.util.List<java.lang.Object[]> listMonthlySongCounts()
Returns:
Returns a list of String-arrays. The first element of the array is the month, the second element is the year and the third element is the amount of songs that were added to the database in that month.

listMonthlyStatistics

java.util.Map<java.lang.String,java.lang.Integer> listMonthlyStatistics(IUser user)
Returns per-user play-statistics. This method queries the database, and returns a Map containing String -> Integer relations. These releations are constructed as follows: "yyyy,mm,k" -> x where mm is the month, yyyy is the year, k is the eventkind and x is the amount of such events

Parameters:
user - The user to gather these statistics for.
Returns:
The Map as stated above. The order of the keys in the returned map is guaranteed to be alphabetical.
See Also:
Event

listNamableItems

java.util.List<java.lang.Object[]> listNamableItems()
Returns:
Returns a list of Object-arrays. The first element of the array is the name (String) of a namable item. The second is the id (Long). Namable items are all items in the database that both have a name and an id. (Bands, Artists, Playlists, Songs, Instruments, Keywords)

listKeywordbags

java.util.List<Keywordbag> listKeywordbags()
Returns a list of all Keyword bags.

Returns:
A list of all keyword bags.

searchInstrument

Instrument searchInstrument(java.lang.String instrname)
Returns the instrument with the given instrument name or NULL if there is no instrument with the given name.

Parameters:
instrname - The intsrument name.
Returns:
The instrument with the given name.

count

int count(java.lang.String hql,
          java.util.Map<java.lang.String,java.lang.Object> params)
          throws java.lang.Exception
Throws:
java.lang.Exception

getMostUsedAIBag

AIBag getMostUsedAIBag(Band band)
Searches the database for the most used AIBag for this band. This comes in handy when a user needs to have a hint for which artists and instruments to choose for a new song.

Parameters:
band - The Band
Returns:
A suggestion for a AIBag for a new song of this band.

listAIBags

java.util.List<AIBag> listAIBags()
Returns a list of all Artist-Instrument bags.

Returns:
A list of all Artist-Instrument bags.

mergePlaylists

void mergePlaylists(Playlist keep,
                    Playlist delete)
Merge the two playlists into one. There is no effect if one or both of the arguments are null.

Parameters:
keep - This playlist will receive all songs from the other playlist.
delete - This The songs of this playlist will be moved to the other playlist and this playlist will be deleted.

deleteArtist

void deleteArtist(Artist delete)
Deletes an artist. Nothing happens if the 'delete' argument is null.

Parameters:
delete - The artist to delete.

deleteAiBag

void deleteAiBag(AIBag delete)
Deletes an AIBag. Nothing happens if the 'delete' argument is null.

Parameters:
delete - The AIBag to delete.

getSessionFactory2

org.hibernate.SessionFactory getSessionFactory2()
Returns the SessionFactory.

Returns:
The SessionFactory.

registerSongChangeListener

void registerSongChangeListener(SongChangeListener listener)
Adds a SongChangeListener to the internal list of listeners. The listener will be informed about all Song-changes that happen after registration.

Parameters:
listener - The SongChangeListener to register.

getSupport

org.springframework.orm.hibernate3.HibernateTemplate getSupport()


Copyright © 2010 A.J.V.. All Rights Reserved.