use of com.github.hakko.musiccabinet.domain.model.library.LastFmUser in project musiccabinet by hakko.
the class UserStarredTrackRowMapper method mapRow.
@Override
public UserStarredTrack mapRow(ResultSet rs, int rowNum) throws SQLException {
String username = rs.getString(1);
String sessionKey = rs.getString(2);
String artistName = rs.getString(3);
String trackName = rs.getString(4);
return new UserStarredTrack(new LastFmUser(username, sessionKey), new Track(artistName, trackName));
}
use of com.github.hakko.musiccabinet.domain.model.library.LastFmUser in project musiccabinet by hakko.
the class UserRecommendedArtistsService method updateSearchIndex.
@Override
protected void updateSearchIndex() throws ApplicationException {
List<LastFmUser> users = lastFmSettingsService.getLastFmUsers();
setTotalOperations(users.size());
List<UserRecommendedArtists> artists = new ArrayList<>();
for (LastFmUser user : users) {
try {
WSResponse wsResponse = userRecommendedArtistsClient.getUserRecommendedArtists(user.getLastFmUsername());
LOG.debug(wsResponse);
if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
UserRecommendedArtistsParser parser = new UserRecommendedArtistsParserImpl(stringUtil.getInputStream());
artists.add(new UserRecommendedArtists(user, parser.getArtists()));
}
} catch (ApplicationException e) {
LOG.warn("Fetching top artist for " + user.getLastFmUsername() + " failed.", e);
}
addFinishedOperation();
}
dao.createUserRecommendedArtists(artists);
}
use of com.github.hakko.musiccabinet.domain.model.library.LastFmUser in project musiccabinet by hakko.
the class JdbcMusicBrainzAlbumDaoTest method findsAlbumsMissingFromLibraryWithRecentlyPlayedFilter.
@Test
public void findsAlbumsMissingFromLibraryWithRecentlyPlayedFilter() {
List<MBAlbum> albums = albumDao.getMissingAlbums(null, null, USER, 10, 0);
assertEquals(0, albums.size());
LastFmUser lastFmUser = new LastFmUser(USER);
lastFmDao.createOrUpdateLastFmUser(lastFmUser);
submitFile(additionDao, getFile(artist.getName(), UNKNOWN, UNKNOWN));
Track track = browserDao.getTracks(browserDao.getRandomTrackIds(1)).get(0);
playCountDao.addPlayCount(lastFmUser, track);
albums = albumDao.getMissingAlbums(null, null, USER, 10, 0);
assertEquals(2, albums.size());
}
use of com.github.hakko.musiccabinet.domain.model.library.LastFmUser 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);
}
use of com.github.hakko.musiccabinet.domain.model.library.LastFmUser in project musiccabinet by hakko.
the class JdbcWebserviceHistoryDaoTest method importUserRelatedDataNotPossibleTwice.
@Test
public void importUserRelatedDataNotPossibleTwice() {
Calltype TOP_ARTISTS = Calltype.USER_GET_TOP_ARTISTS;
LastFmUser user = new LastFmUser("arnathalon");
WebserviceInvocation topArtists = new WebserviceInvocation(TOP_ARTISTS, user, OVERALL.getDays());
deleteWebserviceInvocations();
assertTrue(dao.isWebserviceInvocationAllowed(topArtists));
dao.logWebserviceInvocation(topArtists);
assertFalse(dao.isWebserviceInvocationAllowed(topArtists));
}
Aggregations