/*
 * $Id: ShowStatisticsAction.java,v 1.8 2006/10/04 03:14:52 marbobo Exp $
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 *
 * $Log: ShowStatisticsAction.java,v $
 * Revision 1.8  2006/10/04 03:14:52  marbobo
 * + Vollständige Unterstützung für Templates implementiert
 * + Alles von Virtoweb auf ProCoBa umgestellt
 *
 * Revision 1.7  2006/03/23 13:40:54  marbobo
 * + Unbenutzte Imports entfernt und alle nicht verwendete Elemente auskommentiert
 *
 * Revision 1.6  2005/09/15 14:43:32  jonyp
 * reset form to current year an dmonth if no date is given
 *
 * Revision 1.5  2004/07/13 23:25:00  jonyp
 * usable version
 *
 * Revision 1.4  2004/07/06 14:40:23  jonyp
 * preliminary
 *
 * Revision 1.3  2004/06/24 23:31:12  marbobo
 * Quellcode maintenance
 *
 * Revision 1.2  2004/06/18 15:02:41  jonyp
 * added conveninces methods
 *
 * Revision 1.1  2004/06/18 07:55:18  jonyp
 * first strike
 *
  */
package vkc.statistics.action;

import java.util.Calendar;
import java.util.GregorianCalendar;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import vkc.statistics.form.ShowStatisticsForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public final class ShowStatisticsAction extends Action {

    public ActionForward execute(ActionMapping mapping, ActionForm form,
                                   HttpServletRequest request, HttpServletResponse response)
        throws Exception {       
        
        ShowStatisticsForm statisticsForm = (ShowStatisticsForm) form;
        
        if (statisticsForm.getYear() == null) {
            GregorianCalendar now = new GregorianCalendar();
            statisticsForm.setYear(new Integer(now.get(Calendar.YEAR)));
            statisticsForm.setMonth(new Integer(now.get(Calendar.MONTH) + 1));
        }
        
/*
        String chartFilename = ChartGenerator.generateTimeSeriesChart(statisticsForm.getYear(),
                                                                        statisticsForm.getMonth(),
                                                                          statisticsForm.getDay(),
                                                                            request.getSession(), 
                                                                              response.getWriter() 
                                                                           ); 
        
        statisticsForm.setChartFilename(chartFilename);
        statisticsForm.setChartURL(request.getContextPath() + "/servlet/DisplayChart?filename=" + chartFilename);
*/        
		return new ActionForward("/templates/${template.name}/statistics/showStatistics.jsp", false);		
    }
}