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);
});
}
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);
}
}
}
Aggregations