annotate gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java @ 573:bd67164cf28b

Devided actions and exports. Adjusted output and export actions. gnv/trunk@704 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 23 Feb 2010 17:43:16 +0000
parents f2ba58011a2d
children a634d5ee961d
rev   line source
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.action;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
3 import java.util.Collection;
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
4 import java.util.Iterator;
407
55dae5bb76db Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 389
diff changeset
5 import java.util.Map;
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
6
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 import javax.servlet.http.HttpServletRequest;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8 import javax.servlet.http.HttpServletResponse;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10 import org.apache.log4j.Logger;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 import org.apache.struts.action.ActionForm;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 import org.apache.struts.action.ActionForward;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 import org.apache.struts.action.ActionMapping;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
15 import de.intevation.gnv.action.sessionmodel.DiagrammOptions;
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 import de.intevation.gnv.action.sessionmodel.SessionModel;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17 import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
19 import de.intevation.gnv.artifactdatabase.objects.OutputMode;
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
20 import de.intevation.gnv.artifactdatabase.objects.OutputParameter;
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 /**
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 * @author Tim Englich <tim.englich@intevation.de>
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
24 *
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25 */
409
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 408
diff changeset
26 public class ChangeOptionsAction extends DescribeUIAction {
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 /**
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 * the logger, used to log exceptions and additonaly information
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 */
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 private static Logger log = Logger.getLogger(ChangeOptionsAction.class);
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
31
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 /**
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 * Constructor
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 */
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 public ChangeOptionsAction() {
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 super();
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 @Override
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 public ActionForward execute(ActionMapping mapping, ActionForm form,
38
fccf90761825 Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents: 36
diff changeset
41 HttpServletRequest request,
fccf90761825 Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents: 36
diff changeset
42 HttpServletResponse response) throws Exception {
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 log.debug("NextArtifactStepAction.execute");
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
44 try {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
45 SessionModel sm = SessionModelFactory.getInstance()
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
46 .getSessionModel(request);
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
47
409
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 408
diff changeset
48 ArtifactDescription ad = sm.getArtifactDescription();
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 408
diff changeset
49
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
50 String target = request.getParameter("target");
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
51 OutputMode outputMode = sm.getOutputMode(target);
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
52 if (outputMode != null) {
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
53
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
54 Collection<OutputParameter> op = outputMode
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
55 .getOutputParameters();
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
56 if (op != null) {
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
57 Iterator<OutputParameter> it = op.iterator();
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
58 DiagrammOptions diagrammOptions = new DiagrammOptions();
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
59 while (it.hasNext()) {
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
60 OutputParameter parameter = it.next();
289
890d7a41ab93 Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents: 157
diff changeset
61 String value = request.getParameter(parameter.getName());
890d7a41ab93 Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents: 157
diff changeset
62 if (parameter.getType().equalsIgnoreCase("boolean")){
890d7a41ab93 Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents: 157
diff changeset
63 if (value == null){
890d7a41ab93 Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents: 157
diff changeset
64 value = "false";
890d7a41ab93 Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents: 157
diff changeset
65 }
407
55dae5bb76db Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 389
diff changeset
66 else {
55dae5bb76db Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 389
diff changeset
67 value = "true";
55dae5bb76db Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 389
diff changeset
68 }
289
890d7a41ab93 Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents: 157
diff changeset
69 }
890d7a41ab93 Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents: 157
diff changeset
70 diagrammOptions.setValue(parameter.getName(),value);
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
71
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
72 }
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
73 sm.setDiagrammOptions(diagrammOptions);
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
74 }
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
75 }
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
76
407
55dae5bb76db Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 389
diff changeset
77 Map tmpOuts = ad.getOutputModes();
55dae5bb76db Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 389
diff changeset
78 if (tmpOuts == null || tmpOuts.isEmpty()) {
55dae5bb76db Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 389
diff changeset
79 request.setAttribute("furthertargets", true);
55dae5bb76db Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 389
diff changeset
80 }
55dae5bb76db Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 389
diff changeset
81 else {
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 571
diff changeset
82 request.setAttribute(target, true);
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
83 }
407
55dae5bb76db Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 389
diff changeset
84
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
85 return super.execute(mapping, form, request, response);
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
86 } catch (Exception e) {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
87 log.error(e, e);
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
88 request.setAttribute(
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
89 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
90 .getMessage());
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
91 return super.getExceptionForward(mapping);
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
92 }
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
93 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
94
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
95 }
409
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 408
diff changeset
96 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org