public class HibernateMusicLibrary<A extends ApplicationComponent> extends AbstractMusicLibrary<A>
AUTO_DETECT_ITUNESLIBRARY, databaseDir, propertyChangeSupport, TEN_MINUTES, TOTALTIME_DEVIATION, wrappingProxy
Constructor and Description |
---|
HibernateMusicLibrary(A application) |
Modifier and Type | Method and 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.
|
static <T> T |
callOnDefaultJob(Callable<T> callable,
long timeoutInSeconds,
T onErrorValue)
Executes the given
Callable in the default job queue. |
static <T> T |
callOnDefaultJobWithException(Callable<T> callable,
long timeoutInSeconds,
RuntimeException rte)
Executes the given
Callable in the default job queue. |
static <T> T |
callOnLIFOJob(Callable<T> callable,
long timeoutInSeconds,
T onErrorValue)
Executes the given
Callable in the LIFO job queue. |
int |
countSongs()
Number of songs in the library.
|
int |
countSongsWithPropertyValue(String propertyName,
Object propertyValue)
Count all songs with a property
equal to the given value. |
int |
countUnprotectedSongsAddedAfter(Date time) |
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 new
PlayList 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 |
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.
|
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.
|
Set<Album.Key> |
getAllTimesFavoriteAlbums(int max) |
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() |
HibernateMusicLibraryDelegate |
getHibernateMusicLibraryDelegate() |
HibernateUtil |
getHibernateUtil() |
Set<Album.Key> |
getHighlyRatedAlbums(int max) |
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 the
iTunes Music Library.xml . |
PropertyChangeListener[] |
getPlayListPropertyChangeListeners() |
PropertyChangeListener[] |
getPlayListPropertyChangeListeners(String property) |
List<PlayList> |
getPlayLists()
List of all playlists.
|
TagCollection |
getPopularTagCollection(int numberOfTags)
Returns the
TagCollection for the X most common tags. |
Set<Album.Key> |
getRecentlyAddedAlbums(int max) |
Set<Album.Key> |
getRecentlyPlayedAlbums(int max) |
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 an
Iterable that can be used to iterate over all song ids. |
List<Long> |
getSongIdsWithoutPropertyValue(String propertyName,
Object propertyValue)
Get all song ids of songs with a property
equal the given value. |
List<Long> |
getSongIdsWithPropertyLikeValue(String propertyName,
String propertyValue)
Get all song ids of songs with a property
like the given value. |
List<Long> |
getSongIdsWithPropertyValue(String propertyName,
Object propertyValue)
Get all song ids for songs with a property
equal to the given value. |
<T> List<T> |
getSongPropertyValues(String propertyName)
All possible values for a given property.
|
<T> List<T> |
getSongPropertyValues(String propertyName,
List<T> valueList)
All possible values for a given property.
|
<T> List<T> |
getSongPropertyValues(String propertyName,
String restrictionPropertyName,
Object restrictionPropertyValue)
Gets all property values of property
propertyName for songs with
restrictionPropertyName equaling restrictionPropertyValue . |
Iterable<AudioSong> |
getSongs(Collection<Long> ids)
Returns an
Iterable 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> |
getSongsWithoutPropertyValue(String propertyName,
Object propertyValue)
Get all songs with a property
not equal to the given value. |
List<AudioSong> |
getSongsWithPropertyLikeValue(String propertyName,
String propertyValue)
Get all songs with a property
like the given value. |
List<AudioSong> |
getSongsWithPropertyValue(String propertyName,
Object propertyValue)
Get all songs with a property
equal to the given value. |
Set<AudioSong> |
getSongsWithTrackIdTotalTime(Set<AudioId> ids,
int time) |
TagCollection |
getTagCollection()
Returns the
TagCollection for the entire library. |
List<AudioSong> |
getUnprotectedSongsAddedAfter(Date time) |
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 with
AbstractMusicLibrary.setLibraryDescriptor(LibraryDescriptor) . |
void |
removePlayListDataListener(ListDataListener l) |
void |
removePlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener) |
void |
removePlayListPropertyChangeListener(String property,
PropertyChangeListener propertyChangeListener) |
static void |
runOnDefaultJob(Callable<?> callable)
Executes the given
Callable in the default job queue. |
void |
setApplicationVersion(Version applicationVersion) |
void |
setCoalesceWrites(boolean coalesceWrites) |
void |
setHibernateMusicLibraryDelegate(HibernateMusicLibraryDelegate hibernateMusicLibraryDelegate) |
void |
setHibernateUtil(HibernateUtil hibernateUtil) |
void |
setPlayLists(List<PlayList> playLists) |
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(Iterable<AudioSong> songs)
Stores a collection of songs in the beaTunes database.
|
void |
store(MatchListInfo matchListInfo)
Store the given info.
|
void |
store(PlayList playList)
Stores a playlist in the beaTunes database.
|
void |
updateSelectivity()
Update the selectivity for columns, so that the query plan cost optimizer can work
as well as possible.
|
addITunesMusicLibraryListener, addPropertyChangeListener, addPropertyChangeListener, fireAsynchronousSynchronizationEvent, fireLibrarySynchronizedEvent, fireSynchronousSynchronizationEvent, getApplication, getAudioMetaDataExecutor, getImplementation, getLastSynchronizationTimestamp, getLibraryDescriptor, getLock, getPlayList, getPreviousToLastSynchronizationTimestamp, getPropertyChangeListeners, getPropertyChangeListeners, getSongIds, getSongs, getTunes, getTunesExecutor, getUIDelegate, getWrappingProxy, getWrappingProxyFactory, isEmbedAudioMetaData, isNewDatabase, isOneWeekOld, isRebuildPlayLists, isSynchronizing, lock, needsRefresh, refresh, refresh, refreshOnNextUpdate, removePropertyChangeListener, removePropertyChangeListener, serialExecute, serialExecute, setApplication, setDatabaseDir, setEmbedAudioMetaData, setLibraryDescriptor, setNewDatabase, setRebuildPlayLists, setUIDelegate, smuggle, store
public HibernateMusicLibrary(A application)
public String getId()
ApplicationComponent
public HibernateMusicLibraryDelegate getHibernateMusicLibraryDelegate()
public void setHibernateMusicLibraryDelegate(HibernateMusicLibraryDelegate hibernateMusicLibraryDelegate)
public static String getSchemaVersion()
public HibernateUtil getHibernateUtil()
public void setHibernateUtil(HibernateUtil hibernateUtil)
public File getDatabaseDir()
public void init()
ITunesMusicLibrary
public void shutdown()
ITunesMusicLibrary
public boolean isCoalesceWrites()
public void setCoalesceWrites(boolean coalesceWrites)
public void openDatabase()
AbstractMusicLibrary.setLibraryDescriptor(LibraryDescriptor)
.
Nothing should really happen, if the database with the same id is already open.protected boolean isProgressDialogVisible(boolean firstTime, boolean manuallyInitiated)
isProgressDialogVisible
in class AbstractMusicLibrary<A extends ApplicationComponent>
public PlayList createPlayList(Long parentId, String name)
ITunesMusicLibrary
parentId
- persistent id of the parent, i.e. the location of the playlist to newly createname
- namepublic PlayList createPlayList(String name)
ITunesMusicLibrary
name
- namepublic PlayList createFolder(Long parentId)
ITunesMusicLibrary
parentId
- persistent id of the parent, i.e. the location of the folder to newly createpublic PlayList createFolder()
ITunesMusicLibrary
public PlayList createPlayList(Long id, Long parentId, String name, boolean folder)
ITunesMusicLibrary
PlayList
object with the given name and id.id
- persistentIdparentId
- parent playlist persistent id - may be null
, if there is no parentname
- namefolder
- is folderpublic Version getApplicationVersion()
ITunesMusicLibrary
public void setApplicationVersion(Version applicationVersion)
public Long getPersistentId()
ITunesMusicLibrary
iTunes Music Library.xml
.public LibraryLoader getLibraryLoader()
getLibraryLoader
in class AbstractMusicLibrary<A extends ApplicationComponent>
public int countSongs()
ITunesMusicLibrary
public Song getSong(Long id)
ITunesMusicLibrary
Song.getId()
.id
- idnull
, if not foundpublic AudioSong fetchCollections(AudioSong audioSong)
audioSong
- song to 'complete'public TagCollection getPopularTagCollection(int numberOfTags)
ITunesMusicLibrary
TagCollection
for the X most common tags.numberOfTags
- max number of tags to returnpublic TagCollection getTagCollection()
ITunesMusicLibrary
TagCollection
for the entire library.public <T> List<T> getSongPropertyValues(String propertyName, String restrictionPropertyName, Object restrictionPropertyValue)
ITunesMusicLibrary
propertyName
for songs with
restrictionPropertyName
equaling restrictionPropertyValue
.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 setpublic Collection<Set<Long>> getSimilarTitles()
ITunesMusicLibrary
ITunesMusicLibrary.getDuplicateTitles()
public List<String> getDuplicateTitles()
ITunesMusicLibrary
ITunesMusicLibrary.getSimilarTitles()
public List<String> getDuplicateTrackIds()
ITunesMusicLibrary
ITunesMusicLibrary.getSimilarTitles()
public Set<Set<Long>> getAcousticallyIdenticalSongIds()
ITunesMusicLibrary
AudioSong.setFingerprint(byte[])
) can be found.ITunesMusicLibrary.getAcousticallyIdenticalSongIds(int)
public Set<Set<Long>> getAcousticallyIdenticalSongIds(int maxSubprintMatchAttempts)
ITunesMusicLibrary
AudioSong.setFingerprint(byte[])
) can be found.maxSubprintMatchAttempts
- maximum number of attempts to match a subprint.
Negative values cause an exhaustive search (longer runtime).
The default value used in ITunesMusicLibrary.getAcousticallyIdenticalSongIds()
is 15
.ITunesMusicLibrary.getAcousticallyIdenticalSongIds()
public <T> List<T> getSongPropertyValues(String propertyName)
ITunesMusicLibrary
propertyName
- propertypublic <T> List<T> getSongPropertyValues(String propertyName, List<T> valueList)
ITunesMusicLibrary
propertyName
- propertyvalueList
- list that this method will add the results to.
Before the results are added, the list is cleared.public int countSongsWithPropertyValue(String propertyName, Object propertyValue)
ITunesMusicLibrary
equal
to the given value.propertyName
- name of a propertypropertyValue
- value of a propertypublic List<AudioSong> getSongsWithPropertyValue(String propertyName, Object propertyValue)
ITunesMusicLibrary
equal
to the given value.propertyName
- name of a propertypropertyValue
- value of a propertypublic List<AudioSong> getSongsWithoutPropertyValue(String propertyName, Object propertyValue)
ITunesMusicLibrary
not equal
to the given value.propertyName
- name of a propertypropertyValue
- value of a propertyITunesMusicLibrary.getSongIdsWithoutPropertyValue(String, Object)
public List<Long> getSongIdsWithPropertyValue(String propertyName, Object propertyValue)
ITunesMusicLibrary
equal
to the given value.propertyName
- name of a propertypropertyValue
- value of a propertypublic List<Long> getSongIdsWithoutPropertyValue(String propertyName, Object propertyValue)
ITunesMusicLibrary
equal
the given value.propertyName
- name of a propertypropertyValue
- value of a propertyITunesMusicLibrary.getSongsWithoutPropertyValue(String, Object)
public List<AudioSong> getSongsWithPropertyLikeValue(String propertyName, String propertyValue)
ITunesMusicLibrary
like
the given value.propertyName
- name of a propertypropertyValue
- value of a string propertyITunesMusicLibrary.getSongIdsWithPropertyLikeValue(String, String)
public List<Long> getSongIdsWithPropertyLikeValue(String propertyName, String propertyValue)
ITunesMusicLibrary
like
the given value.propertyName
- name of a propertypropertyValue
- value of a string propertyITunesMusicLibrary.getSongsWithPropertyLikeValue(String, String)
public List<Long> getAlbumSongIds(String album, String artist)
ITunesMusicLibrary
ITunesMusicLibrary.getAlbumKeys()
.album
- albumartist
- artist or album artistITunesMusicLibrary.getAlbumSongs(String, String)
,
ITunesMusicLibrary.getAlbumKeys()
public List<AudioSong> getAlbumSongs(String album, String artist)
ITunesMusicLibrary
ITunesMusicLibrary.getAlbumKeys()
.album
- albumartist
- artist or album artistITunesMusicLibrary.getAlbumSongIds(String, String)
,
ITunesMusicLibrary.getAlbumKeys()
public Set<Album.Key> getAlbumKeys()
ITunesMusicLibrary
public Iterable<AudioSong> getSongs(Collection<Long> ids)
ITunesMusicLibrary
Iterable
that can be used to iterate over the specified songs.ids
- collection of idspublic List<Long> getSongIds()
ITunesMusicLibrary
Iterable
that can be used to iterate over all song ids.public PlayList getLibrary()
ITunesMusicLibrary
PlayList.Kind.MUSIC
(testable via PlayList.getDistinguishedKind()
).public List<PlayList> getPlayLists()
ITunesMusicLibrary
public Album getAlbum(Album.Key key)
ITunesMusicLibrary
key
- album key, interpreted case-insensitivelyITunesMusicLibrary.getAlbumSongs(String, String)
public List<AudioSong> getSongsWithNameArtistAlbumTotalTime(String name, String artist, String album, int time)
public Set<AudioSong> getSongsWithTrackIdTotalTime(Set<AudioId> ids, int time)
public int countUnprotectedSongsAddedAfter(Date time)
public void store(PlayList playList)
ITunesMusicLibrary
playList
- playlist to savepublic void store(AudioSong song, String changedProperty)
ITunesMusicLibrary
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.
song
- song to savechangedProperty
- property that has been changed (may be null, if multiple properties have changed or the change is unknown)public void flushPendingWrites() throws InterruptedException
ITunesMusicLibrary
InterruptedException
public void store(Iterable<AudioSong> songs)
ITunesMusicLibrary
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.
songs
- songs to savepublic void deletePlayList(long id)
ITunesMusicLibrary
id
- idpublic void store(MatchListInfo matchListInfo)
ITunesMusicLibrary
matchListInfo
- match list infopublic void updateSelectivity()
public void addPlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener)
ITunesMusicLibrary
propertyChangeListener
- listenerpublic void addPlayListPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
ITunesMusicLibrary
property
- propertypropertyChangeListener
- listenerpublic void removePlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener)
public void removePlayListPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
public PropertyChangeListener[] getPlayListPropertyChangeListeners()
public PropertyChangeListener[] getPlayListPropertyChangeListeners(String property)
public void addPlayListDataListener(ListDataListener l)
public void removePlayListDataListener(ListDataListener l)
public static <T> T callOnLIFOJob(Callable<T> callable, long timeoutInSeconds, T onErrorValue)
Callable
in the LIFO job queue. All exceptions are caught.T
- type of return valuecallable
- callabletimeoutInSeconds
- timeout, negative values are interpreted as infinite timeoutonErrorValue
- value to return in case an exception occurs. All exceptions are caught.onErrorValue
in case of an exceptionpublic static <T> T callOnDefaultJob(Callable<T> callable, long timeoutInSeconds, T onErrorValue)
Callable
in the default job queue. All exceptions are caught.T
- type of return valuecallable
- callabletimeoutInSeconds
- timeout, negative values are interpreted as infinite timeoutonErrorValue
- value to return in case an exception occurs. All exceptions are caught.onErrorValue
in case of an exceptionpublic static <T> T callOnDefaultJobWithException(Callable<T> callable, long timeoutInSeconds, RuntimeException rte)
Callable
in the default job queue.T
- type of return valuecallable
- callabletimeoutInSeconds
- timeout, negative values are interpreted as infinite timeoutrte
- exception to throw, in case we encounter an exception that is not a RuntimeException
Copyright © 2006–2017 tagtraum industries incorporated. All rights reserved.