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>"));
}
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();
}
Aggregations