@RequestParam(value = "period", required = false) String period,
HttpServletRequest request, HttpServletResponse response)
throws JsonGenerationException, JsonMappingException, IOException {
try {
final Map<String, Object> jsonResponse = new HashMap<String, Object>();
final HashTagStatsBean tagStatsBean = new HashTagStatsBean();
final TypeSearchResult filterType = TypeSearchResult.getTypeSearchResult(filter);
final SearchPeriods searchPeriod = SearchPeriods.getPeriodString(period);
if (filterType == null) {
throw new EnMeNoResultsFoundException("type not found");
} else {
if (filterType.equals(TypeSearchResult.HASHTAGRATED)) {
// hits /period
tagStatsBean.setTotalHits(getStatisticsService().getHashTagHitsbyName(tagName,
filterType, request, searchPeriod));
tagStatsBean.getTotalHits().setTypeSearchResult(TypeSearchResult.HITS);
// social network use /period
tagStatsBean.setTotalUsageBySocialNetwork(getStatisticsService()
.getSocialNetworkUseByHashTag(tagName, this.INIT_RESULTS,
null, request, searchPeriod));
tagStatsBean.getTotalUsageBySocialNetwork().setTypeSearchResult(TypeSearchResult.SOCIALNETWORK);
// usage by / period
tagStatsBean.setUsageByItem(getStatisticsService().getTotalUsageByHashTag(tagName,
this.INIT_RESULTS, null, filterType, request, searchPeriod
));
tagStatsBean.getUsageByItem().setTypeSearchResult(TypeSearchResult.HASHTAG);
// votes
tagStatsBean.setUsageByVotes(getStatisticsService().getHashTagUsedOnItemsVoted(tagName,
this.INIT_RESULTS, null, request, searchPeriod));
tagStatsBean.getUsageByVotes().setTypeSearchResult(TypeSearchResult.VOTES);
jsonResponse.put("hashTagButtonStats", tagStatsBean);
setItemResponse(jsonResponse);
} else {
setError("filter not valid", response);
}