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 int
TIMEOUT_IN_SECONDS_10
static int
TIMEOUT_IN_SECONDS_1000
static int
TIMEOUT_IN_SECONDS_10000
static int
TIMEOUT_IN_SECONDS_100000
static int
TIMEOUT_IN_SECONDS_180
static int
TIMEOUT_IN_SECONDS_30
static int
TIMEOUT_IN_SECONDS_60
static int
TIMEOUT_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 void
addPlayListDataListener(ListDataListener l)
void
addPlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener)
Lets you register a listener that receives events when a playlist property is changed.void
addPlayListPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
Lets you register a listener that receives events when a playlist property is changed.<T> T
callOnDefaultJob(Callable<T> callable, long timeoutInSeconds, T onErrorValue)
Executes the givenCallable
in the default job queue.<T> T
callOnDefaultJob(Callable<T> callable, T onErrorValue)
Executes the givenCallable
in the default job queue.<T> T
callOnDefaultJobWithException(Callable<T> callable, long timeoutInSeconds, RuntimeException rte)
Executes the givenCallable
in the default job queue.<T> T
callOnDefaultJobWithException(Callable<T> callable, RuntimeException rte)
Executes the givenCallable
in the default job queue.int
countSongs()
Number of songs in the library.int
countSongsWithPropertyValue(String propertyName, Object propertyValue)
Count all songs with a propertyequal
to the given value.int
countUnprotectedSongsAddedAfter(Date time)
Counts unprotected songs added after a certain date.PlayList
createFolder()
Creates a new folder under the Music playlist/folder.PlayList
createFolder(Long parentId)
Creates a new folder at a specific location.PlayList
createPlayList(Long id, Long parentId, String name, boolean folder)
Creates a newPlayList
object with the given name and id.PlayList
createPlayList(Long parentId, String name)
Creates a new PlayList at a specific location.PlayList
createPlayList(String name)
Creates a new PlayList under the Music playlist/folder.void
deleteAllFingerprints()
Delete all fingerprints from the database to save disk space.void
deletePlayList(long id)
Deletes a playlist from the library.AudioSong
fetchCollections(AudioSong audioSong)
Loads dependent collections that otherwise wouldn't have been loaded.static void
fetchLazyAssociations(List<Song> songs)
void
flushPendingWrites()
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.Album
getAlbum(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.Version
getApplicationVersion()
Returns the iTunes application version as specified in the iTunes Music Library.xml.File
getDatabaseDir()
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()
HibernateUtil
getHibernateUtil()
String
getId()
Unique id for each instance of this object.PlayList
getLibrary()
Returns the master playlist that contains all library objects.LibraryLoader
getLibraryLoader()
Long
getPersistentId()
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.TagCollection
getPopularTagCollection(int numberOfTags)
Returns theTagCollection
for the X most common tags.static String
getSchemaVersion()
Collection<Set<Long>>
getSimilarTitles()
Returns a collection of id sets that point to songs with similar or identical titles.Song
getSong(Long id)
Gets a Song, given its id (Song.getId()
.Song
getSong(org.hibernate.Session session, Long playlistId, Long id)
List<Long>
getSongIds()
Returns anIterable
that 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 propertypropertyName
for songs withrestrictionPropertyName
equalingrestrictionPropertyValue
.<T> List<T>
getSongPropertyValues(String propertyName, List<T> valueList)
All possible values for a given property.Iterable<AudioSong>
getSongs(Collection<Long> ids)
Returns anIterable
that 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 propertiesequal
to 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)
TagCollection
getTagCollection()
Returns theTagCollection
for the entire library.int
getTimeoutFactor()
List<AudioSong>
getUnprotectedSongsAddedAfter(Date time)
Return unprotected songs added after a certain date.void
init()
Initializes this component and its sub-components.boolean
isCoalesceWrites()
protected boolean
isProgressDialogVisible(boolean firstTime, boolean manuallyInitiated)
void
openDatabase()
Opens the underlying database that has the descriptor set withsetLibraryDescriptor(LibraryDescriptor)
.void
removePlayListDataListener(ListDataListener l)
void
removePlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener)
void
removePlayListPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
static void
runOnDefaultJob(Callable<?> callable)
Executes the givenCallable
in the default job queue.void
setApplicationVersion(Version applicationVersion)
void
setCoalesceWrites(boolean coalesceWrites)
void
setLibraryDescriptor(LibraryDescriptor libraryDescriptor)
Sets the library descriptor.void
setPlayLists(List<PlayList> playLists)
void
setTimeoutFactor(int timeoutFactor)
void
shutdown()
Shuts down this component and its sub-components.void
store(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.void
store(PlayList playList)
Stores a playlist in the beaTunes database.void
store(MatchListInfo matchListInfo)
Store the given info.void
store(Iterable<AudioSong> songs)
Stores a collection of songs in the beaTunes database.void
updateGenreIRI(AudioSong song)
void
updateSelectivity()
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:ApplicationComponent
Unique 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:MediaLibrary
Initializes this component and its sub-components.
-
shutdown
public void shutdown()
Description copied from interface:MediaLibrary
Shuts 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:MediaLibrary
Sets the library descriptor.- Specified by:
setLibraryDescriptor
in interfaceMediaLibrary
- Overrides:
setLibraryDescriptor
in 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:
isProgressDialogVisible
in classAbstractMediaLibrary<A extends ApplicationComponent>
-
createPlayList
public PlayList createPlayList(Long parentId, String name)
Description copied from interface:MediaLibrary
Creates 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:MediaLibrary
Creates 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:MediaLibrary
Creates 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:MediaLibrary
Creates 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:MediaLibrary
Creates a newPlayList
object 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:MediaLibrary
Returns 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:MediaLibrary
Returns the iTunes library persistent id as specified in theiTunes Music Library.xml
.- Returns:
- persistent library id as long
-
getLibraryLoader
public LibraryLoader getLibraryLoader()
- Specified by:
getLibraryLoader
in classAbstractMediaLibrary<A extends ApplicationComponent>
-
countSongs
public int countSongs()
Description copied from interface:MediaLibrary
Number of songs in the library.- Returns:
- number of songs in the library.
-
getSong
public Song getSong(Long id)
Description copied from interface:MediaLibrary
Gets 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:MediaLibrary
Returns theTagCollection
for 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:MediaLibrary
Returns theTagCollection
for 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:MediaLibrary
Gets all property values of propertypropertyName
for songs withrestrictionPropertyName
equalingrestrictionPropertyValue
.- 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:MediaLibrary
Returns 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:MediaLibrary
Returns 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:MediaLibrary
Returns 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:MediaLibrary
Returns 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:MediaLibrary
Returns 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:MediaLibrary
Returns 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:MediaLibrary
Returns 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:MediaLibrary
All 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:MediaLibrary
All 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:MediaLibrary
Count all songs with a propertyequal
to 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:MediaLibrary
Get 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:MediaLibrary
Get all songs without propertiesequal
to 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:MediaLibrary
Get all song ids for songs that match all given properties. All key value pairs are implicitly connected using theAND
operator.- 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:MediaLibrary
Get all song ids for songs that match none of the given properties. All key value pairs are implicitly connected using theAND
operator.- 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:MediaLibrary
Get 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:MediaLibrary
Get 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:MediaLibrary
Get 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:MediaLibrary
Returns 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:MediaLibrary
Returns 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:MediaLibrary
Returns 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:MediaLibrary
Returns anIterable
that 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:MediaLibrary
Returns anIterable
that 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:MediaLibrary
Returns 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:MediaLibrary
List of all playlists.- Returns:
- list of all playlists in the library
-
getAlbum
public Album getAlbum(Album.Key key)
Description copied from interface:MediaLibrary
Returns 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:MediaLibrary
Counts unprotected songs added after a certain date.- Parameters:
time
- time- Returns:
- count
-
getUnprotectedSongsAddedAfter
public List<AudioSong> getUnprotectedSongsAddedAfter(Date time)
Description copied from interface:MediaLibrary
Return 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:MediaLibrary
Stores a playlist in the beaTunes database.- Parameters:
playList
- playlist to save
-
store
public void store(AudioSong song, String changedProperty)
Description copied from interface:MediaLibrary
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.
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 InterruptedException
Description copied from interface:MediaLibrary
Flush any pending writes (blocks until all writes happened).- Throws:
InterruptedException
-
store
public void store(Iterable<AudioSong> songs)
Description copied from interface:MediaLibrary
Stores 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:MediaLibrary
Deletes a playlist from the library.- Parameters:
id
- id
-
store
public void store(MatchListInfo matchListInfo)
Description copied from interface:MediaLibrary
Store 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:MediaLibrary
Lets 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:MediaLibrary
Lets 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 givenCallable
in 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
onErrorValue
in case of an exception
-
callOnDefaultJob
public <T> T callOnDefaultJob(Callable<T> callable, long timeoutInSeconds, T onErrorValue)
Executes the givenCallable
in 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
onErrorValue
in case of an exception
-
callOnDefaultJobWithException
public <T> T callOnDefaultJobWithException(Callable<T> callable, RuntimeException rte)
Executes the givenCallable
in 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 givenCallable
in 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 givenCallable
in the default job queue.- Parameters:
callable
- callable
-
deleteAllFingerprints
public void deleteAllFingerprints()
Description copied from interface:MediaLibrary
Delete all fingerprints from the database to save disk space.
-
-