Class HibernateMediaLibrary<A extends ApplicationComponent>

    • 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()
      • 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)
      • openDatabase

        public void openDatabase()
        Opens the underlying database that has the descriptor set with setLibraryDescriptor(LibraryDescriptor). Nothing should really happen, if the database with the same id is already open.
      • 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 create
        name - 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 new PlayList object with the given name and id.
        Parameters:
        id - persistentId
        parentId - parent playlist persistent id - may be null, if there is no parent
        name - name
        folder - 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 the iTunes Music Library.xml.
        Returns:
        persistent library id as long
      • 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
      • getSong

        public Song getSong​(org.hibernate.Session session,
                            Long playlistId,
                            Long id)
      • getSongs

        public List<Song> getSongs​(org.hibernate.Session session,
                                   Long playlistId,
                                   Long... ids)
      • 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 the TagCollection 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 the TagCollection 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 property propertyName for songs with restrictionPropertyName equaling restrictionPropertyValue.
        Parameters:
        propertyName - properties whose values are going to be returned
        restrictionPropertyName - property that is used to select the return set
        restrictionPropertyValue - property value that is used to select the return set
        Returns:
        values of propertyName
      • 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 - property
        valueList - list that this method will add the results to. Before the results are added, the list is cleared.
        Returns:
        values for a given property
      • getGenres

        public List<String> getGenres()
        Returns:
        unsorted list of all non-null genre names.
      • countSongsWithPropertyValue

        public int countSongsWithPropertyValue​(String propertyName,
                                               Object propertyValue)
        Description copied from interface: MediaLibrary
        Count all songs with a property equal to the given value.
        Parameters:
        propertyName - name of a property
        propertyValue - 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 properties equal 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 the AND 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 the AND 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
      • 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 an Iterable 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 an Iterable that can be used to iterate over all song ids.
        Returns:
        an object from which one can get an iterator
      • getPlayLists

        public List<PlayList> getPlayLists()
        Description copied from interface: MediaLibrary
        List of all playlists.
        Returns:
        list of all playlists in the library
      • setPlayLists

        public void setPlayLists​(List<PlayList> playLists)
      • 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)
      • getSongsWithFileAndSize

        public List<AudioSong> getSongsWithFileAndSize​(String filename,
                                                       int size)
      • getSongsWithNameArtistAlbumTotalTime

        public List<AudioSong> getSongsWithNameArtistAlbumTotalTime​(String name,
                                                                    String artist,
                                                                    String album,
                                                                    int time)
      • fetchLazyAssociations

        public static void fetchLazyAssociations​(List<Song> songs)
      • 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 save
        changedProperty - property that has been changed (may be null, if multiple properties have changed or the change is unknown)
      • updateGenreIRI

        public void updateGenreIRI​(AudioSong song)
      • 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 - property
        propertyChangeListener - listener
      • removePlayListPropertyChangeListener

        public void removePlayListPropertyChangeListener​(PropertyChangeListener propertyChangeListener)
      • removePlayListPropertyChangeListener

        public void removePlayListPropertyChangeListener​(String property,
                                                         PropertyChangeListener propertyChangeListener)
      • addPlayListDataListener

        public void addPlayListDataListener​(ListDataListener l)
      • removePlayListDataListener

        public void removePlayListDataListener​(ListDataListener l)
      • callOnDefaultJob

        public <T> T callOnDefaultJob​(Callable<T> callable,
                                      T onErrorValue)
        Executes the given Callable in the default job queue. All exceptions are caught. Blocks indefinitely.
        Type Parameters:
        T - type of return value
        Parameters:
        callable - callable
        onErrorValue - 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 given Callable in the default job queue. All exceptions are caught.
        Type Parameters:
        T - type of return value
        Parameters:
        callable - callable
        timeoutInSeconds - timeout, negative values are interpreted as infinite timeout
        onErrorValue - 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 given Callable in the default job queue. Blocks indefinitely.
        Type Parameters:
        T - type of return value
        Parameters:
        callable - callable
        rte - exception to throw, in case we encounter an exception that is not a RuntimeException
        Returns:
        return value
      • callOnDefaultJobWithException

        public <T> T callOnDefaultJobWithException​(Callable<T> callable,
                                                   long timeoutInSeconds,
                                                   RuntimeException rte)
        Executes the given Callable in the default job queue.
        Type Parameters:
        T - type of return value
        Parameters:
        callable - callable
        timeoutInSeconds - timeout, negative values are interpreted as infinite timeout
        rte - exception to throw, in case we encounter an exception that is not a RuntimeException
        Returns:
        return value
      • runOnDefaultJob

        public static void runOnDefaultJob​(Callable<?> callable)
        Executes the given Callable 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.