Search in sources :

Example 6 with MBArtist

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();
}
Also used : MBArtist(com.github.hakko.musiccabinet.domain.model.music.MBArtist) SqlParameter(org.springframework.jdbc.core.SqlParameter) BatchSqlUpdate(org.springframework.jdbc.object.BatchSqlUpdate)

Example 7 with MBArtist

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();
}
Also used : MBArtist(com.github.hakko.musiccabinet.domain.model.music.MBArtist)

Example 8 with MBArtist

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());
}
Also used : MBArtist(com.github.hakko.musiccabinet.domain.model.music.MBArtist) Test(org.junit.Test)

Aggregations

MBArtist (com.github.hakko.musiccabinet.domain.model.music.MBArtist)8 Test (org.junit.Test)4 ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)3 ApplicationException (com.github.hakko.musiccabinet.exception.ApplicationException)2 StringUtil (com.github.hakko.musiccabinet.util.StringUtil)2 ArrayList (java.util.ArrayList)2 Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)1 MBRelease (com.github.hakko.musiccabinet.domain.model.music.MBRelease)1 ArtistQueryParser (com.github.hakko.musiccabinet.parser.musicbrainz.ArtistQueryParser)1 ArtistQueryParserImpl (com.github.hakko.musiccabinet.parser.musicbrainz.ArtistQueryParserImpl)1 ReleaseParser (com.github.hakko.musiccabinet.parser.musicbrainz.ReleaseParser)1 ReleaseParserImpl (com.github.hakko.musiccabinet.parser.musicbrainz.ReleaseParserImpl)1 SqlParameter (org.springframework.jdbc.core.SqlParameter)1 BatchSqlUpdate (org.springframework.jdbc.object.BatchSqlUpdate)1