Search in sources :

Example 11 with ContentEntry

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());
}
Also used : X509Certificate(java.security.cert.X509Certificate) SSLContext(javax.net.ssl.SSLContext) LoggerFactory(org.slf4j.LoggerFactory) TrustManager(javax.net.ssl.TrustManager) PathService(se.light.assembly64.service.PathService) StringUtils(org.apache.commons.lang3.StringUtils) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) ArtifactType(se.light.assembly64.model.ArtifactType) Matcher(java.util.regex.Matcher) Map(java.util.Map) Method(java.lang.reflect.Method) MapType(com.fasterxml.jackson.databind.type.MapType) ContentEntry(se.light.assembly64.model.ContentEntry) TextField(javafx.scene.control.TextField) Artifact(se.light.assembly64.model.Artifact) Collectors(java.util.stream.Collectors) LocalStorageUtil(se.light.assembly64.util.LocalStorageUtil) StandardCharsets(java.nio.charset.StandardCharsets) Executors(java.util.concurrent.Executors) IOUtils(org.apache.commons.io.IOUtils) Base64(java.util.Base64) List(java.util.List) LocalDate(java.time.LocalDate) Pattern(java.util.regex.Pattern) PlaylistEntry(se.light.assembly64.model.PlaylistEntry) GuiLocation(se.light.assembly64.model.GuiLocation) Client(javax.ws.rs.client.Client) HashMap(java.util.HashMap) PlaylistInfo(se.light.assembly64.model.PlaylistInfo) GlobalRepoService(se.light.assembly64.service.GlobalRepoService) SessionInfo(se.light.assembly64.model.SessionInfo) ArrayList(java.util.ArrayList) ClientBuilder(javax.ws.rs.client.ClientBuilder) ExecutorService(java.util.concurrent.ExecutorService) CollectionLikeType(com.fasterxml.jackson.databind.type.CollectionLikeType) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Files(java.nio.file.Files) StringWriter(java.io.StringWriter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FileUtils(org.apache.commons.io.FileUtils) CertificateException(java.security.cert.CertificateException) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) File(java.io.File) AtomicLong(java.util.concurrent.atomic.AtomicLong) URLEncoder(java.net.URLEncoder) Paths(java.nio.file.Paths) X509TrustManager(javax.net.ssl.X509TrustManager) DateTimeFormatter(java.time.format.DateTimeFormatter) ObservableValue(javafx.beans.value.ObservableValue) Comparator(java.util.Comparator) ChangeListener(javafx.beans.value.ChangeListener) LocationAndInstallationStatus(se.light.assembly64.model.LocationAndInstallationStatus) ContentEntry(se.light.assembly64.model.ContentEntry) List(java.util.List) ArrayList(java.util.ArrayList) PlaylistEntry(se.light.assembly64.model.PlaylistEntry)

Example 12 with ContentEntry

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);
}
Also used : ContentEntry(se.light.assembly64.model.ContentEntry) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Support.readList(se.light.assembly64.Support.readList) List(java.util.List) PlaylistEntry(se.light.assembly64.model.PlaylistEntry)

Example 13 with ContentEntry

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();
}
Also used : ContentEntry(se.light.assembly64.model.ContentEntry) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Support.readList(se.light.assembly64.Support.readList) List(java.util.List) PlaylistEntry(se.light.assembly64.model.PlaylistEntry)

Aggregations

ContentEntry (se.light.assembly64.model.ContentEntry)13 File (java.io.File)7 List (java.util.List)7 PlaylistEntry (se.light.assembly64.model.PlaylistEntry)7 ArrayList (java.util.ArrayList)6 ActionEvent (javafx.event.ActionEvent)5 ContextMenu (javafx.scene.control.ContextMenu)5 MenuItem (javafx.scene.control.MenuItem)5 PlaylistInfo (se.light.assembly64.model.PlaylistInfo)5 Comparator (java.util.Comparator)3 Executors (java.util.concurrent.Executors)3 Collectors (java.util.stream.Collectors)3 ChangeListener (javafx.beans.value.ChangeListener)3 ObservableValue (javafx.beans.value.ObservableValue)3 ObservableList (javafx.collections.ObservableList)3 Menu (javafx.scene.control.Menu)3 PlaylistMenuItem (se.light.assembly64.model.PlaylistMenuItem)3 DateTimeFormatter (java.time.format.DateTimeFormatter)2 Label (javafx.scene.control.Label)2 TextField (javafx.scene.control.TextField)2