Search in sources :

Example 21 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class JdbcArtistInfoDaoTest method bioContentIsExposedInDetailedArtistInfo.

@Test
public void bioContentIsExposedInDetailedArtistInfo() {
    deleteArtistInfos();
    int tinaId = musicDao.getArtistId(aiTina.getArtist());
    dao.createArtistInfo(Arrays.asList(aiTina));
    ArtistInfo artistInfo = dao.getDetailedArtistInfo(tinaId);
    Assert.assertNotNull(artistInfo);
    Assert.assertNotNull(artistInfo.getArtist());
    Assert.assertNotNull(artistInfo.getBioContent());
    Assert.assertEquals("Tina Turner", artistInfo.getArtist().getName());
    Assert.assertEquals("http://userserve-ak.last.fm/serve/126/74998404.jpg", artistInfo.getLargeImageUrl());
    Assert.assertTrue(artistInfo.getBioContent().startsWith("<strong>Tina Turner</strong>"));
}
Also used : ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) Test(org.junit.Test)

Example 22 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class JdbcArtistInfoDao method batchInsert.

private void batchInsert(List<ArtistInfo> artistInfos) {
    String sql = "insert into music.artistinfo_import (artist_name, smallimageurl, mediumimageurl, largeimageurl, extralargeimageurl, listeners, playcount, biosummary, biocontent) values (?,?,?,?,?,?,?,?,?)";
    BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
    batchUpdate.setBatchSize(1000);
    batchUpdate.declareParameter(new SqlParameter("artist_name", Types.VARCHAR));
    batchUpdate.declareParameter(new SqlParameter("smallImageUrl", Types.VARCHAR));
    batchUpdate.declareParameter(new SqlParameter("mediumImageUrl", Types.VARCHAR));
    batchUpdate.declareParameter(new SqlParameter("largeImageUrl", Types.VARCHAR));
    batchUpdate.declareParameter(new SqlParameter("extraLargeImageUrl", Types.VARCHAR));
    batchUpdate.declareParameter(new SqlParameter("listeners", Types.INTEGER));
    batchUpdate.declareParameter(new SqlParameter("playcount", Types.INTEGER));
    batchUpdate.declareParameter(new SqlParameter("biosummary", Types.VARCHAR));
    batchUpdate.declareParameter(new SqlParameter("biocontent", Types.VARCHAR));
    for (ArtistInfo ai : artistInfos) {
        batchUpdate.update(new Object[] { ai.getArtist().getName(), ai.getSmallImageUrl(), ai.getMediumImageUrl(), ai.getLargeImageUrl(), ai.getExtraLargeImageUrl(), ai.getListeners(), ai.getPlayCount(), ai.getBioSummary(), ai.getBioContent() });
    }
    batchUpdate.flush();
}
Also used : SqlParameter(org.springframework.jdbc.core.SqlParameter) BatchSqlUpdate(org.springframework.jdbc.object.BatchSqlUpdate) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)

Aggregations

ArtistInfo (com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)22 Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)11 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)7 File (com.github.hakko.musiccabinet.domain.model.library.File)5 ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)4 UnittestLibraryUtil.getFile (com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile)4 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 HashSet (java.util.HashSet)3 Before (org.junit.Before)3 ArtistInfoParserImpl (com.github.hakko.musiccabinet.parser.lastfm.ArtistInfoParserImpl)2 TagTopArtists (com.github.hakko.musiccabinet.domain.model.aggr.TagTopArtists)1 UserRecommendedArtists (com.github.hakko.musiccabinet.domain.model.aggr.UserRecommendedArtists)1 RecommendedArtist (com.github.hakko.musiccabinet.domain.model.aggr.UserRecommendedArtists.RecommendedArtist)1 UserTopArtists (com.github.hakko.musiccabinet.domain.model.aggr.UserTopArtists)1 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)1 Period (com.github.hakko.musiccabinet.domain.model.library.Period)1 Album (com.github.hakko.musiccabinet.domain.model.music.Album)1 ArtistRelation (com.github.hakko.musiccabinet.domain.model.music.ArtistRelation)1