Package com.tagtraum.beatunes.library
Class HibernatePlayList
- java.lang.Object
-
- com.tagtraum.beatunes.library.HibernatePlayList
-
- All Implemented Interfaces:
PlayList
,SyncTempoAware
,PageCacheDataSource<AudioSong>
,ListModel
@Entity public class HibernatePlayList extends Object implements PlayList, PageCacheDataSource<AudioSong>
Playlist backed by Hibernate.- Author:
- Hendrik Schreiber
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.tagtraum.audiokern.PlayList
PlayList.Kind, PlayList.SortDirection, PlayList.SubstringFilterProperty
-
-
Constructor Summary
Constructors Constructor Description HibernatePlayList()
No-arg constructor for Hibernate.HibernatePlayList(long id)
Convenience constructor for deletion viaSession.delete(Object)
.HibernatePlayList(HibernateMediaLibrary library)
Creates an empty playlist.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListDataListener(ListDataListener l)
void
addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
Add a listener.void
addPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
Add a listener for a specific property.void
addSongIds(int filteredIndex, List<Long> songIds)
Adds the given songs at the given (filtered) index.void
addSongIds(List<Long> songIds)
Adds the songs referenced by the given ids to this playlist.void
addSongs(int filteredIndex, String... locations)
Adds songs to the playlist using only their locations.
Depending on the library implementation, the insert index may be ignored.void
addSongs(int filteredIndex, List<AudioSong> songs)
Adds the given songs at the given (filtered) index.void
addSongs(org.hibernate.Session session, gnu.trove.TLongCollection ids)
Needs to be called from open transaction/session.boolean
canAddItem()
Indicates whether we can add items to this playlist.boolean
canInsertItem()
Indicates whether we can insert items into this playlist.void
clearCaches()
Clears all caches that holed info about song order, search results, and songs themselves.boolean
contains(Long id)
int
countSongs(Collection<? extends SongFilter> filters)
Returns song count from this playlist, filtered with the given filters.org.hibernate.Query
createPageQuery(org.hibernate.Session session)
Creates a query that selects persistent objects in the right order.boolean
equals(Object obj)
int[]
filteredIndices(int... unfilteredIndices)
Returns the filtered indices (string, order) for the given unfiltered indices.PlayListIterator<AudioSong>
filteredListIterator(int firstNextFilteredIndex)
Creates a dynamically updated iterator for this playlist.List<AudioSong>
getCachedSongs()
List<PlayList>
getChildPlayLists()
String
getDescription()
PlayList.Kind
getDistinguishedKind()
Returns the special kind of this playlist.Object
getElementAt(int index)
long
getFileSize()
Get the sum of all file sizes (with filters applied).List<Long>
getFilteredSongIds()
Returns song ids from this playlist, both sorted and filtered.Iterable<AudioSong>
getFilteredSongs()
Returns songs from this playlist, both sorted and filtered.int
getGeniusTrackID()
HibernateMediaLibrary<?>
getHibernateMediaLibrary()
HibernateUtil
getHibernateUtil()
Long
getId()
This list's id.Long
getId(AudioSong song)
Needs to be implemented to get the persistent id of the objects that are cached in this cache.Long
getIdAt(int index)
Returns id of the song at the given index, taking sorting and filtering into account.IndexedId[]
getIds(org.hibernate.Session session)
A complete list of sorted ids along with their natural indices.<T> T
getImplementation(Class<T> klass)
PlayList
objects are sometimes implemented by an object that acts as a facade to other objects.IndexedId[]
getIndexedSongIds()
A complete list of sorted ids along with their natural order indices (viaIndexedId.getIndex()
).AudioSong.Liking
getLiking()
String
getName()
Long
getParentId()
If this is a sub-folder/playlist, this returns the parent id.PlayList
getParentPlayList()
PlayList[]
getPlayListPath()
Returns path leading to this playlist and ending with it.int
getSize()
String
getSmartCriteria()
String
getSmartInfo()
AudioSong
getSong(int index)
Returns song from the given index, taking sorting and filtering into account.List<Long>
getSongIds()
Returns song ids from this playlist, neither sorted not filtered.List<Long>
getSongIds(Set<? extends SongFilter> filters)
Returns song ids from this playlist, filtered with the given filters.List<Long>
getSongIds(org.hibernate.Session session)
Iterable<AudioSong>
getSongs()
Returns songs from this playlist, neither sorted nor filtered.List<AudioSong>
getSongs(Collection<? extends SongFilter> filters, int limit)
Returns songs from this playlist, filtered with the given filters.Iterable<AudioSong>
getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction)
Returns songs from this playlist, sorted by the given property.Iterable<AudioSong>
getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction, int limit)
Returns songs from this playlist, sorted by the given property.String
getSortColumnProperty()
Returns the name of the single property the playlist is sorted by.PlayList.SortDirection
getSortDirection()
Return sort direction.String[]
getSortProperties()
Actual sort properties, used inORDER BY
HQL/SQL clauses.String
getSortProperty(int index)
Actual sort property, used inORDER BY
SQL clauses.SpecialPlayListInfo
getSpecialPlayListInfo()
Long
getSpecialPlayListInfoId()
String
getSubstringFilter()
Current substring filter.PlayList.SubstringFilterProperty
getSubstringFilterProperty()
Current property to filter.com.tagtraum.audiokern.bpm.Tempo
getSyncTempo()
When set to a non-null
value,Key
values are displayed as if the song was played back at the given tempo.long
getTotalTime()
Get time with filters applied.int
getUnfilteredSize()
Unfiltered number of songs in playlist.long
getUnfilteredTime()
Get time without any filters applied.AudioSong
getWithId(org.hibernate.Session session, Long id)
List<AudioSong>
getWithIds(org.hibernate.Session session, Long... ids)
Creates a query that selects persistent objects in the right order.int
hashCode()
int
indexOf(Long id)
Returns the first index of the given song.boolean
isAggregateDataAvailable()
Indicates whether we currently have valid aggregate (total size, duration, etc.) data.boolean
isAllItems()
boolean
isAudiobooks()
boolean
isEditable()
Is this playlist editable? Only playlists created by users are editable.boolean
isFolder()
boolean
isGeniusPlaylist()
boolean
isItemsEditable()
Are the contained items editable? E.g., items are not editable, if they are only available online, as the metadata of some stream or online database cannot be changed locally.boolean
isLibrary()
Indicates that this is a library playlist, meaning one of the top level library views (e.g.boolean
isMaster()
Indicates whether this playlist is a master playlist.boolean
isMovies()
boolean
isMusic()
boolean
isParentAFolder()
boolean
isPodcasts()
boolean
isPurchasedMusic()
boolean
isSmartPlaylist()
boolean
isSpecialPlayList()
boolean
isTvShows()
boolean
isUserPlaylist()
Indicates that the playlist is just a regular user playlist.boolean
isVideos()
iTunes 6 playlist attribute.int
moveSongs(int[] fromIndices, int toIndex)
Moves songs.void
objectsAvailable(int index0, int index1)
Notifies the data source, that the given index range has been loaded.void
refresh()
Clears the caches backing this playlist.void
refresh(String sortPropertyName)
All caches related to the given sort property are cleared.void
removeAllSongs()
Removes all songs from this playlist.void
removeAllSongs(org.hibernate.Session session)
Sets the internal persistent song array tonull
.void
removeListDataListener(ListDataListener l)
void
removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
Remove a listener.boolean
removeSongs(int... filteredIndices)
Removes the song with the given (filtered) index from the playlist.boolean
removeSongs(Collection<Long> ids, boolean completelyDeleteSong)
Removes the songs with the given ids from the list.void
setAllItems(boolean value)
void
setAudiobooks(boolean value)
void
setChangedExternally(boolean changedExternally)
Indicates that this playlist was changed by an external process.void
setChildPlayLists(List<PlayList> childPlayLists)
void
setDescription(String description)
void
setDistinguishedKind(PlayList.Kind value)
Allows setting of a special song type, likePlayList.Kind.PODCASTS
.void
setFolder(boolean value)
void
setGeniusTrackID(int value)
void
setHibernateMediaLibrary(HibernateMediaLibrary<?> hibernateMediaLibrary)
void
setId(Long value)
Sets this list's id.void
setLiking(AudioSong.Liking value)
void
setMaster(boolean value)
void
setMovies(boolean value)
void
setMusic(boolean value)
void
setName(String name)
void
setParentId(Long value)
Sets the parent id.void
setParentPlayList(PlayList value)
void
setPodcasts(boolean value)
void
setPurchasedMusic(boolean value)
void
setSize(int size)
void
setSmartCriteria(String smartCriteria)
void
setSmartInfo(String smartInfo)
void
setSongIds(List<Long> songIds)
Removes all songs from this playlist and replaces them with song connected to the given ids.void
setSongs(List<AudioSong> songs)
Removes all songs from this playlist and replaces them with the given songs.void
setSortColumnProperty(String sortColumnProperty)
Sets "visual/semantic" sort property.void
setSortDirection(PlayList.SortDirection sortDirection)
Sort direction.void
setSortProperties(String... properties)
Sets sort properties.void
setSpecialPlayListInfo(SpecialPlayListInfo value)
void
setSubstringFilter(String substring, PlayList.SubstringFilterProperty substringFilterProperty)
Sets the filter and which property to filter in one swoop.void
setSyncTempo(com.tagtraum.audiokern.bpm.Tempo syncTempo)
When set to a non-null
value,Key
values are displayed as if the song was played back at the given tempo.void
setTvShows(boolean value)
void
setVideos(boolean value)
String
toString()
int[]
unfilteredIndices(int... filteredIndices)
Returns the unfiltered indices for the given filtered (string, order) indices.void
updateCachedSong(AudioSong song)
boolean
wasChangedExternally()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.tagtraum.audiokern.PlayList
contains, getSongsOrderedBy, indexOf, removeSongs
-
-
-
-
Constructor Detail
-
HibernatePlayList
public HibernatePlayList()
No-arg constructor for Hibernate. Should not be called directly. Don't forget to also set library viasetHibernateMediaLibrary(HibernateMediaLibrary)
.
-
HibernatePlayList
public HibernatePlayList(HibernateMediaLibrary library)
Creates an empty playlist.- Parameters:
library
- HibernateMediaLibrary that created this playlist
-
HibernatePlayList
public HibernatePlayList(long id)
Convenience constructor for deletion viaSession.delete(Object)
. This will not create a universally useful instance!- Parameters:
id
- id
-
-
Method Detail
-
getImplementation
public <T> T getImplementation(Class<T> klass)
Description copied from interface:PlayList
PlayList
objects are sometimes implemented by an object that acts as a facade to other objects. For example, this could be a proxy for an AppleScript iTunes object or a persistent object that is stored in a local database via Hibernate. While normal calls to an object implementing this interface are routed according to some internal logic, using one of the actual implementation classes allows you precise control over what your call does.Note to plugin developers: It is hardly ever a good idea to exercise this control, unless you know exactly what you are doing. :-)
- Specified by:
getImplementation
in interfacePlayList
- Type Parameters:
T
- implementation class- Parameters:
klass
- class implementing PlayList- Returns:
- object of the desired type or
null
, if such an object is not available - See Also:
AudioSong.getImplementation(Class)
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
Description copied from interface:PlayList
Add a listener.- Specified by:
addPropertyChangeListener
in interfacePlayList
- Parameters:
propertyChangeListener
- listener
-
addPropertyChangeListener
public void addPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
Description copied from interface:PlayList
Add a listener for a specific property.- Specified by:
addPropertyChangeListener
in interfacePlayList
propertyChangeListener
- listener
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
Description copied from interface:PlayList
Remove a listener.- Specified by:
removePropertyChangeListener
in interfacePlayList
- Parameters:
propertyChangeListener
- listener
-
addListDataListener
public void addListDataListener(ListDataListener l)
- Specified by:
addListDataListener
in interfaceListModel
-
removeListDataListener
public void removeListDataListener(ListDataListener l)
- Specified by:
removeListDataListener
in interfaceListModel
-
wasChangedExternally
public boolean wasChangedExternally()
- See Also:
setChangedExternally(boolean)
-
setChangedExternally
public void setChangedExternally(boolean changedExternally)
Indicates that this playlist was changed by an external process. Setting this flag may causePropertyChangeEvent
s to be fired, because of the external change.- Parameters:
changedExternally
- true or false
-
getId
public Long getId(AudioSong song)
Description copied from interface:PageCacheDataSource
Needs to be implemented to get the persistent id of the objects that are cached in this cache.- Specified by:
getId
in interfacePageCacheDataSource<AudioSong>
- Parameters:
song
- some persistent object- Returns:
- persistent id
-
getWithId
public AudioSong getWithId(org.hibernate.Session session, Long id)
- Specified by:
getWithId
in interfacePageCacheDataSource<AudioSong>
- Parameters:
session
- sessionid
- id of the object we are looking for- Returns:
- the persistent object or null, if not found
- See Also:
PageCacheDataSource.getWithIds(Session, Long...)
-
getWithIds
public List<AudioSong> getWithIds(org.hibernate.Session session, Long... ids)
Description copied from interface:PageCacheDataSource
Creates a query that selects persistent objects in the right order. query.setMaxResults(..) and query.setFirstResult(..) are set by the caller.- Specified by:
getWithIds
in interfacePageCacheDataSource<AudioSong>
- Parameters:
session
- sessionids
- ids of the objects we are looking for- Returns:
- list of objects. not found objects are
null
- See Also:
PageCacheDataSource.getWithId(Session, Long)
-
getIds
public IndexedId[] getIds(org.hibernate.Session session)
Description copied from interface:PageCacheDataSource
A complete list of sorted ids along with their natural indices. Indices of filtered out objects are flipped:-(index+1)
- Specified by:
getIds
in interfacePageCacheDataSource<AudioSong>
- Parameters:
session
- hibernate session- Returns:
- a complete list of persistent ids
-
createPageQuery
public org.hibernate.Query createPageQuery(org.hibernate.Session session)
Description copied from interface:PageCacheDataSource
Creates a query that selects persistent objects in the right order. query.setMaxResults(..) and query.setFirstResult(..) are set by the caller.- Specified by:
createPageQuery
in interfacePageCacheDataSource<AudioSong>
- Parameters:
session
- session- Returns:
- a query that returns objects in the right order or null, if such a query cannot be constructed
-
objectsAvailable
public void objectsAvailable(int index0, int index1)
Description copied from interface:PageCacheDataSource
Notifies the data source, that the given index range has been loaded.- Specified by:
objectsAvailable
in interfacePageCacheDataSource<AudioSong>
- Parameters:
index0
- start indexindex1
- end index (inclusive)
-
getHibernateUtil
public HibernateUtil getHibernateUtil()
- Specified by:
getHibernateUtil
in interfacePageCacheDataSource<AudioSong>
- Returns:
- hibernate utilities
-
getHibernateMediaLibrary
public HibernateMediaLibrary<?> getHibernateMediaLibrary()
-
setHibernateMediaLibrary
public void setHibernateMediaLibrary(HibernateMediaLibrary<?> hibernateMediaLibrary)
-
getLiking
public AudioSong.Liking getLiking()
-
setLiking
public void setLiking(AudioSong.Liking value)
-
isAudiobooks
public boolean isAudiobooks()
Description copied from interface:PlayList
- Specified by:
isAudiobooks
in interfacePlayList
-
setAudiobooks
public void setAudiobooks(boolean value)
Description copied from interface:PlayList
- Specified by:
setAudiobooks
in interfacePlayList
-
isMovies
public boolean isMovies()
Description copied from interface:PlayList
-
isMusic
public boolean isMusic()
Description copied from interface:PlayList
-
setMusic
public void setMusic(boolean value)
Description copied from interface:PlayList
-
isTvShows
public boolean isTvShows()
Description copied from interface:PlayList
-
setTvShows
public void setTvShows(boolean value)
Description copied from interface:PlayList
- Specified by:
setTvShows
in interfacePlayList
-
isPodcasts
public boolean isPodcasts()
Description copied from interface:PlayList
- Specified by:
isPodcasts
in interfacePlayList
-
setPodcasts
public void setPodcasts(boolean value)
Description copied from interface:PlayList
- Specified by:
setPodcasts
in interfacePlayList
-
getChildPlayLists
public List<PlayList> getChildPlayLists()
- Specified by:
getChildPlayLists
in interfacePlayList
-
setChildPlayLists
public void setChildPlayLists(List<PlayList> childPlayLists)
- Specified by:
setChildPlayLists
in interfacePlayList
-
getParentPlayList
public PlayList getParentPlayList()
- Specified by:
getParentPlayList
in interfacePlayList
-
getPlayListPath
public PlayList[] getPlayListPath()
Description copied from interface:PlayList
Returns path leading to this playlist and ending with it. I.e., the path has at least the length 1.- Specified by:
getPlayListPath
in interfacePlayList
- Returns:
- path of playlists
-
setParentPlayList
public void setParentPlayList(PlayList value)
- Specified by:
setParentPlayList
in interfacePlayList
-
getDescription
public String getDescription()
- Specified by:
getDescription
in interfacePlayList
-
setDescription
public void setDescription(String description)
- Specified by:
setDescription
in interfacePlayList
-
isMaster
public boolean isMaster()
Description copied from interface:PlayList
Indicates whether this playlist is a master playlist. E.g. the (invisible list) Library is typically the master playlist.- Specified by:
isMaster
in interfacePlayList
- Returns:
- true or false
- See Also:
PlayList.isLibrary()
-
getDistinguishedKind
public PlayList.Kind getDistinguishedKind()
Description copied from interface:PlayList
Returns the special kind of this playlist.- Specified by:
getDistinguishedKind
in interfacePlayList
- Returns:
null
if unknown
-
setDistinguishedKind
public void setDistinguishedKind(PlayList.Kind value)
Description copied from interface:PlayList
Allows setting of a special song type, likePlayList.Kind.PODCASTS
.- Specified by:
setDistinguishedKind
in interfacePlayList
- Parameters:
value
- kind
-
isLibrary
public boolean isLibrary()
Description copied from interface:PlayList
Indicates that this is a library playlist, meaning one of the top level library views (e.g. Music, AudioBooks, etc.).- Specified by:
isLibrary
in interfacePlayList
- Returns:
- true or false
- See Also:
PlayList.isMaster()
-
getGeniusTrackID
public int getGeniusTrackID()
- Specified by:
getGeniusTrackID
in interfacePlayList
-
setGeniusTrackID
public void setGeniusTrackID(int value)
- Specified by:
setGeniusTrackID
in interfacePlayList
-
isGeniusPlaylist
public boolean isGeniusPlaylist()
- Specified by:
isGeniusPlaylist
in interfacePlayList
-
setId
public void setId(Long value)
Description copied from interface:PlayList
Sets this list's id.
-
isAllItems
public boolean isAllItems()
- Specified by:
isAllItems
in interfacePlayList
-
setAllItems
public void setAllItems(boolean value)
- Specified by:
setAllItems
in interfacePlayList
-
getSmartInfo
public String getSmartInfo()
- Specified by:
getSmartInfo
in interfacePlayList
-
setSmartInfo
public void setSmartInfo(String smartInfo)
- Specified by:
setSmartInfo
in interfacePlayList
-
isSmartPlaylist
public boolean isSmartPlaylist()
- Specified by:
isSmartPlaylist
in interfacePlayList
-
getSmartCriteria
public String getSmartCriteria()
- Specified by:
getSmartCriteria
in interfacePlayList
-
setSmartCriteria
public void setSmartCriteria(String smartCriteria)
- Specified by:
setSmartCriteria
in interfacePlayList
-
isVideos
public boolean isVideos()
Description copied from interface:PlayList
iTunes 6 playlist attribute.
-
getIndexedSongIds
public IndexedId[] getIndexedSongIds()
Description copied from interface:PlayList
A complete list of sorted ids along with their natural order indices (viaIndexedId.getIndex()
). Natural indices of filtered out objects are flipped:-(index+1)
- Specified by:
getIndexedSongIds
in interfacePlayList
- Returns:
- a complete list of persistent ids along with their natural indices
-
getFilteredSongIds
public List<Long> getFilteredSongIds()
Description copied from interface:PlayList
Returns song ids from this playlist, both sorted and filtered.- Specified by:
getFilteredSongIds
in interfacePlayList
- Returns:
- song ids
-
getSongIds
public List<Long> getSongIds()
Description copied from interface:PlayList
Returns song ids from this playlist, neither sorted not filtered.- Specified by:
getSongIds
in interfacePlayList
- Returns:
- song ids
-
getSongIds
public List<Long> getSongIds(Set<? extends SongFilter> filters)
Description copied from interface:PlayList
Returns song ids from this playlist, filtered with the given filters.- Specified by:
getSongIds
in interfacePlayList
- Returns:
- song ids
- See Also:
PlayList.getSongs(Collection, int)
-
getSongs
public List<AudioSong> getSongs(Collection<? extends SongFilter> filters, int limit)
Description copied from interface:PlayList
Returns songs from this playlist, filtered with the given filters.- Specified by:
getSongs
in interfacePlayList
- Parameters:
filters
- filterslimit
- limit, -1 for no limit- Returns:
- songs
- See Also:
PlayList.getSongIds(Set)
-
countSongs
public int countSongs(Collection<? extends SongFilter> filters)
Description copied from interface:PlayList
Returns song count from this playlist, filtered with the given filters.- Specified by:
countSongs
in interfacePlayList
- Returns:
- song count
- See Also:
PlayList.getSongIds(Set)
-
filteredListIterator
public PlayListIterator<AudioSong> filteredListIterator(int firstNextFilteredIndex)
Description copied from interface:PlayList
Creates a dynamically updated iterator for this playlist. This iterator will adjust to sort/filter changes to the underlying playlist.
The iterator does not support mutable operations.- Specified by:
filteredListIterator
in interfacePlayList
- Parameters:
firstNextFilteredIndex
- index to start iterating from, first call toListIterator.next()
orListIterator.previous()
will produce the song at the given index- Returns:
- read-only, dynamically adjusting list iterator
-
getFilteredSongs
public Iterable<AudioSong> getFilteredSongs()
Description copied from interface:PlayList
Returns songs from this playlist, both sorted and filtered.- Specified by:
getFilteredSongs
in interfacePlayList
- Returns:
- songs
-
getSongs
public Iterable<AudioSong> getSongs()
Description copied from interface:PlayList
Returns songs from this playlist, neither sorted nor filtered.
-
getSongsOrderedBy
public Iterable<AudioSong> getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction)
Description copied from interface:PlayList
Returns songs from this playlist, sorted by the given property.- Specified by:
getSongsOrderedBy
in interfacePlayList
- Parameters:
sortProperty
- propertydirection
- direction- Returns:
- songs
-
getSongsOrderedBy
public Iterable<AudioSong> getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction, int limit)
Description copied from interface:PlayList
Returns songs from this playlist, sorted by the given property.- Specified by:
getSongsOrderedBy
in interfacePlayList
- Parameters:
sortProperty
- propertydirection
- directionlimit
- max number of songs to return- Returns:
- songs
-
addSongs
public void addSongs(int filteredIndex, String... locations)
Description copied from interface:PlayList
Adds songs to the playlist using only their locations.
Depending on the library implementation, the insert index may be ignored. If it is ignored, the songs will be appended at the end (this is the case for iTunes libraries).- Specified by:
addSongs
in interfacePlayList
- Parameters:
filteredIndex
- filtered index, set this to-1
, if you just want to add the song to the endlocations
- file or URL- See Also:
AudioSongLocation.getLocation()
-
addSongIds
public void addSongIds(List<Long> songIds)
Description copied from interface:PlayList
Adds the songs referenced by the given ids to this playlist.- Specified by:
addSongIds
in interfacePlayList
- Parameters:
songIds
- song ids
-
setSongs
public void setSongs(List<AudioSong> songs)
Description copied from interface:PlayList
Removes all songs from this playlist and replaces them with the given songs. If the songs are not in your library yet, corresponding entries in the database are created.
-
setSongIds
public void setSongIds(List<Long> songIds)
Description copied from interface:PlayList
Removes all songs from this playlist and replaces them with song connected to the given ids.- Specified by:
setSongIds
in interfacePlayList
- Parameters:
songIds
- song ids
-
addSongIds
public void addSongIds(int filteredIndex, List<Long> songIds)
Description copied from interface:PlayList
Adds the given songs at the given (filtered) index.- Specified by:
addSongIds
in interfacePlayList
- Parameters:
filteredIndex
- filtered indexsongIds
- songs
-
addSongs
public void addSongs(int filteredIndex, List<AudioSong> songs)
Description copied from interface:PlayList
Adds the given songs at the given (filtered) index.
-
moveSongs
public int moveSongs(int[] fromIndices, int toIndex)
Description copied from interface:PlayList
Moves songs. All indices have to be filtered.
-
addSongs
public void addSongs(org.hibernate.Session session, gnu.trove.TLongCollection ids)
Needs to be called from open transaction/session.- Parameters:
session
- sessionids
- ids
-
unfilteredIndices
public int[] unfilteredIndices(int... filteredIndices)
Description copied from interface:PlayList
Returns the unfiltered indices for the given filtered (string, order) indices.- Specified by:
unfilteredIndices
in interfacePlayList
- Parameters:
filteredIndices
- filtered indices- Returns:
- unfiltered equivalents
-
filteredIndices
public int[] filteredIndices(int... unfilteredIndices)
Description copied from interface:PlayList
Returns the filtered indices (string, order) for the given unfiltered indices.- Specified by:
filteredIndices
in interfacePlayList
- Parameters:
unfilteredIndices
- unfiltered indices- Returns:
- filtered equivalents or
-1
, if that does not exist, because the index was filtered out
-
indexOf
public int indexOf(Long id)
Description copied from interface:PlayList
Returns the first index of the given song.
-
removeSongs
public boolean removeSongs(Collection<Long> ids, boolean completelyDeleteSong)
Description copied from interface:PlayList
Removes the songs with the given ids from the list.- Specified by:
removeSongs
in interfacePlayList
- Parameters:
ids
- idscompletelyDeleteSong
- if set totrue
, the song object itself is deleted and removed from all other lists as well- Returns:
- success
-
removeSongs
public boolean removeSongs(int... filteredIndices)
Description copied from interface:PlayList
Removes the song with the given (filtered) index from the playlist. If this is a library, the file is also deleted.- Specified by:
removeSongs
in interfacePlayList
- Parameters:
filteredIndices
- filtered indices- Returns:
- true, if the system was able to find and remove the given song
-
removeAllSongs
public void removeAllSongs(org.hibernate.Session session)
Sets the internal persistent song array tonull
. This method can only be called from a transactional/session context.- Parameters:
session
- session
-
removeAllSongs
public void removeAllSongs()
Description copied from interface:PlayList
Removes all songs from this playlist.- Specified by:
removeAllSongs
in interfacePlayList
-
getSong
public AudioSong getSong(int index)
Description copied from interface:PlayList
Returns song from the given index, taking sorting and filtering into account. This method may returnnull
even if a corresponding song exists, because it is loaded asynchronously.
UsePlayList.getIdAt(int)
, if you need a synchronous result.- Specified by:
getSong
in interfacePlayList
- Parameters:
index
- index- Returns:
- song or
null
, if not in the cache or the index is bad - See Also:
PlayList.getIdAt(int)
-
getIdAt
public Long getIdAt(int index)
Description copied from interface:PlayList
Returns id of the song at the given index, taking sorting and filtering into account. Other thanPlayList.getSong(int)
, this method always returns an id, if the index is valid.- Specified by:
getIdAt
in interfacePlayList
- Parameters:
index
- index- Returns:
- id or null, if the index it not valid
- See Also:
PlayList.getSong(int)
-
getElementAt
public Object getElementAt(int index)
- Specified by:
getElementAt
in interfaceListModel
-
updateCachedSong
public void updateCachedSong(AudioSong song)
-
clearCaches
public void clearCaches()
Clears all caches that holed info about song order, search results, and songs themselves. To also invalidate aggregate data, callrefresh()
orrefresh(String)
.
-
refresh
public void refresh()
Clears the caches backing this playlist. This forces a reload the next time it is accessed.
-
refresh
public void refresh(String sortPropertyName)
All caches related to the given sort property are cleared.
-
isParentAFolder
public boolean isParentAFolder()
- Specified by:
isParentAFolder
in interfacePlayList
-
isUserPlaylist
public boolean isUserPlaylist()
Description copied from interface:PlayList
Indicates that the playlist is just a regular user playlist. Note that Matchlists are not considered regular user playlists.- Specified by:
isUserPlaylist
in interfacePlayList
- Returns:
- true or false.
-
isPurchasedMusic
public boolean isPurchasedMusic()
Description copied from interface:PlayList
- Specified by:
isPurchasedMusic
in interfacePlayList
-
setPurchasedMusic
public void setPurchasedMusic(boolean value)
- Specified by:
setPurchasedMusic
in interfacePlayList
-
getParentId
public Long getParentId()
Description copied from interface:PlayList
If this is a sub-folder/playlist, this returns the parent id.- Specified by:
getParentId
in interfacePlayList
- Returns:
- id
-
setParentId
public void setParentId(Long value)
Description copied from interface:PlayList
Sets the parent id.- Specified by:
setParentId
in interfacePlayList
- Parameters:
value
- id
-
isItemsEditable
public boolean isItemsEditable()
Description copied from interface:PlayList
Are the contained items editable? E.g., items are not editable, if they are only available online, as the metadata of some stream or online database cannot be changed locally.- Specified by:
isItemsEditable
in interfacePlayList
- Returns:
- true or false
-
canInsertItem
public boolean canInsertItem()
Description copied from interface:PlayList
Indicates whether we can insert items into this playlist.- Specified by:
canInsertItem
in interfacePlayList
- Returns:
- true or false, typically false for generated lists like "Music"
-
canAddItem
public boolean canAddItem()
Description copied from interface:PlayList
Indicates whether we can add items to this playlist.- Specified by:
canAddItem
in interfacePlayList
- Returns:
- true or false, typically false for generated lists like "Music"
-
isEditable
public boolean isEditable()
Description copied from interface:PlayList
Is this playlist editable? Only playlists created by users are editable.- Specified by:
isEditable
in interfacePlayList
- Returns:
- true or false
-
isAggregateDataAvailable
public boolean isAggregateDataAvailable()
Description copied from interface:PlayList
Indicates whether we currently have valid aggregate (total size, duration, etc.) data. If the data is not available, the asynchronous computation is triggered.- Specified by:
isAggregateDataAvailable
in interfacePlayList
- Returns:
- true or false
-
getFileSize
public long getFileSize()
Description copied from interface:PlayList
Get the sum of all file sizes (with filters applied).- Specified by:
getFileSize
in interfacePlayList
- Returns:
- sum of file sizes
-
getTotalTime
public long getTotalTime()
Description copied from interface:PlayList
Get time with filters applied.- Specified by:
getTotalTime
in interfacePlayList
- Returns:
- time
-
setSize
public void setSize(int size)
-
getUnfilteredSize
public int getUnfilteredSize()
Description copied from interface:PlayList
Unfiltered number of songs in playlist. May return-1
, if the number is unknown- Specified by:
getUnfilteredSize
in interfacePlayList
- Returns:
- number of songs in playlist
- See Also:
PlayList.setSubstringFilter(String, PlayList.SubstringFilterProperty)
-
getUnfilteredTime
public long getUnfilteredTime()
Description copied from interface:PlayList
Get time without any filters applied.- Specified by:
getUnfilteredTime
in interfacePlayList
- Returns:
- time
-
setSortColumnProperty
public void setSortColumnProperty(String sortColumnProperty)
Description copied from interface:PlayList
Sets "visual/semantic" sort property.- Specified by:
setSortColumnProperty
in interfacePlayList
- Parameters:
sortColumnProperty
- name of the property that is marked as sorted-by in the UI- See Also:
PlayList.getSortColumnProperty()
-
getSortColumnProperty
public String getSortColumnProperty()
Description copied from interface:PlayList
Returns the name of the single property the playlist is sorted by. Note that for special properties likename
this may not be the same properties as the ones we use forORDER BY
SQL clauses. But, it's the property that should be highlighted in a UI.- Specified by:
getSortColumnProperty
in interfacePlayList
- Returns:
- column
-
getSortProperties
public String[] getSortProperties()
Description copied from interface:PlayList
Actual sort properties, used inORDER BY
HQL/SQL clauses.- Specified by:
getSortProperties
in interfacePlayList
- Returns:
- sort properties
-
getSortProperty
public String getSortProperty(int index)
Description copied from interface:PlayList
Actual sort property, used inORDER BY
SQL clauses.- Specified by:
getSortProperty
in interfacePlayList
- Parameters:
index
- index- Returns:
- property or
null
-
getSyncTempo
public com.tagtraum.audiokern.bpm.Tempo getSyncTempo()
Description copied from interface:PlayList
When set to a non-null
value,Key
values are displayed as if the song was played back at the given tempo. This has consequences for the sort order.- Specified by:
getSyncTempo
in interfacePlayList
- Returns:
- sync tempo
- See Also:
PlayList.setSortProperties(String...)
-
setSyncTempo
public void setSyncTempo(com.tagtraum.audiokern.bpm.Tempo syncTempo)
Description copied from interface:PlayList
When set to a non-null
value,Key
values are displayed as if the song was played back at the given tempo. This has consequences for the sort order.- Specified by:
setSyncTempo
in interfacePlayList
- Specified by:
setSyncTempo
in interfaceSyncTempoAware
- Parameters:
syncTempo
- sync tempo
-
setSortProperties
public void setSortProperties(String... properties)
Description copied from interface:PlayList
Sets sort properties.- Specified by:
setSortProperties
in interfacePlayList
- Parameters:
properties
- sort properties
-
setSortDirection
public void setSortDirection(PlayList.SortDirection sortDirection)
Description copied from interface:PlayList
Sort direction.- Specified by:
setSortDirection
in interfacePlayList
- Parameters:
sortDirection
- sort direction
-
getSortDirection
public PlayList.SortDirection getSortDirection()
Description copied from interface:PlayList
Return sort direction.- Specified by:
getSortDirection
in interfacePlayList
- Returns:
- sort direction
-
getSubstringFilter
public String getSubstringFilter()
Description copied from interface:PlayList
Current substring filter.- Specified by:
getSubstringFilter
in interfacePlayList
- Returns:
- filter string
-
setSubstringFilter
public void setSubstringFilter(String substring, PlayList.SubstringFilterProperty substringFilterProperty)
Description copied from interface:PlayList
Sets the filter and which property to filter in one swoop.- Specified by:
setSubstringFilter
in interfacePlayList
- Parameters:
substring
- filter stringsubstringFilterProperty
- property to filter
-
getSubstringFilterProperty
public PlayList.SubstringFilterProperty getSubstringFilterProperty()
Description copied from interface:PlayList
Current property to filter.- Specified by:
getSubstringFilterProperty
in interfacePlayList
- Returns:
- which property to filter (substring)
- See Also:
PlayList.setSubstringFilter(String, SubstringFilterProperty)
-
getSpecialPlayListInfo
public SpecialPlayListInfo getSpecialPlayListInfo()
- Specified by:
getSpecialPlayListInfo
in interfacePlayList
-
getSpecialPlayListInfoId
public Long getSpecialPlayListInfoId()
- Specified by:
getSpecialPlayListInfoId
in interfacePlayList
-
setSpecialPlayListInfo
public void setSpecialPlayListInfo(SpecialPlayListInfo value)
- Specified by:
setSpecialPlayListInfo
in interfacePlayList
-
isSpecialPlayList
public boolean isSpecialPlayList()
- Specified by:
isSpecialPlayList
in interfacePlayList
-
-