Search in sources :

Example 1 with GeminiChartUtil

use of com.geminimobile.chart.GeminiChartUtil in project logprocessing by cloudian.

the class GeminiChartController method handleRequestInternal.

//This controller linked to by an img control on gemstats.jsp (message stats reporting page).
//Call the JFreeChart tool to generate the chart. The result goes into the OutputStream.
//Only cummulative-type reports use this controller - not snapshot-type.
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    // The data to be reported on this chart was put in the session by GenerateGemStatsController
    // Example of query string is: 
    //    tableTitleText=MM3 Messages Sent by Hour for Service Provider 1111 for Vasp 4444&intervalText=Hour&messageType=MM3.MPS;
    List<ChartSeries> chartData = (List<ChartSeries>) request.getSession(true).getAttribute("chartData");
    String chartTitle = (String) request.getParameter("chartTitle");
    String intervalText = (String) request.getParameter("intervalText");
    try {
        response.setContentType("image/png");
        if (chartData != null && chartData.size() > 0) {
            //Create the chart with chart tool
            GeminiChartUtil chartUtil = new GeminiChartUtil();
            // chartData - are the data points themselves- ex. [<number>, <time interval>]
            // tableTitleText - is displayed as the chart's title. Ex. "MM3 Msgs Sent for Service Provider 1111 and Vasp 6543"
            // intervalText - displayed as part of the X-Axis label. Ex. "Hour"
            chartUtil.createReport(response.getOutputStream(), chartData, chartTitle, intervalText);
        }
    // write data to CSV file
    //        System.out.println("GCC Calling CSV generation");
    //        GemStatsCSVGeneration csvGeneration = new GemStatsCSVGeneration();
    //        String csvData = csvGeneration.generateCSV(chartData, messageType);
    //        request.getSession().setAttribute(CSVDATA,csvData);  // set in session for csv file data
    } catch (Exception e) {
        e.printStackTrace();
        throw new ServletException("Could not get statistic values.  Probably a Database issue");
    }
    return null;
}
Also used : ServletException(javax.servlet.ServletException) GeminiChartUtil(com.geminimobile.chart.GeminiChartUtil) List(java.util.List) ChartSeries(com.geminimobile.chart.ChartSeries) ServletException(javax.servlet.ServletException)

Aggregations

ChartSeries (com.geminimobile.chart.ChartSeries)1 GeminiChartUtil (com.geminimobile.chart.GeminiChartUtil)1 List (java.util.List)1 ServletException (javax.servlet.ServletException)1