Search in sources :

Example 1 with CmsWordStatistics

use of com.publiccms.views.pojo.entities.CmsWordStatistics 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;
    }
}
Also used : CmsWordStatistics(com.publiccms.views.pojo.entities.CmsWordStatistics) CmsWord(com.publiccms.entities.cms.CmsWord)

Aggregations

CmsWord (com.publiccms.entities.cms.CmsWord)1 CmsWordStatistics (com.publiccms.views.pojo.entities.CmsWordStatistics)1