Search in sources :

Example 6 with Album

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

the class LibraryBrowserServiceTest method getAlbumNames.

private String getAlbumNames(int artistId, boolean sortByYear, boolean sortAscending) {
    List<Album> albums = browserService.getAlbums(artistId, sortByYear, sortAscending);
    StringBuilder sb = new StringBuilder();
    for (Album album : albums) {
        sb.append(album.getName());
    }
    return sb.toString();
}
Also used : Album(com.github.hakko.musiccabinet.domain.model.music.Album)

Example 7 with Album

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

the class LibraryBrowserServiceTest method assertAlbums.

private void assertAlbums(List<Album> albums, Artist artist, String... albumNames) {
    Assert.assertNotNull(albums);
    Assert.assertEquals(albumNames.length, albums.size());
    for (Album album : albums) {
        // not returned by db
        album.setArtist(artist);
    }
    for (String albumName : albumNames) {
        Assert.assertTrue(albums.contains(new Album(artist, albumName)));
    }
}
Also used : Album(com.github.hakko.musiccabinet.domain.model.music.Album)

Example 8 with Album

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

the class DirectoryBrowserServiceTest method findsSingleAlbumInDirectory.

@Test
public void findsSingleAlbumInDirectory() throws ApplicationException {
    scannerService.add(set(cd1));
    int cd1Id = browserService.getRootDirectories().iterator().next().getId();
    List<Album> albums = browserService.getAlbums(cd1Id, true, true);
    Assert.assertEquals(1, albums.size());
    Album album = albums.get(0);
    Assert.assertEquals("The Beatles", album.getArtist().getName());
    Assert.assertEquals("1962-1966", album.getName());
    Assert.assertEquals(4, album.getTrackIds().size());
}
Also used : Album(com.github.hakko.musiccabinet.domain.model.music.Album) Test(org.junit.Test)

Example 9 with Album

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

the class JdbcAlbumInfoDaoTest method allAlbumsWithoutInfoAreReturned.

@Test
public void allAlbumsWithoutInfoAreReturned() {
    deleteAlbumInfos();
    deleteLibraryTracks();
    createLibraryTracks(aiNirvana, aiHurts, aiSchuller);
    List<Album> albums = dao.getAlbumsWithoutInfo();
    Assert.assertNotNull(albums);
    Assert.assertTrue(albums.contains(aiNirvana.getAlbum()));
    Assert.assertTrue(albums.contains(aiHurts.getAlbum()));
    Assert.assertTrue(albums.contains(aiSchuller.getAlbum()));
    for (Album album : albums) {
        Assert.assertNotNull(album.getName());
        Assert.assertNotNull(album.getArtist().getName());
    }
}
Also used : Album(com.github.hakko.musiccabinet.domain.model.music.Album) Test(org.junit.Test)

Example 10 with Album

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

the class JdbcAlbumInfoDao method getAlbumInfosForIds.

@Override
public Map<Integer, AlbumInfo> getAlbumInfosForIds(List<Integer> paths) {
    String sql = "select alb.album_name_capitalization, ai.mediumimageurl," + " ai.largeimageurl, ai.extralargeimageurl, alb.id from music.albuminfo ai" + " inner join music.album alb on ai.album_id = alb.id" + " where alb.id in (" + getParameters(paths.size()) + ")";
    final Map<Integer, AlbumInfo> albumInfos = new HashMap<>();
    try {
        jdbcTemplate.query(sql, paths.toArray(), new RowCallbackHandler() {

            @Override
            public void processRow(ResultSet rs) 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));
                int albumId = rs.getInt(5);
                ai.setAlbum(new Album(albumName));
                albumInfos.put(albumId, ai);
            }
        });
    } catch (DataAccessException e) {
        LOG.warn("Could not fetch album infos for paths " + paths + "!", e);
    }
    return albumInfos;
}
Also used : HashMap(java.util.HashMap) 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) RowCallbackHandler(org.springframework.jdbc.core.RowCallbackHandler) DataAccessException(org.springframework.dao.DataAccessException)

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