ingo@410: package de.intevation.gnv.action; ingo@410: ingo@410: import java.util.Collection; ingo@410: ingo@410: import javax.servlet.http.HttpServletRequest; ingo@410: import javax.servlet.http.HttpServletResponse; ingo@410: ingo@410: import org.apache.log4j.Logger; ingo@410: import org.apache.struts.action.ActionForm; ingo@410: import org.apache.struts.action.ActionForward; ingo@410: import org.apache.struts.action.ActionMapping; ingo@410: tim@963: import de.intevation.gnv.action.sessionmodel.SessionModel; tim@963: import de.intevation.gnv.action.sessionmodel.SessionModelFactory; tim@963: import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient; tim@963: import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory; tim@963: import de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticsSet; tim@963: ingo@410: /** ingo@690: * This controller is used to display to statistic of the current ingo@690: * parameterization. sascha@699: * sascha@684: * @author Ingo Weinzierl ingo@410: */ ingo@410: public class ShowStatisticAction extends DescribeUIAction { ingo@410: tim@963: /** tim@963: * the logger, used to log exceptions and additonaly information tim@963: */ ingo@410: private static Logger logger = Logger.getLogger(ShowStatisticAction.class); ingo@410: ingo@410: tim@963: /** tim@963: * Constructor tim@963: */ ingo@410: public ShowStatisticAction() { ingo@410: super(); ingo@410: } ingo@410: ingo@410: ingo@410: @Override ingo@410: public ActionForward execute( ingo@410: ActionMapping mapping, ingo@410: ActionForm form, ingo@410: HttpServletRequest request, ingo@410: HttpServletResponse response ingo@410: ) throws Exception ingo@410: { ingo@991: if (isSessionExhausted(request)) { ingo@991: return sessionExhaustedForward(mapping, form, request, response); ingo@991: } ingo@991: ingo@410: logger.info("show statistic"); ingo@410: SessionModel sm = SessionModelFactory.getInstance().getSessionModel( ingo@410: request); ingo@410: ingo@410: ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance() ingo@410: .getArtifactDatabaseClient(getLocale(request)); ingo@410: ingo@410: try{ ingo@410: Collection statistics = ingo@410: adc.calculateStatistics(sm.getSelectedArtifactFactory(), ingo@410: sm.getCurrentArtifact()); ingo@410: ingo@410: sm.setStatistics(statistics); ingo@410: ingo@410: request.setAttribute("statistic", true); ingo@410: } ingo@410: catch (Exception e) { ingo@410: logger.error(e, e); ingo@410: } ingo@410: ingo@410: return super.execute(mapping, form, request, response); ingo@410: } ingo@410: } sascha@700: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :