use of com.github.hakko.musiccabinet.domain.model.music.MBArtist in project musiccabinet by hakko.
the class JdbcMusicBrainzArtistDao method batchInsert.
private void batchInsert(List<MBArtist> artists) {
String sql = "insert into music.mb_artist_import (artist_name, mbid, country_code, start_year, active) values (?,?,?,?,?)";
BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
batchUpdate.setBatchSize(1000);
batchUpdate.declareParameter(new SqlParameter("artist_name", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("mbid", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("county_code", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("start_year", Types.SMALLINT));
batchUpdate.declareParameter(new SqlParameter("active", Types.BOOLEAN));
for (MBArtist artist : artists) {
batchUpdate.update(new Object[] { artist.getName(), artist.getMbid(), artist.getCountryCode(), artist.getStartYear(), artist.isActive() });
}
batchUpdate.flush();
}
use of com.github.hakko.musiccabinet.domain.model.music.MBArtist in project musiccabinet by hakko.
the class ArtistQueryHandler method startElement.
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (TAG_ARTIST.equals(qName)) {
artist = new MBArtist();
artist.setMbid(attributes.getValue(ATTR_ID));
} else if (TAG_TAGLIST.equals(qName)) {
tagList = true;
}
characterData = new StringBuilder();
}
use of com.github.hakko.musiccabinet.domain.model.music.MBArtist in project musiccabinet by hakko.
the class JdbcMusicBrainzArtistDaoTest method createsArtists.
@Test
public void createsArtists() {
artistDao.createArtists(Arrays.asList(new MBArtist(artist1.getName(), MBID, COUNTRY_CODE, START_YEAR, ACTIVE)));
MBArtist artist = artistDao.getArtist(artist1.getId());
assertEquals(artist1.getName(), artist.getName());
assertEquals(MBID, artist.getMbid());
assertEquals(COUNTRY_CODE, artist.getCountryCode());
assertEquals(START_YEAR, artist.getStartYear());
assertEquals(ACTIVE, artist.isActive());
}
Aggregations