コード例 #1
0
  @Test
  public void addCherSimilarTracksAndGetPlaylist() throws ApplicationException {
    TrackSimilarityParser tsParser =
        new TrackSimilarityParserImpl(new ResourceUtil(CHER_SIMILAR_TRACKS).getInputStream());
    trackRelationDao.createTrackRelations(tsParser.getTrack(), tsParser.getTrackRelations());

    List<File> files = new ArrayList<>();
    for (TrackRelation tr : tsParser.getTrackRelations()) {
      String artistName = tr.getTarget().getArtist().getName();
      if ("Madonna".equals(artistName)) {
        files.add(getFile(artistName, null, tr.getTarget().getName()));
      }
    }
    UnittestLibraryUtil.submitFile(additionDao, files);

    int trackId =
        musicDao.getTrackId(
            tsParser.getTrack().getArtist().getName(), tsParser.getTrack().getName());

    playlistGeneratorDao.updateSearchIndex();
    List<PlaylistItem> ts = playlistGeneratorDao.getPlaylistForTrack(trackId);

    Assert.assertNotNull(ts);
    Assert.assertEquals(2, ts.size());
  }
コード例 #2
0
  private void logWebserviceInvocation(WebserviceInvocation wi, Date invocationTime) {
    StringBuilder sql =
        new StringBuilder(
            "delete from library.webservice_history where calltype_id = "
                + wi.getCallType().getDatabaseId());

    Integer artistId = null,
        trackId = null,
        albumId = null,
        userId = null,
        groupId = null,
        tagId = null;
    if (wi.getTrack() != null) {
      sql.append(" and track_id = " + (trackId = musicDao.getTrackId(wi.getTrack())));
    } else if (wi.getAlbum() != null) {
      sql.append(" and album_id = " + (albumId = musicDao.getAlbumId(wi.getAlbum())));
    } else if (wi.getArtist() != null) {
      sql.append(" and artist_id = " + (artistId = musicDao.getArtistId(wi.getArtist())));
    } else if (wi.getUser() != null) {
      sql.append(
          " and lastfmuser_id = "
              + (userId = lastFmDao.getLastFmUserId(wi.getUser().getLastFmUsername())));
    } else if (wi.getGroup() != null) {
      sql.append(
          " and lastfmgroup_id = "
              + (groupId = lastFmDao.getLastFmGroupId(wi.getGroup().getName())));
    } else if (wi.getTag() != null) {
      sql.append(" and tag_id = " + (tagId = wi.getTag().getId()));
    }
    if (wi.getPage() != null) sql.append(" and page = " + wi.getPage());

    jdbcTemplate.update(sql.toString());
    jdbcTemplate.update(
        "insert into library.webservice_history"
            + " (artist_id, album_id, track_id, lastfmuser_id, lastfmgroup_id,"
            + " tag_id, calltype_id, page, invocation_time)"
            + " values (?, ?, ?, ?, ?, ?, ?, ?, ?)",
        artistId,
        albumId,
        trackId,
        userId,
        groupId,
        tagId,
        wi.getCallType().getDatabaseId(),
        wi.getPage(),
        invocationTime);
  }