Search in sources :

Example 16 with Album

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

the class DirectoryBrowserServiceTest method getAlbumNames.

private String getAlbumNames(int directoryId, boolean sortByYear, boolean sortAscending) {
    List<Album> albums = browserService.getAlbums(directoryId, 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 17 with Album

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

the class AlbumInfoHandler method endElement.

@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
    if (parsing) {
        String chars = characterData.toString();
        if (TAG_NAME.equals(qName)) {
            albumInfo = new AlbumInfo();
            albumInfo.setAlbum(new Album(chars));
        } else if (TAG_ARTIST.equals(qName)) {
            albumInfo.getAlbum().setArtist(new Artist(chars));
        } else if (TAG_IMAGE.equals(qName)) {
            if (ATTR_SMALL.equals(imageSize)) {
                albumInfo.setSmallImageUrl(validateUrl(chars));
            } else if (ATTR_MEDIUM.equals(imageSize)) {
                albumInfo.setMediumImageUrl(validateUrl(chars));
            } else if (ATTR_LARGE.equals(imageSize)) {
                albumInfo.setLargeImageUrl(validateUrl(chars));
            } else if (ATTR_EXTRA_LARGE.equals(imageSize)) {
                albumInfo.setExtraLargeImageUrl(validateUrl(chars));
            }
        } else if (TAG_LISTENERS.equals(qName)) {
            albumInfo.setListeners(toInt(chars));
        } else if (TAG_PLAY_COUNT.equals(qName)) {
            albumInfo.setPlayCount(toInt(chars));
            parsing = false;
        }
    }
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) AlbumInfo(com.github.hakko.musiccabinet.domain.model.music.AlbumInfo) Album(com.github.hakko.musiccabinet.domain.model.music.Album)

Example 18 with Album

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

the class JdbcPlayCountDaoTest method prepareTestData.

@Before
public void prepareTestData() throws ApplicationException {
    dao.getJdbcTemplate().execute("truncate music.lastfmuser cascade");
    dao.getJdbcTemplate().execute("truncate library.file cascade");
    dao.getJdbcTemplate().execute("truncate music.artist cascade");
    user1 = new LastFmUser(username1 = "user1");
    user2 = new LastFmUser(username2 = "user2");
    lastFmDao.createOrUpdateLastFmUser(user1);
    lastFmDao.createOrUpdateLastFmUser(user2);
    File file1 = UnittestLibraryUtil.getFile("artist1", "album1", "title1");
    File file2 = UnittestLibraryUtil.getFile("artist1", "album1", "title2");
    File file3 = UnittestLibraryUtil.getFile("artist2", "album2", "title3");
    submitFile(additionDao, Arrays.asList(file1, file2, file3));
    List<Artist> artists = browserDao.getArtists();
    assertEquals(2, artists.size());
    artist1 = artists.get(0);
    artist2 = artists.get(1);
    List<Album> albums1 = browserDao.getAlbums(artist1.getId(), true);
    assertEquals(1, albums1.size());
    album1 = albums1.get(0);
    List<Album> albums2 = browserDao.getAlbums(artist2.getId(), true);
    assertEquals(1, albums2.size());
    album2 = albums2.get(0);
    List<Track> tracks1 = browserDao.getTracks(album1.getTrackIds());
    Collections.sort(tracks1, trackComparator);
    assertEquals(2, tracks1.size());
    track1a = tracks1.get(0);
    track1b = tracks1.get(1);
    List<Track> tracks2 = browserDao.getTracks(album2.getTrackIds());
    assertEquals(1, tracks2.size());
    track2 = tracks2.get(0);
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) LastFmUser(com.github.hakko.musiccabinet.domain.model.library.LastFmUser) Album(com.github.hakko.musiccabinet.domain.model.music.Album) File(com.github.hakko.musiccabinet.domain.model.library.File) UnittestLibraryUtil.submitFile(com.github.hakko.musiccabinet.util.UnittestLibraryUtil.submitFile) Track(com.github.hakko.musiccabinet.domain.model.music.Track) Before(org.junit.Before)

Example 19 with Album

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

the class LibraryBrowserServiceTest method findsCoverArtFileForTrack.

@Test
public void findsCoverArtFileForTrack() throws Exception {
    Artist artist = new Artist("Artist Name");
    int artistId = musicDao.getArtistId(artist);
    scannerService.add(set(media3));
    List<Album> albums = browserService.getAlbums(artistId, false, true);
    int trackId = albums.get(1).getTrackIds().get(0);
    String coverArtPath = browserService.getCoverArtFileForTrack(trackId);
    Assert.assertNotNull(coverArtPath);
    Assert.assertTrue(coverArtPath.endsWith("Folder artwork" + separatorChar + "folder.png"));
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) Album(com.github.hakko.musiccabinet.domain.model.music.Album) Test(org.junit.Test)

Example 20 with Album

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

the class LibraryBrowserServiceTest method findsAlbum.

@Test
public void findsAlbum() throws Exception {
    Artist theBeatles = new Artist("The Beatles");
    int beatlesId = musicDao.getArtistId(theBeatles);
    scannerService.add(set(media2));
    List<Album> albums = browserService.getAlbums(beatlesId, true);
    assertAlbums(albums, theBeatles, "1967-1970");
    int albumId = albums.get(0).getId();
    Album album = browserService.getAlbum(albumId);
    assertAlbums(Arrays.asList(album), theBeatles, "1967-1970");
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) Album(com.github.hakko.musiccabinet.domain.model.music.Album) 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