Search in sources :

Example 11 with LastFmUser

use of com.github.hakko.musiccabinet.domain.model.library.LastFmUser in project musiccabinet by hakko.

the class StarService method getStarredTracksMask.

public boolean[] getStarredTracksMask(String lastFmUsername, List<Integer> trackIds) {
    boolean[] mask = new boolean[trackIds.size()];
    if (lastFmUsername == null) {
        return mask;
    }
    LastFmUser lastFmUser = getLastFmUser(lastFmUsername);
    for (int i = 0; i < mask.length; i++) {
        mask[i] = getStarredTracks(lastFmUser).contains(trackIds.get(i));
    }
    return mask;
}
Also used : LastFmUser(com.github.hakko.musiccabinet.domain.model.library.LastFmUser)

Example 12 with LastFmUser

use of com.github.hakko.musiccabinet.domain.model.library.LastFmUser in project musiccabinet by hakko.

the class StarService method unstarArtist.

public void unstarArtist(String lastFmUsername, int artistId) {
    LastFmUser lastFmUser = getLastFmUser(lastFmUsername);
    starDao.unstarArtist(lastFmUser, artistId);
    getStarredArtistIds(lastFmUser).remove(artistId);
}
Also used : LastFmUser(com.github.hakko.musiccabinet.domain.model.library.LastFmUser)

Example 13 with LastFmUser

use of com.github.hakko.musiccabinet.domain.model.library.LastFmUser in project musiccabinet by hakko.

the class StarService method getStarredAlbumsMask.

public boolean[] getStarredAlbumsMask(String lastFmUsername, List<Integer> albumIds) {
    boolean[] mask = new boolean[albumIds.size()];
    if (lastFmUsername == null) {
        return mask;
    }
    LastFmUser lastFmUser = getLastFmUser(lastFmUsername);
    for (int i = 0; i < mask.length; i++) {
        mask[i] = getStarredAlbumIds(lastFmUser).contains(albumIds.get(i));
    }
    return mask;
}
Also used : LastFmUser(com.github.hakko.musiccabinet.domain.model.library.LastFmUser)

Example 14 with LastFmUser

use of com.github.hakko.musiccabinet.domain.model.library.LastFmUser in project musiccabinet by hakko.

the class StarService method getLastFmUser.

protected LastFmUser getLastFmUser(String lastFmUsername) {
    if (cachedUsers.containsKey(lastFmUsername)) {
        return cachedUsers.get(lastFmUsername);
    }
    LastFmUser lastFmUser = lastFmDao.getLastFmUser(lastFmUsername);
    cachedUsers.put(lastFmUsername, lastFmUser);
    return lastFmUser;
}
Also used : LastFmUser(com.github.hakko.musiccabinet.domain.model.library.LastFmUser)

Example 15 with LastFmUser

use of com.github.hakko.musiccabinet.domain.model.library.LastFmUser in project musiccabinet by hakko.

the class StarService method starArtist.

public void starArtist(String lastFmUsername, int artistId) {
    LastFmUser lastFmUser = getLastFmUser(lastFmUsername);
    starDao.starArtist(lastFmUser, artistId);
    getStarredArtistIds(lastFmUser).add(artistId);
}
Also used : LastFmUser(com.github.hakko.musiccabinet.domain.model.library.LastFmUser)

Aggregations

LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)35 Test (org.junit.Test)14 Track (com.github.hakko.musiccabinet.domain.model.music.Track)9 WebserviceInvocation (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)7 ApplicationException (com.github.hakko.musiccabinet.exception.ApplicationException)7 WSResponse (com.github.hakko.musiccabinet.ws.lastfm.WSResponse)7 NameValuePair (org.apache.http.NameValuePair)6 Scrobble (com.github.hakko.musiccabinet.domain.model.aggr.Scrobble)4 Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)4 Before (org.junit.Before)4 Period (com.github.hakko.musiccabinet.domain.model.library.Period)3 Calltype (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype)3 WebserviceHistoryService (com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService)3 ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)3 StringUtil (com.github.hakko.musiccabinet.util.StringUtil)3 ArrayList (java.util.ArrayList)3 UserStarredTrack (com.github.hakko.musiccabinet.domain.model.aggr.UserStarredTrack)2 UserTopArtists (com.github.hakko.musiccabinet.domain.model.aggr.UserTopArtists)2 File (com.github.hakko.musiccabinet.domain.model.library.File)2 Album (com.github.hakko.musiccabinet.domain.model.music.Album)2