Class HibernatePlayList

    • Constructor Detail

      • 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 via Session.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 interface PlayList
        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)
      • setChangedExternally

        public void setChangedExternally​(boolean changedExternally)
        Indicates that this playlist was changed by an external process. Setting this flag may cause PropertyChangeEvents 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 interface PageCacheDataSource<AudioSong>
        Parameters:
        song - some persistent object
        Returns:
        persistent id
      • 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 interface PageCacheDataSource<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 interface PageCacheDataSource<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 interface PageCacheDataSource<AudioSong>
        Parameters:
        index0 - start index
        index1 - end index (inclusive)
      • setHibernateMediaLibrary

        public void setHibernateMediaLibrary​(HibernateMediaLibrary<?> hibernateMediaLibrary)
      • getId

        public Long getId()
        Description copied from interface: PlayList
        This list's id.
        Specified by:
        getId in interface PlayList
        Returns:
        id
      • setMovies

        public void setMovies​(boolean value)
        Specified by:
        setMovies in interface PlayList
      • 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 interface PlayList
        Returns:
        path of playlists
      • 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 interface PlayList
        Returns:
        true or false
        See Also:
        PlayList.isLibrary()
      • setMaster

        public void setMaster​(boolean value)
        Specified by:
        setMaster in interface PlayList
      • 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 interface PlayList
        Returns:
        true or false
        See Also:
        PlayList.isMaster()
      • setId

        public void setId​(Long value)
        Description copied from interface: PlayList
        Sets this list's id.
        Specified by:
        setId in interface PlayList
        Parameters:
        value - id
      • isAllItems

        public boolean isAllItems()
        Specified by:
        isAllItems in interface PlayList
      • setAllItems

        public void setAllItems​(boolean value)
        Specified by:
        setAllItems in interface PlayList
      • isVideos

        public boolean isVideos()
        Description copied from interface: PlayList
        iTunes 6 playlist attribute.
        Specified by:
        isVideos in interface PlayList
        Returns:
        true or false
      • setVideos

        public void setVideos​(boolean value)
        Specified by:
        setVideos in interface PlayList
      • getIndexedSongIds

        public IndexedId[] getIndexedSongIds()
        Description copied from interface: PlayList
        A complete list of sorted ids along with their natural order indices (via IndexedId.getIndex()). Natural indices of filtered out objects are flipped: -(index+1)
        Specified by:
        getIndexedSongIds in interface PlayList
        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 interface PlayList
        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 interface PlayList
        Returns:
        song ids
      • getSongIds

        public List<Long> getSongIds​(org.hibernate.Session session)
      • 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 interface PlayList
        Parameters:
        firstNextFilteredIndex - index to start iterating from, first call to ListIterator.next() or ListIterator.previous() will produce the song at the given index
        Returns:
        read-only, dynamically adjusting list iterator
      • getSongs

        public Iterable<AudioSong> getSongs()
        Description copied from interface: PlayList
        Returns songs from this playlist, neither sorted nor filtered.
        Specified by:
        getSongs in interface PlayList
        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 interface PlayList
        Parameters:
        sortProperty - property
        direction - direction
        limit - 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 interface PlayList
        Parameters:
        filteredIndex - filtered index, set this to -1, if you just want to add the song to the end
        locations - 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 interface PlayList
        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.
        Specified by:
        setSongs in interface PlayList
        Parameters:
        songs - songs
      • 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 interface PlayList
        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 interface PlayList
        Parameters:
        filteredIndex - filtered index
        songIds - songs
      • addSongs

        public void addSongs​(int filteredIndex,
                             List<AudioSong> songs)
        Description copied from interface: PlayList
        Adds the given songs at the given (filtered) index.
        Specified by:
        addSongs in interface PlayList
        Parameters:
        filteredIndex - filtered index
        songs - songs
      • moveSongs

        public int moveSongs​(int[] fromIndices,
                             int toIndex)
        Description copied from interface: PlayList
        Moves songs. All indices have to be filtered.
        Specified by:
        moveSongs in interface PlayList
        Parameters:
        fromIndices - indices to move songs from
        toIndex - index to move the songs to
        Returns:
        new lead index of the moved songs
      • addSongs

        public void addSongs​(org.hibernate.Session session,
                             gnu.trove.TLongCollection ids)
        Needs to be called from open transaction/session.
        Parameters:
        session - session
        ids - 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 interface PlayList
        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 interface PlayList
        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.
        Specified by:
        indexOf in interface PlayList
        Parameters:
        id - song id
        Returns:
        index or -1, if not found
      • 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 interface PlayList
        Parameters:
        ids - ids
        completelyDeleteSong - if set to true, 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 interface PlayList
        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 to null. 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 interface PlayList
      • 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 return null even if a corresponding song exists, because it is loaded asynchronously.
        Use PlayList.getIdAt(int), if you need a synchronous result.
        Specified by:
        getSong in interface PlayList
        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 than PlayList.getSong(int), this method always returns an id, if the index is valid.
        Specified by:
        getIdAt in interface PlayList
        Parameters:
        index - index
        Returns:
        id or null, if the index it not valid
        See Also:
        PlayList.getSong(int)
      • 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, call refresh() or refresh(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.
      • isFolder

        public boolean isFolder()
        Specified by:
        isFolder in interface PlayList
      • setFolder

        public void setFolder​(boolean value)
        Specified by:
        setFolder in interface PlayList
      • 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 interface PlayList
        Returns:
        true or false.
      • setPurchasedMusic

        public void setPurchasedMusic​(boolean value)
        Specified by:
        setPurchasedMusic in interface PlayList
      • 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 interface PlayList
        Returns:
        id
      • setParentId

        public void setParentId​(Long value)
        Description copied from interface: PlayList
        Sets the parent id.
        Specified by:
        setParentId in interface PlayList
        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 interface PlayList
        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 interface PlayList
        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 interface PlayList
        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 interface PlayList
        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 interface PlayList
        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 interface PlayList
        Returns:
        sum of file sizes
      • getTotalTime

        public long getTotalTime()
        Description copied from interface: PlayList
        Get time with filters applied.
        Specified by:
        getTotalTime in interface PlayList
        Returns:
        time
      • setSize

        public void setSize​(int size)
      • getUnfilteredTime

        public long getUnfilteredTime()
        Description copied from interface: PlayList
        Get time without any filters applied.
        Specified by:
        getUnfilteredTime in interface PlayList
        Returns:
        time
      • 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 like name this may not be the same properties as the ones we use for ORDER BY SQL clauses. But, it's the property that should be highlighted in a UI.
        Specified by:
        getSortColumnProperty in interface PlayList
        Returns:
        column
      • getSortProperties

        public String[] getSortProperties()
        Description copied from interface: PlayList
        Actual sort properties, used in ORDER BY HQL/SQL clauses.
        Specified by:
        getSortProperties in interface PlayList
        Returns:
        sort properties
      • getSortProperty

        public String getSortProperty​(int index)
        Description copied from interface: PlayList
        Actual sort property, used in ORDER BY SQL clauses.
        Specified by:
        getSortProperty in interface PlayList
        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 interface PlayList
        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 interface PlayList
        Specified by:
        setSyncTempo in interface SyncTempoAware
        Parameters:
        syncTempo - sync tempo
      • setSortProperties

        public void setSortProperties​(String... properties)
        Description copied from interface: PlayList
        Sets sort properties.
        Specified by:
        setSortProperties in interface PlayList
        Parameters:
        properties - sort properties
      • getSubstringFilter

        public String getSubstringFilter()
        Description copied from interface: PlayList
        Current substring filter.
        Specified by:
        getSubstringFilter in interface PlayList
        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 interface PlayList
        Parameters:
        substring - filter string
        substringFilterProperty - property to filter
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object