protected boolean isWebserviceInvocationAllowed(Calltype callType, Track track) {
   String sql =
       "select max(invocation_time) from library.webservice_history h"
           + " inner join music.track t on t.id = h.track_id"
           + " inner join music.artist a on a.id = t.artist_id"
           + " where calltype_id = "
           + callType.getDatabaseId()
           + " and a.artist_name = upper(?) and t.track_name = upper(?)";
   Timestamp lastInvocation =
       jdbcTemplate.queryForObject(
           sql, new Object[] {track.getArtist().getName(), track.getName()}, Timestamp.class);
   return isWebserviceInvocationAllowed(callType, lastInvocation);
 }
Ejemplo n.º 2
0
 public void loadMediaFiles(List<Integer> mediaFileIds) {
   List<Integer> missingMediaFileIds = new ArrayList<>(mediaFileIds);
   for (Iterator<Integer> it = missingMediaFileIds.iterator(); it.hasNext(); ) {
     if (mediaFileCache.isElementInMemory(it.next())) {
       it.remove();
     }
   }
   if (missingMediaFileIds.size() > 0) {
     List<Track> tracks = libraryBrowserService.getTracks(missingMediaFileIds);
     for (Track track : tracks) {
       mediaFileCache.put(new Element(track.getId(), getMediaFile(track)));
     }
   }
 }
Ejemplo n.º 3
0
 @Override
 public int hashCode() {
   return new HashCodeBuilder()
       .append(lastFmUser)
       .append(track.getId())
       .append(startTime)
       .toHashCode();
 }
Ejemplo n.º 4
0
  @Override
  public boolean equals(Object o) {
    if (o == null) return false;
    if (o == this) return true;
    if (o.getClass() != getClass()) return false;

    Scrobble s = (Scrobble) o;
    return new EqualsBuilder()
        .append(lastFmUser, s.lastFmUser)
        .append(track.getId(), s.track.getId())
        .append(startTime, s.startTime)
        .isEquals();
  }
Ejemplo n.º 5
0
 public static MediaFile getMediaFile(Track track) {
   MediaFile mediaFile = new MediaFile(track.getId());
   mediaFile.setFile(new File(track.getMetaData().getPath()));
   mediaFile.getMetaData().setAlbum(track.getMetaData().getAlbum());
   mediaFile.getMetaData().setAlbumId(track.getMetaData().getAlbumId());
   mediaFile.getMetaData().setArtist(track.getMetaData().getArtist());
   mediaFile.getMetaData().setArtistId(track.getMetaData().getArtistId());
   mediaFile.getMetaData().setComposer(track.getMetaData().getComposer());
   mediaFile.getMetaData().setBitRate((int) track.getMetaData().getBitrate());
   mediaFile.getMetaData().setDiscNumber((int) track.getMetaData().getDiscNr());
   mediaFile.getMetaData().setDuration((int) track.getMetaData().getDuration());
   mediaFile.getMetaData().setFileSize((long) track.getMetaData().getSize());
   mediaFile
       .getMetaData()
       .setFormat(track.getMetaData().getMediaType().getFilesuffix().toLowerCase());
   mediaFile.getMetaData().setGenre(track.getMetaData().getGenre());
   mediaFile.getMetaData().setTitle(track.getName());
   mediaFile.getMetaData().setTrackNumber((int) track.getMetaData().getTrackNr());
   mediaFile.getMetaData().setVariableBitRate(track.getMetaData().isVbr());
   mediaFile.getMetaData().setYear(toYear(track.getMetaData().getYear()));
   mediaFile.getMetaData().setHasLyrics(track.getMetaData().hasLyrics());
   return mediaFile;
 }