use of com.publiccms.entities.cms.CmsWord in project PublicCMS-preview by sanluan.
the class StatisticsComponent method search.
/**
* @param siteId
* @param word
* @return word statistics
*/
public CmsWordStatistics search(short siteId, String word) {
if (CommonUtils.notEmpty(word)) {
CmsWord entity = wordService.getEntity(siteId, word);
if (null == entity) {
entity = new CmsWord();
entity.setName(word);
entity.setSiteId(siteId);
entity.setHidden(true);
wordService.save(entity);
}
CmsWordStatistics wordStatistics = wordCache.get(entity.getId());
if (null == wordStatistics) {
wordStatistics = new CmsWordStatistics(entity.getId(), 1, entity);
} else {
wordStatistics.setSearchCounts(wordStatistics.getSearchCounts() + 1);
}
List<CmsWordStatistics> list = wordCache.put(entity.getId(), wordStatistics);
if (CommonUtils.notEmpty(list)) {
wordService.updateStatistics(list);
}
return wordStatistics;
} else {
return null;
}
}
Aggregations