use of com.xpn.xwiki.store.XWikiHibernateStore in project xwiki-platform by xwiki.
the class XWikiStatsReader method getDocumentStatistics.
/**
* Retrieves document statistics.
*
* @param action the action the results should be ordered by. It can be one of: "view", "save" or "download". If the
* action is "view" then the documents are ordered by the number of times they have been viewed so far.
* @param scope the set of documents for which to retrieve statistics.
* @param period the period of time, including its start date but excluding its end date.
* @param range the sub-range to return from the entire result set. Use this parameter for pagination.
* @param context the XWiki context.
* @return A list of DocumentStats objects
*/
public List<DocumentStats> getDocumentStatistics(String action, Scope scope, Period period, Range range, XWikiContext context) {
List<DocumentStats> documentStatsList;
List<Object> paramList = new ArrayList<Object>(4);
String nameFilter = getHqlNameFilterFromScope(scope, paramList);
String sortOrder = getHqlSortOrderFromRange(range);
XWikiHibernateStore store = context.getWiki().getHibernateStore();
try {
String query = MessageFormat.format("select name, sum(pageViews) from DocumentStats" + " where ({0}) and action=? and ? <= period and period < ? group by name order" + " by sum(pageViews) {1}", nameFilter, sortOrder);
paramList.add(action);
paramList.add(period.getStartCode());
paramList.add(period.getEndCode());
List<?> solist = store.search(query, range.getAbsoluteSize(), range.getAbsoluteStart(), paramList, context);
documentStatsList = getDocumentStatistics(solist, action);
if (range.getSize() < 0) {
Collections.reverse(documentStatsList);
}
} catch (XWikiException e) {
documentStatsList = Collections.emptyList();
}
return documentStatsList;
}
use of com.xpn.xwiki.store.XWikiHibernateStore in project xwiki-platform by xwiki.
the class XWikiStatsReader method getVisitStatistics.
/**
* Retrieves visit statistics.
*
* @param action the action the results should be ordered by. It can be one of: "view", "save" or "download". If the
* action is "view" then the visitors are ordered by the number of pages they have viewed so far.
* @param period the period of time, including its start date but excluding its end date.
* @param range the sub-range to return from the entire result set. Use this parameter for pagination.
* @param context the XWiki context.
* @return a list of VisitStats objects.
*/
public List<VisitStats> getVisitStatistics(String action, Period period, Range range, XWikiContext context) {
List<VisitStats> visiStatList;
List<Object> paramList = new ArrayList<Object>(2);
String query = createVisitStatisticsQuery(action, period, range, paramList, context);
XWikiHibernateStore store = context.getWiki().getHibernateStore();
try {
List<?> solist = store.search(query, range.getAbsoluteSize(), range.getAbsoluteStart(), paramList, context);
visiStatList = getVisitStatistics(solist, new DateTime(period.getStart()), new DateTime(period.getEnd()));
if (range.getSize() < 0) {
Collections.reverse(visiStatList);
}
} catch (XWikiException e) {
LOGGER.error("Faild to search for vist statistics", e);
visiStatList = Collections.emptyList();
}
return visiStatList;
}
use of com.xpn.xwiki.store.XWikiHibernateStore in project xwiki-platform by xwiki.
the class XWikiStatsReader method getRefererStatistics.
/**
* Retrieves referrer statistics.
*
* @param domain the domain for which to retrieve statistics. To retrieve statistics for all domains use the empty
* string.
* @param scope the scope of referred documents to use for filtering the results.
* @param period the period of time, including its start date but excluding its end date.
* @param range the sub-range to return from the entire result set. Use this parameter for pagination.
* @param context the XWiki context.
* @return a list of RefererStats objects.
*/
public List<RefererStats> getRefererStatistics(String domain, Scope scope, Period period, Range range, XWikiContext context) {
List<RefererStats> refererList;
List<Object> paramList = new ArrayList<Object>(4);
String nameFilter = getHqlNameFilterFromScope(scope, paramList);
String sortOrder = getHqlSortOrderFromRange(range);
XWikiHibernateStore store = context.getWiki().getHibernateStore();
try {
String query = MessageFormat.format("select referer, sum(pageViews) from RefererStats" + " where ({0}) and referer like ? and ? <= period and period < ?" + " group by referer order by sum(pageViews) {1}", nameFilter, sortOrder);
paramList.add(getHqlValidDomain(domain));
paramList.add(period.getStartCode());
paramList.add(period.getEndCode());
List<?> solist = store.search(query, range.getAbsoluteSize(), range.getAbsoluteStart(), paramList, context);
refererList = getRefererStatistics(solist);
if (range.getSize() < 0) {
Collections.reverse(refererList);
}
} catch (XWikiException e) {
refererList = Collections.emptyList();
}
return refererList;
}
Aggregations