annotate gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java @ 32:0f4362d75e9e

Adding StatisticsOutput to the GUI gnv/trunk@142 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Mon, 28 Sep 2009 09:36:02 +0000
parents 07e9c137a2f1
children 25fdec8b4c69
rev   line source
12
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 *
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 */
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 package de.intevation.gnv.action;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6 import java.util.ArrayList;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 import java.util.Collection;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8 import java.util.Iterator;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10 import javax.servlet.http.HttpServletRequest;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 import javax.servlet.http.HttpServletResponse;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 import org.apache.log4j.Logger;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 import org.apache.struts.action.ActionForm;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 import org.apache.struts.action.ActionForward;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 import org.apache.struts.action.ActionMapping;
18
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
17 import org.w3c.dom.Node;
12
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 import de.intevation.gnv.action.sessionmodel.SessionModel;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
32
0f4362d75e9e Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
24 import de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticValue;
12
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25 import de.intevation.gnv.artifactdatabase.objects.DefaultInputParameter;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26 import de.intevation.gnv.artifactdatabase.objects.InputParameter;
18
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
27 import de.intevation.gnv.util.XMLUtils;
12
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 import de.intevation.gnv.util.XSLTransformer;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 /**
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 * @author Tim Englich <tim.englich@intevation.de>
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 *
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 */
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 public class NextArtifactStepAction extends ArtifactDatabaseActionBase {
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 /**
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 * the logger, used to log exceptions and additonaly information
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 */
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 private static Logger log = Logger.getLogger(SelectArtifactFactoryAction.class);
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 /**
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 * Constructor
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 */
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 public NextArtifactStepAction() {
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 super();
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 }
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 /**
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 */
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 @Override
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 public ActionForward execute(ActionMapping mapping, ActionForm form,
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 HttpServletRequest request, HttpServletResponse response)
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 throws Exception {
24
ec56ef8f3e58 Configurable logging integrated in the Web-Application
Tim Englich <tim.englich@intevation.de>
parents: 22
diff changeset
54 log.debug("NextArtifactStepAction.execute");
12
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 24
diff changeset
56 ArtifactDescription ad = sm.getArtifactDescription();
12
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 Collection<String> inputParameter = ad.getInputParameter();
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 Collection<InputParameter> ips = null;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 if (inputParameter != null){
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 ips = new ArrayList<InputParameter>(inputParameter.size());
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 Iterator<String> it = inputParameter.iterator();
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 while (it.hasNext()){
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 String name = it.next();
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 String[] values = request.getParameterValues(name);
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 InputParameter ip = new DefaultInputParameter(name, values);
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 ips.add(ip);
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 }
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 }
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient();
13
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
70 if (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty()){
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
71 // TODO: Woher kommt der zu erreichende Status;
19
1557bea6cb55 Do some Imporvements for Userfriendly exceptionhandling.
Tim Englich <tim.englich@intevation.de>
parents: 18
diff changeset
72 String target = null;
1557bea6cb55 Do some Imporvements for Userfriendly exceptionhandling.
Tim Englich <tim.englich@intevation.de>
parents: 18
diff changeset
73 if (ad.getReachableStates().size() > 1){
1557bea6cb55 Do some Imporvements for Userfriendly exceptionhandling.
Tim Englich <tim.englich@intevation.de>
parents: 18
diff changeset
74 target = request.getParameter("product"); // TODO HACK for Propducts every other Step has currently only one reachable state.
1557bea6cb55 Do some Imporvements for Userfriendly exceptionhandling.
Tim Englich <tim.englich@intevation.de>
parents: 18
diff changeset
75 }else{
1557bea6cb55 Do some Imporvements for Userfriendly exceptionhandling.
Tim Englich <tim.englich@intevation.de>
parents: 18
diff changeset
76 target = ad.getReachableStates().iterator().next();
1557bea6cb55 Do some Imporvements for Userfriendly exceptionhandling.
Tim Englich <tim.englich@intevation.de>
parents: 18
diff changeset
77 }
13
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
78
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
79 ArtifactDescription artifactDescription = adc.doNextStep(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), target, ips);
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
80
18
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
81 Node currentUI = artifactDescription.getCurrentUI();
13
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
82 XSLTransformer transformer = new XSLTransformer();
18
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
83 String ui = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "dynamic"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui.xsl"));
13
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
84
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
85 request.setAttribute("ui", ui);
17
d7e5a929fc34 Some Stylingimprovements done
Tim Englich <tim.englich@intevation.de>
parents: 13
diff changeset
86
18
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
87 String staticUI = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "static"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui-static.xsl"));
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
88 request.setAttribute("staticui", staticUI);
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
89
17
d7e5a929fc34 Some Stylingimprovements done
Tim Englich <tim.englich@intevation.de>
parents: 13
diff changeset
90 request.setAttribute("furthertargets", (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty()));
d7e5a929fc34 Some Stylingimprovements done
Tim Englich <tim.englich@intevation.de>
parents: 13
diff changeset
91
13
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
92 }else{
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
93
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
94 adc.doFeed(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), ips);
22
367a00e4b9ad Some GUI-Improvements done
Tim Englich <tim.englich@intevation.de>
parents: 19
diff changeset
95
367a00e4b9ad Some GUI-Improvements done
Tim Englich <tim.englich@intevation.de>
parents: 19
diff changeset
96 request.setAttribute("diagramm", true);
13
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
97
32
0f4362d75e9e Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
98 // statistic abholen und in das sessionmodell schreiben.
0f4362d75e9e Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
99
0f4362d75e9e Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
100 Collection<ArtifactStatisticValue> statistics = adc.calculateStatistics(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact());
0f4362d75e9e Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
101 sm.setStatistics(statistics);
0f4362d75e9e Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
102
17
d7e5a929fc34 Some Stylingimprovements done
Tim Englich <tim.englich@intevation.de>
parents: 13
diff changeset
103 ArtifactDescription artifactDescription = adc.getCurrentStepDescription(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact());
d7e5a929fc34 Some Stylingimprovements done
Tim Englich <tim.englich@intevation.de>
parents: 13
diff changeset
104
18
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
105 Node currentUI = artifactDescription.getCurrentUI();
17
d7e5a929fc34 Some Stylingimprovements done
Tim Englich <tim.englich@intevation.de>
parents: 13
diff changeset
106 XSLTransformer transformer = new XSLTransformer();
18
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
107 String ui = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "dynamic"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui.xsl"));
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
108
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
109 request.setAttribute("ui", ui);
17
d7e5a929fc34 Some Stylingimprovements done
Tim Englich <tim.englich@intevation.de>
parents: 13
diff changeset
110
18
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
111 String staticUI = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "static"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui-static.xsl"));
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
112 request.setAttribute("staticui", staticUI);
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
113
17
d7e5a929fc34 Some Stylingimprovements done
Tim Englich <tim.englich@intevation.de>
parents: 13
diff changeset
114 request.setAttribute("furthertargets",false);
13
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
115 }
12
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
116
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
117 return super.execute(mapping, form, request, response);
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
118 }
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
119
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
120
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
121 }

http://dive4elements.wald.intevation.org