use of com.github.hakko.musiccabinet.domain.model.music.Album in project musiccabinet by hakko.
the class JdbcNameSearchDao method getAlbums.
@Override
public NameSearchResult<Album> getAlbums(String userQuery, int offset, int limit) {
String sql = "select mart.id, mart.artist_name_capitalization," + " malb.id, malb.album_name_capitalization, la.year," + " d1.path, f1.filename, d2.path, f2.filename, null, array[]::int[]" + " from library.album la" + " inner join music.album malb on la.album_id = malb.id" + " inner join music.artist mart on malb.artist_id = mart.id" + " left outer join library.file f1 on f1.id = la.embeddedcoverartfile_id" + " left outer join library.directory d1 on f1.directory_id = d1.id" + " left outer join library.file f2 on f2.id = la.coverartfile_id" + " left outer join library.directory d2 on f2.directory_id = d2.id" + " where la.album_name_search like ?" + " order by malb.album_name" + " offset ? limit ?";
List<Album> albums = jdbcTemplate.query(sql, new Object[] { getNameQuery(userQuery), offset, limit }, new AlbumRowMapper());
return new NameSearchResult<>(albums, offset);
}
use of com.github.hakko.musiccabinet.domain.model.music.Album in project musiccabinet by hakko.
the class JdbcAlbumInfoDao method getAlbumsWithoutInfo.
@Override
public List<Album> getAlbumsWithoutInfo() {
String sql = "select a.artist_name_capitalization, ma.album_name_capitalization from" + " library.album la" + " inner join music.album ma on la.album_id = ma.id" + " inner join music.artist a on ma.artist_id = a.id" + " where not exists (" + " select 1 from music.albuminfo where album_id = ma.id)" + " and ma.album_name_capitalization != '" + UNKNOWN_ALBUM + "'" + " order by a.id limit 3000";
List<Album> albums = jdbcTemplate.query(sql, new RowMapper<Album>() {
@Override
public Album mapRow(ResultSet rs, int rowNum) throws SQLException {
return new Album(rs.getString(1), rs.getString(2));
}
});
return albums;
}
use of com.github.hakko.musiccabinet.domain.model.music.Album in project musiccabinet by hakko.
the class JdbcAlbumInfoDao method getAlbumInfosForArtist.
@Override
public List<AlbumInfo> getAlbumInfosForArtist(final int artistId) {
String sql = "select alb.album_name_capitalization, ai.mediumimageurl, " + " ai.largeimageurl, ai.extralargeimageurl, art.artist_name_capitalization" + " from music.albuminfo ai" + " inner join music.album alb on ai.album_id = alb.id" + " inner join music.artist art on alb.artist_id = art.id" + " where art.id = " + artistId;
List<AlbumInfo> albums = jdbcTemplate.query(sql, new RowMapper<AlbumInfo>() {
@Override
public AlbumInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
AlbumInfo ai = new AlbumInfo();
String albumName = rs.getString(1);
ai.setMediumImageUrl(rs.getString(2));
ai.setLargeImageUrl(rs.getString(3));
ai.setExtraLargeImageUrl(rs.getString(4));
String artistName = rs.getString(5);
ai.setAlbum(new Album(artistName, albumName));
return ai;
}
});
return albums;
}
use of com.github.hakko.musiccabinet.domain.model.music.Album in project musiccabinet by hakko.
the class AlbumNameRowMapper method mapRow.
@Override
public Album mapRow(ResultSet rs, int rowNum) throws SQLException {
int artistId = rs.getInt(1);
String artistName = rs.getString(2);
int albumId = rs.getInt(3);
String albumName = rs.getString(4);
return new Album(new Artist(artistId, artistName), albumId, albumName);
}
use of com.github.hakko.musiccabinet.domain.model.music.Album in project musiccabinet by hakko.
the class AlbumInfoClientTest method validateParameters.
@Test
public void validateParameters() throws ApplicationException {
final String method = AlbumInfoClient.METHOD;
final String artistName = "The Beatles";
final String albumName = "Sergeant Pepper's Lonely Hearts Club Band";
new AlbumInfoClient() {
@Override
protected WSResponse executeWSRequest(WebserviceInvocation wi, List<NameValuePair> params) throws ApplicationException {
Assert.assertEquals(Calltype.ALBUM_GET_INFO, wi.getCallType());
Assert.assertTrue(albumName.equals(wi.getAlbum().getName()));
assertHasParameter(params, PARAM_METHOD, method);
assertHasParameter(params, PARAM_ARTIST, artistName);
assertHasParameter(params, PARAM_ALBUM, albumName);
return null;
}
@Override
protected WebserviceHistoryService getHistoryService() {
return Mockito.mock(WebserviceHistoryService.class);
}
}.getAlbumInfo(new Album(artistName, albumName));
}
Aggregations