예제 #1
0
  public List<Album> getAlbums(
      List<com.github.hakko.musiccabinet.domain.model.music.Album> alb, boolean onlyLocalArtwork) {
    List<Album> albums = new ArrayList<>();
    List<Integer> trackIds = new ArrayList<>();

    boolean preferLastFmArtwork = settingsService.isPreferLastFmArtwork();
    for (com.github.hakko.musiccabinet.domain.model.music.Album a : alb) {
      Album album = new Album();
      album.setArtistId(a.getArtist().getId());
      album.setArtistName(a.getArtist().getName());
      album.setId(a.getId());
      album.setTitle(a.getName());
      album.setYear(a.getYear());
      album.setCoverArtPath(a.getCoverArtPath());
      album.setCoverArtUrl(a.getCoverArtURL());
      album.setTrackIds(a.getTrackIds());
      if (album.getCoverArtPath() != null && album.getCoverArtUrl() != null) {
        if (preferLastFmArtwork && !onlyLocalArtwork) {
          album.setCoverArtPath(null);
        } else {
          album.setCoverArtUrl(null);
        }
      }
      trackIds.addAll(a.getTrackIds());
      albums.add(album);
    }
    loadMediaFiles(trackIds);
    return albums;
  }
 protected boolean isWebserviceInvocationAllowed(Calltype callType, Album album) {
   String sql =
       "select max(invocation_time) from library.webservice_history h"
           + " inner join music.album alb on alb.id = h.album_id"
           + " inner join music.artist art on art.id = alb.artist_id"
           + " where calltype_id = "
           + callType.getDatabaseId()
           + " and art.artist_name = upper(?) and alb.album_name = upper(?)";
   Timestamp lastInvocation =
       jdbcTemplate.queryForObject(
           sql, new Object[] {album.getArtist().getName(), album.getName()}, Timestamp.class);
   return isWebserviceInvocationAllowed(callType, lastInvocation);
 }