Search in sources :

Example 1 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class JdbcArtistInfoDao method getArtistInfo.

@Override
public ArtistInfo getArtistInfo(final int artistId) {
    String sql = "select a.artist_name_capitalization, ai.largeimageurl, ai.biosummary," + " exists(select 1 from library.artisttoptrackplaycount where artist_id = a.id)" + " from music.artist a" + " left outer join music.artistinfo ai on ai.artist_id = a.id" + " where a.id = " + artistId;
    List<ArtistInfo> artistInfos = jdbcTemplate.query(sql, new RowMapper<ArtistInfo>() {

        @Override
        public ArtistInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
            ArtistInfo ai = new ArtistInfo();
            ai.setArtist(new Artist(artistId, rs.getString(1)));
            ai.setLargeImageUrl(rs.getString(2));
            ai.setBioSummary(rs.getString(3));
            ai.setInSearchIndex(rs.getBoolean(4));
            return ai;
        }
    });
    return artistInfos.isEmpty() ? null : artistInfos.get(0);
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)

Example 2 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class JdbcArtistInfoDao method getArtistInfo.

@Override
public ArtistInfo getArtistInfo(final Artist artist) {
    String sql = "select ai.smallimageurl, ai.mediumimageurl, ai.largeimageurl, ai.extralargeimageurl, " + "ai.listeners, ai.playcount, ai.biosummary, ai.biocontent from music.artistinfo ai" + " inner join music.artist a on ai.artist_id = a.id" + " where a.artist_name = upper(?)";
    ArtistInfo artistInfo = jdbcTemplate.queryForObject(sql, new Object[] { artist.getName() }, new RowMapper<ArtistInfo>() {

        @Override
        public ArtistInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
            ArtistInfo ai = new ArtistInfo();
            ai.setArtist(artist);
            ai.setSmallImageUrl(rs.getString(1));
            ai.setMediumImageUrl(rs.getString(2));
            ai.setLargeImageUrl(rs.getString(3));
            ai.setExtraLargeImageUrl(rs.getString(4));
            ai.setListeners(rs.getInt(5));
            ai.setPlayCount(rs.getInt(6));
            ai.setBioSummary(rs.getString(7));
            ai.setBioContent(rs.getString(8));
            return ai;
        }
    });
    return artistInfo;
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)

Example 3 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class JdbcArtistInfoDao method getDetailedArtistInfo.

@Override
public ArtistInfo getDetailedArtistInfo(final int artistId) {
    String sql = "select a.artist_name_capitalization, ai.largeimageurl, ai.biocontent" + " from music.artist a" + " left outer join music.artistinfo ai on ai.artist_id = a.id" + " where a.id = " + artistId;
    List<ArtistInfo> artistInfos = jdbcTemplate.query(sql, new RowMapper<ArtistInfo>() {

        @Override
        public ArtistInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
            ArtistInfo ai = new ArtistInfo();
            ai.setArtist(new Artist(artistId, rs.getString(1)));
            ai.setLargeImageUrl(rs.getString(2));
            ai.setBioContent(rs.getString(3));
            return ai;
        }
    });
    return artistInfos.isEmpty() ? null : artistInfos.get(0);
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)

Example 4 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class JdbcUserRecommendedArtistsDaoTest method createArtistMetaData.

private void createArtistMetaData() {
    Set<Artist> artists = new HashSet<>();
    for (UserRecommendedArtists ura : Arrays.asList(joanRec, rjRec, ftpareaRec)) {
        for (RecommendedArtist rec : ura.getArtists()) {
            artists.add(rec.getArtist());
        }
    }
    List<File> files = new ArrayList<>();
    for (Artist artist : artists) {
        files.add(getFile(artist.getName(), null, null));
    }
    List<ArtistInfo> artistInfos = new ArrayList<>();
    for (Artist artist : artists) {
        artistInfos.add(new ArtistInfo(artist, "/url/to/" + artist.getName()));
    }
    additionDao.getJdbcTemplate().execute("truncate library.directory cascade");
    UnittestLibraryUtil.submitFile(additionDao, files);
    artistInfoDao.createArtistInfo(artistInfos);
}
Also used : RecommendedArtist(com.github.hakko.musiccabinet.domain.model.aggr.UserRecommendedArtists.RecommendedArtist) Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) UserRecommendedArtists(com.github.hakko.musiccabinet.domain.model.aggr.UserRecommendedArtists) ArrayList(java.util.ArrayList) RecommendedArtist(com.github.hakko.musiccabinet.domain.model.aggr.UserRecommendedArtists.RecommendedArtist) UnittestLibraryUtil.getFile(com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile) File(com.github.hakko.musiccabinet.domain.model.library.File) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) HashSet(java.util.HashSet)

Example 5 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class JdbcGroupWeeklyArtistChartDaoTest method createArtistMetaData.

private void createArtistMetaData() {
    Set<Artist> artists = new HashSet<>();
    for (int i = 0; i < 3; i++) {
        artists.add(artistChart.getArtistPlayCounts().get(i).getArtist());
    }
    List<File> files = new ArrayList<>();
    for (Artist artist : artists) {
        files.add(getFile(artist.getName(), null, null));
    }
    List<ArtistInfo> artistInfos = new ArrayList<>();
    for (Artist artist : artists) {
        artistInfos.add(new ArtistInfo(artist, "/url/to/" + artist.getName()));
    }
    additionDao.getJdbcTemplate().execute("truncate library.directory cascade");
    additionDao.getJdbcTemplate().execute("truncate library.artist cascade");
    additionDao.getJdbcTemplate().execute("truncate music.groupweeklyartistchart cascade");
    UnittestLibraryUtil.submitFile(additionDao, files);
    artistInfoDao.createArtistInfo(artistInfos);
    dao.createArtistCharts(Arrays.asList(artistChart));
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) ArrayList(java.util.ArrayList) UnittestLibraryUtil.getFile(com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile) File(com.github.hakko.musiccabinet.domain.model.library.File) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) HashSet(java.util.HashSet)

Aggregations

ArtistInfo (com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)22 Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)11 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)7 File (com.github.hakko.musiccabinet.domain.model.library.File)5 ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)4 UnittestLibraryUtil.getFile (com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile)4 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 HashSet (java.util.HashSet)3 Before (org.junit.Before)3 ArtistInfoParserImpl (com.github.hakko.musiccabinet.parser.lastfm.ArtistInfoParserImpl)2 TagTopArtists (com.github.hakko.musiccabinet.domain.model.aggr.TagTopArtists)1 UserRecommendedArtists (com.github.hakko.musiccabinet.domain.model.aggr.UserRecommendedArtists)1 RecommendedArtist (com.github.hakko.musiccabinet.domain.model.aggr.UserRecommendedArtists.RecommendedArtist)1 UserTopArtists (com.github.hakko.musiccabinet.domain.model.aggr.UserTopArtists)1 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)1 Period (com.github.hakko.musiccabinet.domain.model.library.Period)1 Album (com.github.hakko.musiccabinet.domain.model.music.Album)1 ArtistRelation (com.github.hakko.musiccabinet.domain.model.music.ArtistRelation)1