use of com.github.hakko.musiccabinet.domain.model.music.MBArtist in project musiccabinet by hakko.
the class ArtistQueryParserTest method emptyResourceFileCorrectlyParsed.
@Test
public void emptyResourceFileCorrectlyParsed() throws ApplicationException {
ArtistQueryParser parser = new ArtistQueryParserImpl(new ResourceUtil(ARTIST_QUERY_EMPTY_FILE).getInputStream());
MBArtist artist = parser.getArtist();
assertNull(artist);
}
use of com.github.hakko.musiccabinet.domain.model.music.MBArtist in project musiccabinet by hakko.
the class ArtistQueryParserTest method resourceFileCorrectlyParsed.
@Test
public void resourceFileCorrectlyParsed() throws ApplicationException {
ArtistQueryParser parser = new ArtistQueryParserImpl(new ResourceUtil(ARTIST_QUERY_FILE).getInputStream());
MBArtist artist = parser.getArtist();
assertEquals(MBID, artist.getMbid());
assertEquals(NAME, artist.getName());
assertEquals(COUNTRY_CODE, artist.getCountryCode());
assertEquals(START_YEAR, artist.getStartYear());
assertEquals(ACTIVE, artist.isActive());
}
use of com.github.hakko.musiccabinet.domain.model.music.MBArtist in project musiccabinet by hakko.
the class ArtistQueryParserTest method dateGetsStoredAsYearOnly.
@Test
public void dateGetsStoredAsYearOnly() throws ApplicationException {
ArtistQueryParser parser = new ArtistQueryParserImpl(new ResourceUtil(ARTIST_QUERY_DATE_FILE).getInputStream());
MBArtist artist = parser.getArtist();
assertEquals(YEAR_PART, artist.getStartYear());
}
use of com.github.hakko.musiccabinet.domain.model.music.MBArtist in project musiccabinet by hakko.
the class MusicBrainzService method updateArtistIds.
protected void updateArtistIds() {
List<Artist> missingArtists = artistDao.getMissingArtists();
List<MBArtist> mbArtists = new ArrayList<>();
mbids = missingArtists.size();
for (Artist artist : artistDao.getMissingArtists()) {
try {
StringUtil response = new StringUtil(artistQueryClient.get(artist.getName()));
ArtistQueryParser parser = new ArtistQueryParserImpl(response.getInputStream());
if (parser.getArtist() != null) {
mbArtists.add(parser.getArtist());
if (mbArtists.size() > 100) {
artistDao.createArtists(mbArtists);
mbArtists.clear();
}
}
++mbid;
} catch (ApplicationException e) {
LOG.warn("Couldn't read mbid for " + artist.getName(), e);
}
}
artistDao.createArtists(mbArtists);
}
use of com.github.hakko.musiccabinet.domain.model.music.MBArtist in project musiccabinet by hakko.
the class MusicBrainzService method updateArtistDiscographies.
protected void updateArtistDiscographies() {
List<MBArtist> outdatedArtists = artistDao.getOutdatedArtists();
List<MBRelease> mbReleases = new ArrayList<>();
ReleaseParser parser;
discographies = outdatedArtists.size();
for (MBArtist artist : outdatedArtists) {
try {
int offset = 0;
do {
StringUtil response = new StringUtil(releaseClient.get(artist.getName(), artist.getMbid(), offset));
parser = new ReleaseParserImpl(response.getInputStream());
for (MBRelease album : parser.getReleases()) {
album.setArtistId(artist.getId());
}
mbReleases.addAll(parser.getReleases());
offset += 100;
} while (offset < parser.getTotalReleases());
++discography;
if (mbReleases.size() > 1000) {
albumDao.createAlbums(mbReleases);
mbReleases.clear();
}
} catch (ApplicationException e) {
LOG.warn("Couldn't read discography for " + artist.getName(), e);
}
}
albumDao.createAlbums(mbReleases);
}
Aggregations