use of se.light.assembly64.model.ContentEntry in project assembly64fx by freabemania.
the class Support method flattenAndEnrichEntries.
public static List<ContentEntry> flattenAndEnrichEntries(List<PlaylistEntry> selectedItems, List<List<ContentEntry>> contentEntries) {
if (selectedItems.size() != contentEntries.size()) {
throw new IllegalStateException("?!?!?!?");
}
Iterator<PlaylistEntry> items = selectedItems.iterator();
Iterator<List<ContentEntry>> contentItems = contentEntries.iterator();
while (items.hasNext()) {
PlaylistEntry currEntry = items.next();
List<ContentEntry> currContentsForEntry = contentItems.next();
for (ContentEntry entry : currContentsForEntry) {
entry.setFullPlaylistInfo(currEntry);
}
}
return contentEntries.stream().flatMap(item -> item.stream()).collect(Collectors.toList());
}
use of se.light.assembly64.model.ContentEntry in project assembly64fx by freabemania.
the class PlaylistService method addSong.
public void addSong(PlaylistInfo playlist, ContentEntry song) {
List<PlaylistEntry> entryAsList = new ArrayList<>();
entryAsList.add(song.getFullPlaylistInfo());
List<ContentEntry> contentEntries = new ArrayList<>();
contentEntries.add(new ContentEntry(song.getId(), song.getName()));
List<List<ContentEntry>> listOfListsOfContent = new ArrayList<>();
listOfListsOfContent.add(contentEntries);
addSongs(playlist, entryAsList, listOfListsOfContent);
}
use of se.light.assembly64.model.ContentEntry in project assembly64fx by freabemania.
the class PlaylistService method addSongs.
public void addSongs(PlaylistInfo playlist, List<PlaylistEntry> entry, List<List<ContentEntry>> songs) {
if (entry.size() != songs.size()) {
throw new IllegalStateException("Bah!!!");
}
List<PlaylistEntry> entries = new ArrayList<>();
Iterator<PlaylistEntry> entryLists = entry.iterator();
Iterator<List<ContentEntry>> entryListsSongs = songs.iterator();
while (entryLists.hasNext()) {
PlaylistEntry pEntry = entryLists.next();
List<ContentEntry> pSongs = entryListsSongs.next();
for (ContentEntry song : pSongs) {
if (song.getName().toLowerCase().endsWith(".sid")) {
PlaylistEntry tmp = new PlaylistEntry(pEntry.getId(), pEntry.getCategory(), song.getId());
tmp.setName(song.getName());
if (song.getFullPlaylistInfo() != null) {
tmp.setGroup(song.getFullPlaylistInfo().getGroup());
tmp.setYear(song.getFullPlaylistInfo().getYear());
}
entries.add(tmp);
}
}
}
Executors.newSingleThreadExecutor().execute(() -> {
List<PlaylistEntry> addedSongs = getClient().target(server).path("/leet/playlistsnew/addsongs/" + playlist.getId()).request().header("email", getSessionInfo().getEmail()).header("token", getSessionInfo().getToken()).post(Entity.json(entries), new GenericType<List<PlaylistEntry>>() {
});
List<PlaylistEntry> songsForPlaylist = getSongsForPlaylist(playlist);
for (PlaylistEntry tmp1 : addedSongs) {
for (PlaylistEntry tmp2 : songsForPlaylist) {
if (tmp2.getSongId().equals(tmp1.getSongId())) {
tmp2.setGroup(tmp1.getGroup());
tmp2.setYear(tmp1.getYear());
tmp2.setName(tmp1.getName());
break;
}
}
}
flush(songsForPlaylist, resolvePlaylistFilename(playlist));
playlist.setChecksum(getChksum(songsForPlaylist));
Analytics.sendEvent("sidify", "addsongs");
});
List<PlaylistEntry> songsForPlaylist = getSongsForPlaylist(playlist);
songsForPlaylist.addAll(entries);
flush(songsForPlaylist, resolvePlaylistFilename(playlist));
playlist.setChecksum(getChksum(songsForPlaylist));
flushPlaylistInfo();
}
Aggregations