Search in sources :

Example 1 with TagInfoParser

use of com.github.hakko.musiccabinet.parser.lastfm.TagInfoParser in project musiccabinet by hakko.

the class TagInfoService method updateSearchIndex.

@Override
protected void updateSearchIndex() throws ApplicationException {
    List<TagInfo> tagInfos = new ArrayList<>();
    Set<String> tags = getTagsForUpdate();
    setTotalOperations(tags.size());
    for (String tag : tags) {
        WSResponse wsResponse = tagInfoClient.getTagInfo(tag, lastFmSettingsService.getLang());
        if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
            StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
            TagInfoParser tiParser = new TagInfoParserImpl(stringUtil.getInputStream());
            tagInfos.add(tiParser.getTagInfo());
        }
        addFinishedOperation();
    }
    tagInfoDao.createTagInfo(tagInfos);
}
Also used : TagInfoParser(com.github.hakko.musiccabinet.parser.lastfm.TagInfoParser) TagInfo(com.github.hakko.musiccabinet.domain.model.music.TagInfo) ArrayList(java.util.ArrayList) TagInfoParserImpl(com.github.hakko.musiccabinet.parser.lastfm.TagInfoParserImpl) WSResponse(com.github.hakko.musiccabinet.ws.lastfm.WSResponse) StringUtil(com.github.hakko.musiccabinet.util.StringUtil)

Aggregations

TagInfo (com.github.hakko.musiccabinet.domain.model.music.TagInfo)1 TagInfoParser (com.github.hakko.musiccabinet.parser.lastfm.TagInfoParser)1 TagInfoParserImpl (com.github.hakko.musiccabinet.parser.lastfm.TagInfoParserImpl)1 StringUtil (com.github.hakko.musiccabinet.util.StringUtil)1 WSResponse (com.github.hakko.musiccabinet.ws.lastfm.WSResponse)1 ArrayList (java.util.ArrayList)1