ElasticSearchStatsViewer esStatsViewer = new ElasticSearchStatsViewer(dso, fromDate, toDate);
StatisticsTransformer statisticsTransformerInstance = new StatisticsTransformer(fromDate, toDate);
if(requestedReport.equalsIgnoreCase("topCountries"))
{
SearchRequestBuilder requestBuilder = esStatsViewer.facetedQueryBuilder(esStatsViewer.facetTopCountries);
SearchResponse searchResponse = requestBuilder.execute().actionGet();
TermsFacet topCountriesFacet = searchResponse.getFacets().facet(TermsFacet.class, "top_countries");
addTermFacetToWriter(topCountriesFacet, "");
}
else if (requestedReport.equalsIgnoreCase("fileDownloads"))
{
SearchRequestBuilder requestBuilder = esStatsViewer.facetedQueryBuilder(esStatsViewer.facetMonthlyDownloads);
SearchResponse searchResponse = requestBuilder.execute().actionGet();
DateHistogramFacet monthlyDownloadsFacet = searchResponse.getFacets().facet(DateHistogramFacet.class, "monthly_downloads");
addDateHistogramFacetToWriter(monthlyDownloadsFacet);
}
else if(requestedReport.equalsIgnoreCase("topDownloads"))
{
SearchRequestBuilder requestBuilder = esStatsViewer.facetedQueryBuilder(esStatsViewer.facetTopBitstreamsAllTime);
SearchResponse searchResponse = requestBuilder.execute().actionGet();
log.info(searchResponse.toString());
TermsFacet topBitstreams = searchResponse.getFacets().facet(TermsFacet.class, "top_bitstreams_alltime");
addTermFacetToWriter(topBitstreams, "bitstream");
}