use of com.github.hakko.musiccabinet.parser.lastfm.ArtistTopTagsParserImpl in project musiccabinet by hakko.
the class JdbcArtistTopTagsDaoTest method loadFunctionDependencyAndTestdata.
@Before
public void loadFunctionDependencyAndTestdata() throws ApplicationException {
PostgreSQLUtil.loadFunction(dao, UPDATE_ARTISTTOPTAG);
ArtistTopTagsParser cherParser = new ArtistTopTagsParserImpl(new ResourceUtil(CHER_TOP_TAGS).getInputStream());
ArtistTopTagsParser rihannaParser = new ArtistTopTagsParserImpl(new ResourceUtil(RIHANNA_TOP_TAGS).getInputStream());
cherArtist = cherParser.getArtist();
cherTopTags = cherParser.getTopTags();
rihannaArtist = rihannaParser.getArtist();
rihannaTopTags = rihannaParser.getTopTags();
PostgreSQLUtil.truncateTables(dao);
musicDao.setArtistId(cherArtist);
musicDao.setArtistId(rihannaArtist);
}
use of com.github.hakko.musiccabinet.parser.lastfm.ArtistTopTagsParserImpl in project musiccabinet by hakko.
the class ArtistTopTagsService method updateSearchIndex.
@Override
protected void updateSearchIndex() throws ApplicationException {
Set<String> artistNames = webserviceHistoryService.getArtistNamesScheduledForUpdate(ARTIST_GET_TOP_TAGS);
setTotalOperations(artistNames.size());
for (String artistName : artistNames) {
try {
WSResponse wsResponse = artistTopTagsClient.getTopTags(new Artist(artistName));
if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
ArtistTopTagsParser attParser = new ArtistTopTagsParserImpl(stringUtil.getInputStream());
removeTagsWithLowTagCount(attParser.getTopTags());
artistTopTagsDao.createTopTags(attParser.getArtist(), attParser.getTopTags());
}
} catch (ApplicationException e) {
LOG.warn("Fetching top tags for " + artistName + " failed.", e);
}
addFinishedOperation();
}
}
Aggregations