コード例 #1
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);
  }
コード例 #2
0
  private int prepareTestdataForArtist() throws ApplicationException {
    ArtistSimilarityParser asParser =
        new ArtistSimilarityParserImpl(new ResourceUtil(CHER_SIMILAR_ARTISTS).getInputStream());
    artistRelationDao.createArtistRelations(asParser.getArtist(), asParser.getArtistRelations());

    ArtistTopTracksParser attParser =
        new ArtistTopTracksParserImpl(new ResourceUtil(CHER_TOP_TRACKS).getInputStream());
    artistTopTracksDao.createTopTracks(attParser.getArtist(), attParser.getTopTracks());

    List<File> files = new ArrayList<>();
    for (Track topTrack : attParser.getTopTracks()) {
      files.add(UnittestLibraryUtil.getFile(topTrack));
    }
    UnittestLibraryUtil.submitFile(additionDao, files);

    int artistId = musicDao.getArtistId(asParser.getArtist());

    playlistGeneratorDao.updateSearchIndex();

    return artistId;
  }