Package com.tagtraum.beatunes.library
Class HibernateMediaLibrary<A extends ApplicationComponent>
- java.lang.Object
-
- com.tagtraum.beatunes.library.AbstractMediaLibrary<A>
-
- com.tagtraum.beatunes.library.HibernateMediaLibrary<A>
-
- All Implemented Interfaces:
MediaLibrary,ApplicationComponent<A>
public class HibernateMediaLibrary<A extends ApplicationComponent> extends AbstractMediaLibrary<A>
Hibernate-based music library.- Author:
- Hendrik Schreiber
-
-
Field Summary
Fields Modifier and Type Field Description static intTIMEOUT_IN_SECONDS_10static intTIMEOUT_IN_SECONDS_1000static intTIMEOUT_IN_SECONDS_10000static intTIMEOUT_IN_SECONDS_100000static intTIMEOUT_IN_SECONDS_180static intTIMEOUT_IN_SECONDS_30static intTIMEOUT_IN_SECONDS_60static intTIMEOUT_IN_SECONDS_600-
Fields inherited from class com.tagtraum.beatunes.library.AbstractMediaLibrary
AUTO_DETECT_ITUNESLIBRARY, databaseDir, propertyChangeSupport, TEN_MINUTES, TOTALTIME_DEVIATION, wrappingProxy
-
-
Constructor Summary
Constructors Constructor Description HibernateMediaLibrary(A application)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPlayListDataListener(ListDataListener l)voidaddPlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener)Lets you register a listener that receives events when a playlist property is changed.voidaddPlayListPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)Lets you register a listener that receives events when a playlist property is changed.<T> TcallOnDefaultJob(Callable<T> callable, long timeoutInSeconds, T onErrorValue)Executes the givenCallablein the default job queue.<T> TcallOnDefaultJob(Callable<T> callable, T onErrorValue)Executes the givenCallablein the default job queue.<T> TcallOnDefaultJobWithException(Callable<T> callable, long timeoutInSeconds, RuntimeException rte)Executes the givenCallablein the default job queue.<T> TcallOnDefaultJobWithException(Callable<T> callable, RuntimeException rte)Executes the givenCallablein the default job queue.intcountSongs()Number of songs in the library.intcountSongsWithPropertyValue(String propertyName, Object propertyValue)Count all songs with a propertyequalto the given value.intcountUnprotectedSongsAddedAfter(Date time)Counts unprotected songs added after a certain date.PlayListcreateFolder()Creates a new folder under the Music playlist/folder.PlayListcreateFolder(Long parentId)Creates a new folder at a specific location.PlayListcreatePlayList(Long id, Long parentId, String name, boolean folder)Creates a newPlayListobject with the given name and id.PlayListcreatePlayList(Long parentId, String name)Creates a new PlayList at a specific location.PlayListcreatePlayList(String name)Creates a new PlayList under the Music playlist/folder.voiddeleteAllFingerprints()Delete all fingerprints from the database to save disk space.voiddeletePlayList(long id)Deletes a playlist from the library.AudioSongfetchCollections(AudioSong audioSong)Loads dependent collections that otherwise wouldn't have been loaded.static voidfetchLazyAssociations(List<Song> songs)voidflushPendingWrites()Flush any pending writes (blocks until all writes happened).Set<Set<Long>>getAcousticallyIdenticalSongIds()Returns a collection of sets that each contain song ids of acoustically "identical" songs.Set<Set<Long>>getAcousticallyIdenticalSongIds(int maxSubprintMatchAttempts)Returns a collection of sets that each contain song ids of acoustically "identical" songs.Set<Set<Long>>getAcousticallyIdenticalSongIds(Set<Long> ids)Returns a collection of sets that each contain song ids of acoustically "identical" songs.Set<Set<Long>>getAcousticallyIdenticalSongIds(Set<Long> ids, int maxSubprintMatchAttempts)Returns a collection of sets that each contain song ids of acoustically "identical" songs.AlbumgetAlbum(Album.Key key)Returns an album.Set<Album.Key>getAlbumKeys()Returns the set of all valid album keys.List<Long>getAlbumSongIds(String album, String artist)Returns a list of song ids for songs specified by the given album and artist.List<AudioSong>getAlbumSongs(String album, String artist)Returns a list of songs specified by the given album and artist.VersiongetApplicationVersion()Returns the iTunes application version as specified in the iTunes Music Library.xml.FilegetDatabaseDir()List<String>getDuplicateTitles()Returns a list of titles that have exact duplicates.List<String>getDuplicateTrackIds()Returns a list of track ids that correspond to more than one song.List<String>getGenres()HibernateUtilgetHibernateUtil()StringgetId()Unique id for each instance of this object.PlayListgetLibrary()Returns the master playlist that contains all library objects.LibraryLoadergetLibraryLoader()LonggetPersistentId()Returns the iTunes library persistent id as specified in theiTunes Music Library.xml.PropertyChangeListener[]getPlayListPropertyChangeListeners()PropertyChangeListener[]getPlayListPropertyChangeListeners(String property)List<PlayList>getPlayLists()List of all playlists.TagCollectiongetPopularTagCollection(int numberOfTags)Returns theTagCollectionfor the X most common tags.static StringgetSchemaVersion()Collection<Set<Long>>getSimilarTitles()Returns a collection of id sets that point to songs with similar or identical titles.SonggetSong(Long id)Gets a Song, given its id (Song.getId().SonggetSong(org.hibernate.Session session, Long playlistId, Long id)List<Long>getSongIds()Returns anIterablethat can be used to iterate over all song ids.List<Long>getSongIdsWithoutProperties(Map<String,Object> properties)Get all song ids for songs that match none of the given properties.List<Long>getSongIdsWithProperties(Map<String,Object> properties)Get all song ids for songs that match all given properties.List<Long>getSongIdsWithPropertiesILike(Map<String,Object> properties)Get all song ids of songs with a properties that are ilike the given properties (case-insensitive).List<Long>getSongIdsWithPropertiesLike(Map<String,Object> properties)Get all song ids of songs with a properties that are like the given properties.<T> List<T>getSongPropertyValues(String propertyName)All possible values for a given property.<T> List<T>getSongPropertyValues(String propertyName, String restrictionPropertyName, Object restrictionPropertyValue)Gets all property values of propertypropertyNamefor songs withrestrictionPropertyNameequalingrestrictionPropertyValue.<T> List<T>getSongPropertyValues(String propertyName, List<T> valueList)All possible values for a given property.Iterable<AudioSong>getSongs(Collection<Long> ids)Returns anIterablethat can be used to iterate over the specified songs.List<Song>getSongs(org.hibernate.Session session, Long playlistId, Long... ids)List<AudioSong>getSongsWithFileAndSize(String filename, int size)List<AudioSong>getSongsWithNameArtistAlbumTotalTime(String name, String artist, String album, int time)List<AudioSong>getSongsWithoutProperties(Map<String,Object> properties)Get all songs without propertiesequalto the given value.List<AudioSong>getSongsWithProperties(Map<String,Object> properties)Get all song ids for songs that match all given properties.List<AudioSong>getSongsWithPropertiesLike(Map<String,Object> properties)Get all songs with a properties that are like the given properties.Set<AudioSong>getSongsWithTrackIdTotalTime(Set<AudioId> ids, int time)TagCollectiongetTagCollection()Returns theTagCollectionfor the entire library.intgetTimeoutFactor()List<AudioSong>getUnprotectedSongsAddedAfter(Date time)Return unprotected songs added after a certain date.voidinit()Initializes this component and its sub-components.booleanisCoalesceWrites()protected booleanisProgressDialogVisible(boolean firstTime, boolean manuallyInitiated)voidopenDatabase()Opens the underlying database that has the descriptor set withsetLibraryDescriptor(LibraryDescriptor).voidremovePlayListDataListener(ListDataListener l)voidremovePlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener)voidremovePlayListPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)static voidrunOnDefaultJob(Callable<?> callable)Executes the givenCallablein the default job queue.voidsetApplicationVersion(Version applicationVersion)voidsetCoalesceWrites(boolean coalesceWrites)voidsetLibraryDescriptor(LibraryDescriptor libraryDescriptor)Sets the library descriptor.voidsetPlayLists(List<PlayList> playLists)voidsetTimeoutFactor(int timeoutFactor)voidshutdown()Shuts down this component and its sub-components.voidstore(AudioSong song, String changedProperty)Stores a song in the beaTunes database and clears any sortorder caches in the playlist objects this song might be in, if the playlist is sorted by the changed property.voidstore(PlayList playList)Stores a playlist in the beaTunes database.voidstore(MatchListInfo matchListInfo)Store the given info.voidstore(Iterable<AudioSong> songs)Stores a collection of songs in the beaTunes database.voidupdateGenreIRI(AudioSong song)voidupdateSelectivity()Update the selectivity for columns, so that the query plan cost optimizer can work as well as possible.-
Methods inherited from class com.tagtraum.beatunes.library.AbstractMediaLibrary
addMediaLibraryListener, addPropertyChangeListener, addPropertyChangeListener, cancelSynchronization, fireAsynchronousSynchronizationEvent, fireLibrarySynchronizedEvent, fireSynchronousSynchronizationEvent, getApplication, getAudioMetaDataExecutor, getGenreIRILookupService, getImplementation, getLastSynchronizationTimestamp, getLibraryDescriptor, getLock, getPlayList, getPreviousToLastSynchronizationTimestamp, getPropertyChangeListeners, getPropertyChangeListeners, getSongIds, getSongs, getSongsOrderedBy, getSongsOrderedBy, getTunes, getTunesExecutor, getUIDelegate, getWrappingProxy, getWrappingProxyFactory, isEmbedAudioMetaData, isForceAudioMetaDataWrites, isForceRecovery, isNewDatabase, isOneWeekOld, isRebuildPlayLists, isSupportedPlayList, isSynchronizing, lock, needsRefresh, refresh, refresh, refreshOnNextUpdate, removeMediaLibraryListener, removePropertyChangeListener, removePropertyChangeListener, serialExecute, serialExecute, setApplication, setDatabaseDir, setEmbedAudioMetaData, setForceAudioMetaDataWrites, setGenreIRILookupService, setNewDatabase, setRebuildPlayLists, setRecoveryFlag, setRecoveryFlag, setUIDelegate, smuggle, store
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.tagtraum.beatunes.library.MediaLibrary
getSongsOrderedBy
-
-
-
-
Field Detail
-
TIMEOUT_IN_SECONDS_10
public static final int TIMEOUT_IN_SECONDS_10
- See Also:
- Constant Field Values
-
TIMEOUT_IN_SECONDS_30
public static final int TIMEOUT_IN_SECONDS_30
- See Also:
- Constant Field Values
-
TIMEOUT_IN_SECONDS_60
public static final int TIMEOUT_IN_SECONDS_60
- See Also:
- Constant Field Values
-
TIMEOUT_IN_SECONDS_180
public static final int TIMEOUT_IN_SECONDS_180
- See Also:
- Constant Field Values
-
TIMEOUT_IN_SECONDS_600
public static final int TIMEOUT_IN_SECONDS_600
- See Also:
- Constant Field Values
-
TIMEOUT_IN_SECONDS_1000
public static final int TIMEOUT_IN_SECONDS_1000
- See Also:
- Constant Field Values
-
TIMEOUT_IN_SECONDS_10000
public static final int TIMEOUT_IN_SECONDS_10000
- See Also:
- Constant Field Values
-
TIMEOUT_IN_SECONDS_100000
public static final int TIMEOUT_IN_SECONDS_100000
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HibernateMediaLibrary
public HibernateMediaLibrary(A application)
-
-
Method Detail
-
getId
public String getId()
Description copied from interface:ApplicationComponentUnique id for each instance of this object.- Returns:
- id
-
getTimeoutFactor
public int getTimeoutFactor()
-
setTimeoutFactor
public void setTimeoutFactor(int timeoutFactor)
-
getSchemaVersion
public static String getSchemaVersion()
-
getHibernateUtil
public HibernateUtil getHibernateUtil()
-
getDatabaseDir
public File getDatabaseDir()
-
init
public void init()
Description copied from interface:MediaLibraryInitializes this component and its sub-components.
-
shutdown
public void shutdown()
Description copied from interface:MediaLibraryShuts down this component and its sub-components.
-
isCoalesceWrites
public boolean isCoalesceWrites()
-
setCoalesceWrites
public void setCoalesceWrites(boolean coalesceWrites)
-
setLibraryDescriptor
public void setLibraryDescriptor(LibraryDescriptor libraryDescriptor)
Description copied from interface:MediaLibrarySets the library descriptor.- Specified by:
setLibraryDescriptorin interfaceMediaLibrary- Overrides:
setLibraryDescriptorin classAbstractMediaLibrary<A extends ApplicationComponent>- Parameters:
libraryDescriptor- library descriptor
-
openDatabase
public void openDatabase()
Opens the underlying database that has the descriptor set withsetLibraryDescriptor(LibraryDescriptor). Nothing should really happen, if the database with the same id is already open.
-
isProgressDialogVisible
protected boolean isProgressDialogVisible(boolean firstTime, boolean manuallyInitiated)- Specified by:
isProgressDialogVisiblein classAbstractMediaLibrary<A extends ApplicationComponent>
-
createPlayList
public PlayList createPlayList(Long parentId, String name)
Description copied from interface:MediaLibraryCreates a new PlayList at a specific location.- Parameters:
parentId- persistent id of the parent, i.e. the location of the playlist to newly createname- name- Returns:
- new playlist object.
-
createPlayList
public PlayList createPlayList(String name)
Description copied from interface:MediaLibraryCreates a new PlayList under the Music playlist/folder.- Parameters:
name- name- Returns:
- new playlist object.
-
createFolder
public PlayList createFolder(Long parentId)
Description copied from interface:MediaLibraryCreates a new folder at a specific location.- Parameters:
parentId- persistent id of the parent, i.e. the location of the folder to newly create- Returns:
- new folder object.
-
createFolder
public PlayList createFolder()
Description copied from interface:MediaLibraryCreates a new folder under the Music playlist/folder.- Returns:
- new folder object.
-
createPlayList
public PlayList createPlayList(Long id, Long parentId, String name, boolean folder)
Description copied from interface:MediaLibraryCreates a newPlayListobject with the given name and id.- Parameters:
id- persistentIdparentId- parent playlist persistent id - may benull, if there is no parentname- namefolder- is folder- Returns:
- a new persistent playlist
-
getApplicationVersion
public Version getApplicationVersion()
Description copied from interface:MediaLibraryReturns the iTunes application version as specified in the iTunes Music Library.xml.- Returns:
- iTunes application version
-
setApplicationVersion
public void setApplicationVersion(Version applicationVersion)
-
getPersistentId
public Long getPersistentId()
Description copied from interface:MediaLibraryReturns the iTunes library persistent id as specified in theiTunes Music Library.xml.- Returns:
- persistent library id as long
-
getLibraryLoader
public LibraryLoader getLibraryLoader()
- Specified by:
getLibraryLoaderin classAbstractMediaLibrary<A extends ApplicationComponent>
-
countSongs
public int countSongs()
Description copied from interface:MediaLibraryNumber of songs in the library.- Returns:
- number of songs in the library.
-
getSong
public Song getSong(Long id)
Description copied from interface:MediaLibraryGets a Song, given its id (Song.getId().- Parameters:
id- id- Returns:
- song or
null, if not found
-
fetchCollections
public AudioSong fetchCollections(AudioSong audioSong)
Loads dependent collections that otherwise wouldn't have been loaded. Default impl. does nothing.- Parameters:
audioSong- song to 'complete'- Returns:
- song complete with associated collections
-
getPopularTagCollection
public TagCollection getPopularTagCollection(int numberOfTags)
Description copied from interface:MediaLibraryReturns theTagCollectionfor the X most common tags.- Parameters:
numberOfTags- max number of tags to return- Returns:
- tag collection for strongest tags in the library
-
getTagCollection
public TagCollection getTagCollection()
Description copied from interface:MediaLibraryReturns theTagCollectionfor the entire library.- Returns:
- tag collection for the library
-
getSongPropertyValues
public <T> List<T> getSongPropertyValues(String propertyName, String restrictionPropertyName, Object restrictionPropertyValue)
Description copied from interface:MediaLibraryGets all property values of propertypropertyNamefor songs withrestrictionPropertyNameequalingrestrictionPropertyValue.- Parameters:
propertyName- properties whose values are going to be returnedrestrictionPropertyName- property that is used to select the return setrestrictionPropertyValue- property value that is used to select the return set- Returns:
- values of propertyName
-
getSimilarTitles
public Collection<Set<Long>> getSimilarTitles()
Description copied from interface:MediaLibraryReturns a collection of id sets that point to songs with similar or identical titles.- Returns:
- collection of id sets
- See Also:
MediaLibrary.getDuplicateTitles()
-
getDuplicateTitles
public List<String> getDuplicateTitles()
Description copied from interface:MediaLibraryReturns a list of titles that have exact duplicates.- Returns:
- list of duplicate titles
- See Also:
MediaLibrary.getSimilarTitles()
-
getDuplicateTrackIds
public List<String> getDuplicateTrackIds()
Description copied from interface:MediaLibraryReturns a list of track ids that correspond to more than one song.- Returns:
- list of duplicate ids
- See Also:
MediaLibrary.getSimilarTitles()
-
getAcousticallyIdenticalSongIds
public Set<Set<Long>> getAcousticallyIdenticalSongIds()
Description copied from interface:MediaLibraryReturns a collection of sets that each contain song ids of acoustically "identical" songs. Only songs that have fingerprints (seeAudioSong.setFingerprint(byte[])) can be found. Because of scalability issues, please useMediaLibrary.getAcousticallyIdenticalSongIds(Set).- Returns:
- set of id sets
- See Also:
MediaLibrary.getAcousticallyIdenticalSongIds(Set)
-
getAcousticallyIdenticalSongIds
public Set<Set<Long>> getAcousticallyIdenticalSongIds(Set<Long> ids)
Description copied from interface:MediaLibraryReturns a collection of sets that each contain song ids of acoustically "identical" songs. Only songs that have fingerprints (seeAudioSong.setFingerprint(byte[])) can be found.- Parameters:
ids- ids of the the songs to find duplicates for- Returns:
- set of id sets
- See Also:
MediaLibrary.getAcousticallyIdenticalSongIds(Set, int)
-
getAcousticallyIdenticalSongIds
public Set<Set<Long>> getAcousticallyIdenticalSongIds(Set<Long> ids, int maxSubprintMatchAttempts)
Description copied from interface:MediaLibraryReturns a collection of sets that each contain song ids of acoustically "identical" songs. Only songs that have fingerprints (seeAudioSong.setFingerprint(byte[])) can be found.- Parameters:
ids- ids of the the songs to find duplicates formaxSubprintMatchAttempts- maximum number of attempts to match a subprint. Negative values cause an exhaustive search (longer runtime). The default value used inMediaLibrary.getAcousticallyIdenticalSongIds()is15.- Returns:
- set of id sets
- See Also:
MediaLibrary.getAcousticallyIdenticalSongIds()
-
getAcousticallyIdenticalSongIds
public Set<Set<Long>> getAcousticallyIdenticalSongIds(int maxSubprintMatchAttempts)
Description copied from interface:MediaLibraryReturns a collection of sets that each contain song ids of acoustically "identical" songs. Only songs that have fingerprints (seeAudioSong.setFingerprint(byte[])) can be found. Because of scalability issues, please useMediaLibrary.getAcousticallyIdenticalSongIds(Set, int).- Parameters:
maxSubprintMatchAttempts- maximum number of attempts to match a subprint. Negative values cause an exhaustive search (longer runtime). The default value used inMediaLibrary.getAcousticallyIdenticalSongIds()is15.- Returns:
- set of id sets
- See Also:
MediaLibrary.getAcousticallyIdenticalSongIds(Set, int)
-
getSongPropertyValues
public <T> List<T> getSongPropertyValues(String propertyName)
Description copied from interface:MediaLibraryAll possible values for a given property.- Parameters:
propertyName- property- Returns:
- values for a given property
-
getSongPropertyValues
public <T> List<T> getSongPropertyValues(String propertyName, List<T> valueList)
Description copied from interface:MediaLibraryAll possible values for a given property.- Parameters:
propertyName- propertyvalueList- list that this method will add the results to. Before the results are added, the list is cleared.- Returns:
- values for a given property
-
countSongsWithPropertyValue
public int countSongsWithPropertyValue(String propertyName, Object propertyValue)
Description copied from interface:MediaLibraryCount all songs with a propertyequalto the given value.- Parameters:
propertyName- name of a propertypropertyValue- value of a property- Returns:
- list of songs whose property has the required value
-
getSongsWithProperties
public List<AudioSong> getSongsWithProperties(Map<String,Object> properties)
Description copied from interface:MediaLibraryGet all song ids for songs that match all given properties.- Parameters:
properties- name-value pairs- Returns:
- list of songs whose properties have the required values
-
getSongsWithoutProperties
public List<AudioSong> getSongsWithoutProperties(Map<String,Object> properties)
Description copied from interface:MediaLibraryGet all songs without propertiesequalto the given value.- Parameters:
properties- name-value pairs- Returns:
- list of song whose properties do not the given values
-
getSongIdsWithProperties
public List<Long> getSongIdsWithProperties(Map<String,Object> properties)
Description copied from interface:MediaLibraryGet all song ids for songs that match all given properties. All key value pairs are implicitly connected using theANDoperator.- Parameters:
properties- name-value pairs- Returns:
- list of song ids whose properties have the required value
-
getSongIdsWithoutProperties
public List<Long> getSongIdsWithoutProperties(Map<String,Object> properties)
Description copied from interface:MediaLibraryGet all song ids for songs that match none of the given properties. All key value pairs are implicitly connected using theANDoperator.- Parameters:
properties- name-value pairs- Returns:
- list of song ids whose properties have the required value
-
getSongsWithPropertiesLike
public List<AudioSong> getSongsWithPropertiesLike(Map<String,Object> properties)
Description copied from interface:MediaLibraryGet all songs with a properties that are like the given properties.- Parameters:
properties- name-value pairs- Returns:
- list of songs whose string property contains the given value
-
getSongIdsWithPropertiesLike
public List<Long> getSongIdsWithPropertiesLike(Map<String,Object> properties)
Description copied from interface:MediaLibraryGet all song ids of songs with a properties that are like the given properties.- Parameters:
properties- name-value pairs- Returns:
- list of song ids whose string property contains the given value
-
getSongIdsWithPropertiesILike
public List<Long> getSongIdsWithPropertiesILike(Map<String,Object> properties)
Description copied from interface:MediaLibraryGet all song ids of songs with a properties that are ilike the given properties (case-insensitive).- Parameters:
properties- name-value pairs- Returns:
- list of song ids whose string property contains the given value
-
getAlbumSongIds
public List<Long> getAlbumSongIds(String album, String artist)
Description copied from interface:MediaLibraryReturns a list of song ids for songs specified by the given album and artist. At least on of the two parameters must be a non-empty string. The lookup is case-sensitive. To find valid album/artist combinations, checkMediaLibrary.getAlbumKeys().- Parameters:
album- albumartist- artist or album artist- Returns:
- list of ids
- See Also:
MediaLibrary.getAlbumSongs(String, String),MediaLibrary.getAlbumKeys()
-
getAlbumSongs
public List<AudioSong> getAlbumSongs(String album, String artist)
Description copied from interface:MediaLibraryReturns a list of songs specified by the given album and artist. At least one of the two parameters must be a non-empty string. The lookup is case-sensitive. To find valid album/artist combinations, checkMediaLibrary.getAlbumKeys().- Parameters:
album- albumartist- artist or album artist- Returns:
- list of songs
- See Also:
MediaLibrary.getAlbumSongIds(String, String),MediaLibrary.getAlbumKeys()
-
getAlbumKeys
public Set<Album.Key> getAlbumKeys()
Description copied from interface:MediaLibraryReturns the set of all valid album keys. To qualify for the set, both an album and either an artist or an album artist must be set.- Returns:
- album keys
-
getSongs
public Iterable<AudioSong> getSongs(Collection<Long> ids)
Description copied from interface:MediaLibraryReturns anIterablethat can be used to iterate over the specified songs.- Parameters:
ids- collection of ids- Returns:
- an object from which one can get an iterator
-
getSongIds
public List<Long> getSongIds()
Description copied from interface:MediaLibraryReturns anIterablethat can be used to iterate over all song ids.- Returns:
- an object from which one can get an iterator
-
getLibrary
public PlayList getLibrary()
Description copied from interface:MediaLibraryReturns the master playlist that contains all library objects. This may also be unexpected objects like apps. For just Music objects, get the playlist with kindPlayList.Kind.MUSIC(testable viaPlayList.getDistinguishedKind()).- Returns:
- master playlist
-
getPlayLists
public List<PlayList> getPlayLists()
Description copied from interface:MediaLibraryList of all playlists.- Returns:
- list of all playlists in the library
-
getAlbum
public Album getAlbum(Album.Key key)
Description copied from interface:MediaLibraryReturns an album. The songs contained in this album are not properly wrapped. Writing to them most likely does not work as expected.- Parameters:
key- album key, interpreted case-insensitively- Returns:
- album
- See Also:
MediaLibrary.getAlbumSongs(String, String)
-
getSongsWithNameArtistAlbumTotalTime
public List<AudioSong> getSongsWithNameArtistAlbumTotalTime(String name, String artist, String album, int time)
-
getSongsWithTrackIdTotalTime
public Set<AudioSong> getSongsWithTrackIdTotalTime(Set<AudioId> ids, int time)
-
countUnprotectedSongsAddedAfter
public int countUnprotectedSongsAddedAfter(Date time)
Description copied from interface:MediaLibraryCounts unprotected songs added after a certain date.- Parameters:
time- time- Returns:
- count
-
getUnprotectedSongsAddedAfter
public List<AudioSong> getUnprotectedSongsAddedAfter(Date time)
Description copied from interface:MediaLibraryReturn unprotected songs added after a certain date.- Parameters:
time- time- Returns:
- songs, at most 1000.
-
store
public void store(PlayList playList)
Description copied from interface:MediaLibraryStores a playlist in the beaTunes database.- Parameters:
playList- playlist to save
-
store
public void store(AudioSong song, String changedProperty)
Description copied from interface:MediaLibraryStores a song in the beaTunes database and clears any sortorder caches in the playlist objects this song might be in, if the playlist is sorted by the changed property.
The write-process is asynchronous, i.e. this method may return before the songs has actually been written.
- Parameters:
song- song to savechangedProperty- property that has been changed (may be null, if multiple properties have changed or the change is unknown)
-
updateGenreIRI
public void updateGenreIRI(AudioSong song)
-
flushPendingWrites
public void flushPendingWrites() throws InterruptedExceptionDescription copied from interface:MediaLibraryFlush any pending writes (blocks until all writes happened).- Throws:
InterruptedException
-
store
public void store(Iterable<AudioSong> songs)
Description copied from interface:MediaLibraryStores a collection of songs in the beaTunes database.
The write-process is asynchronous, i.e. this method may return before the songs has actually been written.
- Parameters:
songs- songs to save
-
deletePlayList
public void deletePlayList(long id)
Description copied from interface:MediaLibraryDeletes a playlist from the library.- Parameters:
id- id
-
store
public void store(MatchListInfo matchListInfo)
Description copied from interface:MediaLibraryStore the given info.- Parameters:
matchListInfo- match list info
-
updateSelectivity
public void updateSelectivity()
Update the selectivity for columns, so that the query plan cost optimizer can work as well as possible.
-
addPlayListPropertyChangeListener
public void addPlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener)
Description copied from interface:MediaLibraryLets you register a listener that receives events when a playlist property is changed. Unlike listeners bound to individual, transient playlist objects, this registration is permanent as long as this library is available.- Parameters:
propertyChangeListener- listener
-
addPlayListPropertyChangeListener
public void addPlayListPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
Description copied from interface:MediaLibraryLets you register a listener that receives events when a playlist property is changed. Unlike listeners bound to individual, transient playlist objects, this registration is permanent as long as this library is available.- Parameters:
property- propertypropertyChangeListener- listener
-
removePlayListPropertyChangeListener
public void removePlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener)
-
removePlayListPropertyChangeListener
public void removePlayListPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
-
getPlayListPropertyChangeListeners
public PropertyChangeListener[] getPlayListPropertyChangeListeners()
-
getPlayListPropertyChangeListeners
public PropertyChangeListener[] getPlayListPropertyChangeListeners(String property)
-
addPlayListDataListener
public void addPlayListDataListener(ListDataListener l)
-
removePlayListDataListener
public void removePlayListDataListener(ListDataListener l)
-
callOnDefaultJob
public <T> T callOnDefaultJob(Callable<T> callable, T onErrorValue)
Executes the givenCallablein the default job queue. All exceptions are caught. Blocks indefinitely.- Type Parameters:
T- type of return value- Parameters:
callable- callableonErrorValue- value to return in case an exception occurs. All exceptions are caught.- Returns:
- return value, may be
onErrorValuein case of an exception
-
callOnDefaultJob
public <T> T callOnDefaultJob(Callable<T> callable, long timeoutInSeconds, T onErrorValue)
Executes the givenCallablein the default job queue. All exceptions are caught.- Type Parameters:
T- type of return value- Parameters:
callable- callabletimeoutInSeconds- timeout, negative values are interpreted as infinite timeoutonErrorValue- value to return in case an exception occurs. All exceptions are caught.- Returns:
- return value, may be
onErrorValuein case of an exception
-
callOnDefaultJobWithException
public <T> T callOnDefaultJobWithException(Callable<T> callable, RuntimeException rte)
Executes the givenCallablein the default job queue. Blocks indefinitely.- Type Parameters:
T- type of return value- Parameters:
callable- callablerte- exception to throw, in case we encounter an exception that is not aRuntimeException- Returns:
- return value
-
callOnDefaultJobWithException
public <T> T callOnDefaultJobWithException(Callable<T> callable, long timeoutInSeconds, RuntimeException rte)
Executes the givenCallablein the default job queue.- Type Parameters:
T- type of return value- Parameters:
callable- callabletimeoutInSeconds- timeout, negative values are interpreted as infinite timeoutrte- exception to throw, in case we encounter an exception that is not aRuntimeException- Returns:
- return value
-
runOnDefaultJob
public static void runOnDefaultJob(Callable<?> callable)
Executes the givenCallablein the default job queue.- Parameters:
callable- callable
-
deleteAllFingerprints
public void deleteAllFingerprints()
Description copied from interface:MediaLibraryDelete all fingerprints from the database to save disk space.
-
-