annotate gnv/src/main/java/de/intevation/gnv/action/ShowStatisticAction.java @ 410:9602f4bffc07

Added statistic to the actions if available. gnv/trunk@604 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 22 Jan 2010 13:58:30 +0000
parents
children d49e8695786c
rev   line source
410
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.action;
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.util.Collection;
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import javax.servlet.http.HttpServletRequest;
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import javax.servlet.http.HttpServletResponse;
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import org.apache.log4j.Logger;
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import org.apache.struts.action.ActionForm;
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import org.apache.struts.action.ActionForward;
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import org.apache.struts.action.ActionMapping;
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import de.intevation.gnv.action.sessionmodel.SessionModel;
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticsSet;
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 /**
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 */
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 public class ShowStatisticAction extends DescribeUIAction {
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 private static Logger logger = Logger.getLogger(ShowStatisticAction.class);
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 public ShowStatisticAction() {
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 super();
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 }
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 @Override
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 public ActionForward execute(
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 ActionMapping mapping,
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 ActionForm form,
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 HttpServletRequest request,
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 HttpServletResponse response
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 ) throws Exception
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 {
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 logger.info("show statistic");
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 SessionModel sm = SessionModelFactory.getInstance().getSessionModel(
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 request);
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance()
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 .getArtifactDatabaseClient(getLocale(request));
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 try{
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 Collection<ArtifactStatisticsSet> statistics =
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 adc.calculateStatistics(sm.getSelectedArtifactFactory(),
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 sm.getCurrentArtifact());
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 sm.setStatistics(statistics);
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 request.setAttribute("statistic", true);
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 }
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 catch (Exception e) {
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 logger.error(e, e);
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 }
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 return super.execute(mapping, form, request, response);
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 }
9602f4bffc07 Added statistic to the actions if available.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 }

http://dive4elements.wald.intevation.org