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