Search in sources :

Example 11 with Album

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);
}
Also used : NameSearchResult(com.github.hakko.musiccabinet.domain.model.aggr.NameSearchResult) Album(com.github.hakko.musiccabinet.domain.model.music.Album) AlbumRowMapper(com.github.hakko.musiccabinet.dao.jdbc.rowmapper.AlbumRowMapper)

Example 12 with Album

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;
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) Album(com.github.hakko.musiccabinet.domain.model.music.Album)

Example 13 with Album

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;
}
Also used : SQLException(java.sql.SQLException) AlbumInfo(com.github.hakko.musiccabinet.domain.model.music.AlbumInfo) ResultSet(java.sql.ResultSet) Album(com.github.hakko.musiccabinet.domain.model.music.Album)

Example 14 with Album

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);
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) Album(com.github.hakko.musiccabinet.domain.model.music.Album)

Example 15 with Album

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));
}
Also used : NameValuePair(org.apache.http.NameValuePair) ApplicationException(com.github.hakko.musiccabinet.exception.ApplicationException) WebserviceHistoryService(com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService) Album(com.github.hakko.musiccabinet.domain.model.music.Album) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) Test(org.junit.Test)

Aggregations

Album (com.github.hakko.musiccabinet.domain.model.music.Album)22 Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)11 Test (org.junit.Test)10 Track (com.github.hakko.musiccabinet.domain.model.music.Track)5 AlbumInfo (com.github.hakko.musiccabinet.domain.model.music.AlbumInfo)4 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)2 ApplicationException (com.github.hakko.musiccabinet.exception.ApplicationException)2 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 AlbumRowMapper (com.github.hakko.musiccabinet.dao.jdbc.rowmapper.AlbumRowMapper)1 NameSearchResult (com.github.hakko.musiccabinet.domain.model.aggr.NameSearchResult)1 File (com.github.hakko.musiccabinet.domain.model.library.File)1 WebserviceInvocation (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)1 ArtistInfo (com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)1 AlbumInfoParser (com.github.hakko.musiccabinet.parser.lastfm.AlbumInfoParser)1 AlbumInfoParserImpl (com.github.hakko.musiccabinet.parser.lastfm.AlbumInfoParserImpl)1 WebserviceHistoryService (com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService)1 StringUtil (com.github.hakko.musiccabinet.util.StringUtil)1