use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.
the class AlbumNameRowMapper method mapRow.
@Override
public Album mapRow(ResultSet rs, int rowNum) throws SQLException {
int artistId = rs.getInt(1);
String artistName = rs.getString(2);
int albumId = rs.getInt(3);
String albumName = rs.getString(4);
return new Album(new Artist(artistId, artistName), albumId, albumName);
}
use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.
the class ArtistInfoService method updateSearchIndex.
@Override
protected void updateSearchIndex() throws ApplicationException {
Set<String> artistNames = webserviceHistoryService.getArtistNamesScheduledForUpdate(ARTIST_GET_INFO);
List<ArtistInfo> artistInfos = new ArrayList<>(artistNames.size());
setTotalOperations(artistNames.size());
for (String artistName : artistNames) {
try {
WSResponse wsResponse = artistInfoClient.getArtistInfo(new Artist(artistName), lastFmSettingsService.getLang());
if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
ArtistInfoParser aiParser = new ArtistInfoParserImpl(stringUtil.getInputStream());
if (aiParser.getArtistInfo() != null) {
artistInfos.add(aiParser.getArtistInfo());
} else {
LOG.warn("Artist info response for " + artistName + " not parsed correctly. Response was " + wsResponse.getResponseBody());
}
if (artistInfos.size() == BATCH_SIZE) {
artistInfoDao.createArtistInfo(artistInfos);
artistInfos.clear();
}
}
} catch (ApplicationException e) {
LOG.warn("Fetching artist info for " + artistName + " failed.", e);
}
addFinishedOperation();
}
artistInfoDao.createArtistInfo(artistInfos);
}
use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.
the class ArtistRelationService method updateSearchIndex.
@Override
protected void updateSearchIndex() throws ApplicationException {
Set<String> artistNames = webserviceHistoryService.getArtistNamesScheduledForUpdate(ARTIST_GET_SIMILAR);
setTotalOperations(artistNames.size());
for (String artistName : artistNames) {
try {
WSResponse wsResponse = artistSimilarityClient.getArtistSimilarity(new Artist(artistName));
if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
ArtistSimilarityParser asParser = new ArtistSimilarityParserImpl(stringUtil.getInputStream());
artistRelationDao.createArtistRelations(asParser.getArtist(), asParser.getArtistRelations());
}
} catch (ApplicationException e) {
LOG.warn("Fetching artist relations for " + artistName + " failed.", e);
}
addFinishedOperation();
}
}
use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.
the class ArtistTopTracksService method updateSearchIndex.
@Override
protected void updateSearchIndex() throws ApplicationException {
Set<String> artistNames = webserviceHistoryService.getArtistNamesScheduledForUpdate(ARTIST_GET_TOP_TRACKS);
setTotalOperations(artistNames.size());
for (String artistName : artistNames) {
try {
WSResponse wsResponse = artistTopTracksClient.getTopTracks(new Artist(artistName));
if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
ArtistTopTracksParser attParser = new ArtistTopTracksParserImpl(stringUtil.getInputStream());
artistTopTracksDao.createTopTracks(attParser.getArtist(), attParser.getTopTracks());
}
} catch (ApplicationException e) {
LOG.warn("Fetching top tracks for " + artistName + " failed.", e);
}
addFinishedOperation();
}
}
use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.
the class ArtistTopTagsHandler method startElement.
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (TAG_TOP_TAGS.equals(qName)) {
artistName = attributes.getValue(TAG_ARTIST);
sourceArtist = new Artist(artistName);
} else if (TAG_NAME.equals(qName)) {
currentTag = new Tag();
state = NAME;
characterData = new StringBuilder();
} else if (TAG_COUNT.equals(qName)) {
state = COUNT;
characterData = new StringBuilder();
} else {
state = null;
}
}
Aggregations