Package it.unipd.netmus.shared

Examples of it.unipd.netmus.shared.SongDTO


        client_factory.getProfileView().startLoading();
        final String song_id = FieldVerifier.generateSongId(title, artist,
                album);

        // ricerca nella mappa delle info già caricate
        final SongDTO song_dto = info_alredy_loaded.get(song_id);

        if (song_dto != null) {

            // La canzone è già stata caricata una volta e le informazioni sono
            // disponibili
            // nel client.
            Timer timerPlay = new Timer() {
                @Override
                public void run() {
                    if (song_dto.getYoutubeCode().equals("")) {
                        // client_factory.getProfileView().closeYouTube();
                        client_factory.getProfileView().playYouTube(
                                "00000000000");
                        client_factory.getProfileView().showErrorFast(
                                my_constants.notYoutube() + title + "\"");
                        client_factory.getProfileView().playNext();
                    } else {
                        // client_factory.getProfileView().closeYouTube();
                        client_factory.getProfileView().playYouTube(
                                song_dto.getYoutubeCode());
                        client_factory.getProfileView().setInfo(
                                title + " - " + artist + " - " + album);
                    }

                    if (!song_dto.getAlbumCover().equals(""))
                        client_factory.getProfileView().paintMainCover(
                                song_dto.getAlbumCover());
                    else
                        client_factory.getProfileView().paintMainCover(
                                "images/test_cover.jpg");

                    client_factory.getProfileView().stopLoading();
                }
            };
            timerPlay.schedule(5);

            return;
        } else {

            Map<String, SongSummaryDTO> songs = current_user.getMusicLibrary()
                    .getSongs();

            // caricamento dalla mappa della canzone selezionata
            final SongSummaryDTO current_song_summary_dto = songs
                    .get(FieldVerifier.generateSongId(title, artist, album));

            song_service_svc.getSongDTO(current_song_summary_dto,
                    new AsyncCallback<SongDTO>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            client_factory.getProfileView().showError(
                                    my_constants.getSongDTOError());
                            client_factory.getProfileView().stopLoading();
                        }

                        @Override
                        public void onSuccess(SongDTO song_dto) {

                            // Imposta la copertina di default in caso non ce ne
                            // siano altre
                            if (song_dto.getAlbumCover().equals("")) {
                                song_dto.setAlbumCover("images/test_cover.jpg");
                            }

                            // Mostra la copertina relativa alla canzone
                            client_factory.getProfileView().paintMainCover(
                                    song_dto.getAlbumCover());

                            // Salva le informazioni caricate dal server in una
                            // mappa cache diposnibile nel client
                            info_alredy_loaded.put(song_id, song_dto);
                            cover_alredy_loaded.put(FieldVerifier
                                    .generateAlbumId(album, artist), song_dto
                                    .getAlbumCover());

                            // Se il video non è disponibile passa alla canzone
                            // successiva
                            if (song_dto.getYoutubeCode().equals("")) {
                                // client_factory.getProfileView().closeYouTube();
                                client_factory.getProfileView().playYouTube(
                                        "00000000000");
                                client_factory.getProfileView().showErrorFast(
                                        my_constants.notYoutube() + title
                                                + "\"");
                                client_factory.getProfileView().playNext();
                            } else {
                                // client_factory.getProfileView().closeYouTube();
                                client_factory.getProfileView().playYouTube(
                                        song_dto.getYoutubeCode());
                                client_factory.getProfileView().setInfo(
                                        title + " - " + artist + " - " + album);
                            }

                            client_factory.getProfileView().stopLoading();
View Full Code Here


        client_factory.getProfileView().startLoading();
        final String song_id = FieldVerifier.generateSongId(title, artist,
                album);

        // ricerca nella mappa delle info già caricate
        SongDTO song_dto = info_alredy_loaded.get(song_id);

        if (song_dto != null) {

            // Riempimento default dei campi
            String genere = "----";
            String anno = "----";
            String compositore = "----";
            String traccia = "----";
            String cover = "images/test_cover.jpg";

            // se le info erano già state caricate precedentemente vengono prese
            // ed utilizzate immediatamente
            if (!song_dto.getGenre().equals(""))
                genere = song_dto.getGenre();
            if (!song_dto.getYear().equals(""))
                anno = song_dto.getYear();
            if (!song_dto.getComposer().equals(""))
                compositore = song_dto.getComposer();
            if (!song_dto.getTrackNumber().equals(""))
                traccia = song_dto.getTrackNumber();
            if (!song_dto.getAlbumCover().equals(""))
                cover = song_dto.getAlbumCover();

            // richiesta di visualizzazione delle info dettagliate
            // nell'interfaccia grafica
            client_factory.getProfileView().setSongFields(artist, title, album,
                    genere, anno, compositore, traccia, cover);

            client_factory.getProfileView().stopLoading();

            return;
        } else {
            Map<String, SongSummaryDTO> songs = current_user.getMusicLibrary()
                    .getSongs();
            final SongSummaryDTO current_song_summary_dto = songs.get(song_id);

            song_service_svc.getSongDTO(current_song_summary_dto,
                    new AsyncCallback<SongDTO>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            client_factory.getProfileView().showError(
                                    my_constants.getSongDTOError());
                            client_factory.getProfileView().stopLoading();
                        }

                        @Override
                        public void onSuccess(SongDTO song_dto) {

                            // Imposta la copertina di default in caso non ce ne
                            // siano altre
                            if (song_dto.getAlbumCover().equals("")) {
                                song_dto.setAlbumCover("images/test_cover.jpg");
                            }

                            // salva le info caricate in modo che siano sempre
                            // disponibili nel client
                            info_alredy_loaded.put(song_id, song_dto);

                            // Riempimento default dei campi
                            String genere = "----";
                            String anno = "----";
                            String compositore = "----";
                            String traccia = "----";
                            String cover = "images/test_cover.jpg";

                            if (!song_dto.getGenre().equals(""))
                                genere = song_dto.getGenre();
                            if (!song_dto.getYear().equals(""))
                                anno = song_dto.getYear();
                            if (!song_dto.getComposer().equals(""))
                                compositore = song_dto.getComposer();
                            if (!song_dto.getTrackNumber().equals(""))
                                traccia = song_dto.getTrackNumber();
                            if (!song_dto.getAlbumCover().equals(""))
                                cover = song_dto.getAlbumCover();

                            // richiesta di visualizzazione delle info
                            // dettagliate nell'interfaccia grafica
                            client_factory.getProfileView().setSongFields(
                                    artist, title, album, genere, anno,
View Full Code Here

     *
     * @param node
     * @return
     */
    private SongDTO generateDTO(Element node) {
        SongDTO song = new SongDTO();
        while (node.hasChildNodes()) {
            Element child = (Element) node.getFirstChild();
            String name = child.getNodeName();
            // System.out.println(child.getFirstChild().getNodeValue());
            // if (name.equals(FILE_NAME))
            // song.setFile(clearFileName(child.getFirstChild().getNodeValue()));
            if (name.equals(FILE_NAME))
                song.setFile(child.getFirstChild().getNodeValue());
            else if (name.equals(ALBUMTITLE_NAME))
                song.setAlbum(child.getFirstChild().getNodeValue());
            else if (name.equals(AUTHORCOMPOSER_NAME))
                song.setComposer(child.getFirstChild().getNodeValue());
            else if (name.equals(LEADARTIST_NAME))
                song.setArtist(child.getFirstChild().getNodeValue());
            else if (name.equals(SONGGENRE_NAME))
                song.setGenre(child.getFirstChild().getNodeValue());
            else if (name.equals(SONGTITLE_NAME))
                song.setTitle(child.getFirstChild().getNodeValue());
            else if (name.equals(TRACKNUMBER_NAME))
                song.setTrackNumber(child.getFirstChild().getNodeValue());
            else if (name.equals(YEAR_NAME))
                song.setYear(child.getFirstChild().getNodeValue());
            node.removeChild(child);
        }
        return song;
    }
View Full Code Here

    @Override
    public synchronized SongDTO getSongDTO(SongSummaryDTO song_summary_dto) {

        Song song = Song.loadFromDTO(song_summary_dto);

        SongDTO song_dto = null;
        if (song != null) {
            song_dto = song.toSongDTO();
        } else {
            return new SongDTO();
        }

        String ip = getThreadLocalRequest().getRemoteAddr();
        if (ip.equals("127.0.0.1"))
            ip = "";

        song_dto.setAlbumCover(Album.getAlbumCoverLastFm(song_dto.getAlbum(),
                song_dto.getArtist()));
        song_dto.setYoutubeCode(Utils.getYouTubeCode(song.getTitle() + " "
                + song.getArtist(), ip));

        return song_dto;
    }
View Full Code Here

                t = null;

            if (t == null)
                return null;
            else {
                SongDTO song = new SongDTO();
                song.setTitle(t.getName());
                song.setArtist(t.getArtist());
                if (t.getAlbum() != null)
                    song.setAlbum(t.getAlbum());
                song.setAlbumCover(t.getImageURL(ImageSize.EXTRALARGE));
                return song;
            }
        } catch (Exception e) {
        }
        return null;
View Full Code Here

    public void setYear(String year) {
        this.year = year;
    }

    public SongDTO toSongDTO() {
        SongDTO tmp = new SongDTO();
        tmp.setArtist(this.artist);
        tmp.setTitle(this.title);
        tmp.setAlbum(this.album);
        tmp.setComposer(this.composer);
        tmp.setGenre(this.genre);
        tmp.setTrackNumber(this.track_number);
        tmp.setYear(this.year);
        tmp.setNumOwners(this.num_owners);
        tmp.setNumRatings(this.num_ratings);
        tmp.setRating(this.rating);
        return tmp;
    }
View Full Code Here

TOP

Related Classes of it.unipd.netmus.shared.SongDTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.