use of com.github.hakko.musiccabinet.domain.model.music.TagInfo in project musiccabinet by hakko.
the class TagInfoParserTest method resourceFileCorrectlyParsed.
@Test
public void resourceFileCorrectlyParsed() throws ApplicationException {
TagInfoParser parser = new TagInfoParserImpl(new ResourceUtil(TAG_INFO_FILE).getInputStream());
TagInfo tagInfo = parser.getTagInfo();
Assert.assertEquals(NAME, tagInfo.getTagName());
Assert.assertEquals(SUMMARY, tagInfo.getSummary());
Assert.assertEquals(CONTENT, tagInfo.getContent());
}
use of com.github.hakko.musiccabinet.domain.model.music.TagInfo in project musiccabinet by hakko.
the class JdbcTagInfoDao method createTagInfo.
@Override
public void createTagInfo(List<TagInfo> tagInfos) {
String sql = "insert into music.taginfo_import (tag_name, summary, content) values (?,?,?)";
BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
batchUpdate.setBatchSize(1000);
batchUpdate.declareParameter(new SqlParameter("tag_name", VARCHAR));
batchUpdate.declareParameter(new SqlParameter("summary", VARCHAR));
batchUpdate.declareParameter(new SqlParameter("content", VARCHAR));
for (TagInfo ti : tagInfos) {
batchUpdate.update(new Object[] { ti.getTagName(), ti.getSummary(), ti.getContent() });
}
batchUpdate.flush();
jdbcTemplate.execute("select music.update_taginfo()");
}
use of com.github.hakko.musiccabinet.domain.model.music.TagInfo 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);
}
use of com.github.hakko.musiccabinet.domain.model.music.TagInfo in project musiccabinet by hakko.
the class TagInfoHandler method endElement.
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
String chars = characterData.toString();
if (TAG_NAME.equals(qName)) {
tagInfo = new TagInfo();
tagInfo.setTagName(chars);
} else if (TAG_SUMMARY.equals(qName)) {
tagInfo.setSummary(chars);
} else if (TAG_CONTENT.equals(qName)) {
tagInfo.setContent(chars);
}
}
Aggregations