Search in sources :

Example 1 with Song

use of net.robinfriedli.aiode.entities.Song in project aiode by robinfriedli.

the class HibernatePlaylistMigrator method loadSpotifyItem.

private void loadSpotifyItem(XmlElement item, int index, SpotifyTrackBulkLoadingService spotifyBulkLoadingService, ShardManager shardManager, Playlist newPlaylist, Map<PlaylistItem, Integer> itemsWithIndex, SpotifyTrackKind kind) {
    String id = item.getAttribute("id").getValue();
    spotifyBulkLoadingService.add(createItem(id, kind), spotifyTrack -> {
        String addedUser = item.getAttribute("addedUser").getValue();
        String addedUserId = item.getAttribute("addedUserId").getValue();
        PlaylistItem playlistItem = spotifyTrack.exhaustiveMatch(track -> new Song(track, addedUser, addedUserId, newPlaylist, session), episode -> new Episode(episode, addedUser, addedUserId, newPlaylist));
        playlistItem.setAddedUser(item.getAttribute("addedUser").getValue());
        playlistItem.setAddedUserId(item.getAttribute("addedUserId").getValue());
        itemsWithIndex.put(playlistItem, index);
    });
}
Also used : Episode(net.robinfriedli.aiode.entities.Episode) Song(net.robinfriedli.aiode.entities.Song) PlaylistItem(net.robinfriedli.aiode.entities.PlaylistItem)

Example 2 with Song

use of net.robinfriedli.aiode.entities.Song in project aiode by robinfriedli.

the class VerifyPlaylistInterceptor method onDeleteChained.

@Override
public void onDeleteChained(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
    if (entity instanceof PlaylistItem) {
        PlaylistItem playlistItem = (PlaylistItem) entity;
        Playlist playlist = playlistItem.getPlaylist();
        if (playlistItem instanceof Song) {
            playlist.getSongs().remove(playlistItem);
        } else if (playlistItem instanceof Video) {
            playlist.getVideos().remove(playlistItem);
        } else if (playlistItem instanceof UrlTrack) {
            playlist.getUrlTracks().remove(playlistItem);
        }
    }
}
Also used : Playlist(net.robinfriedli.aiode.entities.Playlist) Song(net.robinfriedli.aiode.entities.Song) Video(net.robinfriedli.aiode.entities.Video) UrlTrack(net.robinfriedli.aiode.entities.UrlTrack) PlaylistItem(net.robinfriedli.aiode.entities.PlaylistItem)

Aggregations

PlaylistItem (net.robinfriedli.aiode.entities.PlaylistItem)2 Song (net.robinfriedli.aiode.entities.Song)2 Episode (net.robinfriedli.aiode.entities.Episode)1 Playlist (net.robinfriedli.aiode.entities.Playlist)1 UrlTrack (net.robinfriedli.aiode.entities.UrlTrack)1 Video (net.robinfriedli.aiode.entities.Video)1