Oracle WebCenter Analytics Development Guide

     Previous Next  Open TOC in new window   View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Querying Oracle WebCenter Analytics and Displaying Statistics

To retrieve data from the Analytics database for custom reports, use SQL.

To define or determine table and column names, go to the Event Registration page of Analytics Administration (see Defining Your Event Model). For descriptions of the tables that are delivered with Analytics, see the Oracle WebCenter Analytics Database Schema. In this sample application, the "View Events!" button opens a JSP page with a pie chart that shows the percentage of clicks by page name or event method. The query to the Analytics database is handled in the same servlet that raises the Go to My Demo Page! event. The sample application uses a JFreeCharts dataset producer to iterate over the data. The JSP page that displays the pie charts uses cewolf tags to render the data from the JFreeCharts dataset producer.
/**
* View "demo event" data using JFreeCharts and cewolf tag libraries.
*
* @param req HttpServletRequest
* @param res HttpServletResponse
*/

public void viewEvents(HttpServletRequest req, HttpServletResponse res) 
throws IOException, ServletException {
try {
	Connection conn = getDatabaseConnection();
	Statement stmt = conn.createStatement();
	String query = "";

		if ("EVENT_METHOD".equals(req.getParameter("groupby"))) {
			// group by eventMethod
		query = "select count(*), method.value " + "from ascfact_demo_event fact, ascdim_page_name page, ascdim_event_method method " + "where fact.page_name = page.id and fact.event_method = method.id " + "group by method.value";
		req.getSession().setAttribute("GROUP_BY_CHECKED", "EVENT_METHOD"); 

		} else {
			// group by pageName
		query = "select count(*), page.value " + "from ascfact_demo_event fact, ascdim_page_name page, ascdim_event_method method " + "where fact.page_name = page.id and fact.event_method = method.id " + "group by page.value";
		req.getSession().setAttribute("GROUP_BY_CHECKED", "PAGE_NAME"); 
	}

	// execute the query
	ResultSet results = stmt.executeQuery(query);

	// create a JFreeChart DatasetProducer which will be rendered by the cewolf tag library
	DatasetProducer datasource = new PieChartDatasetProducer(results);
	req.setAttribute("datasource", datasource);

	// close database resources
	results.close();
	stmt.close();
	conn.close();

} catch (Exception e) {
e.printStackTrace();
throw new ServletException("Exception while creating DatasetProducer - " + e);
}

RequestDispatcher dis = req.getRequestDispatcher("demo_chart.jsp"); 
dis.forward(req, res);
}</p>

(Analytics includes a collection of standard reports that display portal events; for details, see the Administrator Guide for Oracle WebCenter Analytics.)

For more information on querying the Analytics database from custom applications, see the next section, About the Oracle WebCenter Analytics Query API .


  Back to Top      Previous Next