Mercurial > dive4elements > gnv-client
comparison gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java @ 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.
gnv/trunk@599 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 22 Jan 2010 11:28:25 +0000 |
parents | b5733f9f386b |
children | 9a5e50e7afaa |
comparison
equal
deleted
inserted
replaced
408:b5733f9f386b | 409:df78178e1180 |
---|---|
12 | 12 |
13 import org.apache.log4j.Logger; | 13 import org.apache.log4j.Logger; |
14 import org.apache.struts.action.ActionForm; | 14 import org.apache.struts.action.ActionForm; |
15 import org.apache.struts.action.ActionForward; | 15 import org.apache.struts.action.ActionForward; |
16 import org.apache.struts.action.ActionMapping; | 16 import org.apache.struts.action.ActionMapping; |
17 import org.w3c.dom.Node; | |
18 | 17 |
19 import de.intevation.gnv.action.sessionmodel.DiagrammOptions; | 18 import de.intevation.gnv.action.sessionmodel.DiagrammOptions; |
20 import de.intevation.gnv.action.sessionmodel.SessionModel; | 19 import de.intevation.gnv.action.sessionmodel.SessionModel; |
21 import de.intevation.gnv.action.sessionmodel.SessionModelFactory; | 20 import de.intevation.gnv.action.sessionmodel.SessionModelFactory; |
22 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient; | |
23 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory; | |
24 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription; | 21 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription; |
25 import de.intevation.gnv.artifactdatabase.objects.OutputMode; | 22 import de.intevation.gnv.artifactdatabase.objects.OutputMode; |
26 import de.intevation.gnv.artifactdatabase.objects.OutputParameter; | 23 import de.intevation.gnv.artifactdatabase.objects.OutputParameter; |
27 import de.intevation.gnv.util.XMLUtils; | |
28 import de.intevation.gnv.util.XSLTransformer; | |
29 | 24 |
30 /** | 25 /** |
31 * @author Tim Englich <tim.englich@intevation.de> | 26 * @author Tim Englich <tim.englich@intevation.de> |
32 * | 27 * |
33 */ | 28 */ |
34 public class ChangeOptionsAction extends ArtifactDatabaseActionBase { | 29 public class ChangeOptionsAction extends DescribeUIAction { |
35 /** | 30 /** |
36 * the logger, used to log exceptions and additonaly information | 31 * the logger, used to log exceptions and additonaly information |
37 */ | 32 */ |
38 private static Logger log = Logger.getLogger(ChangeOptionsAction.class); | 33 private static Logger log = Logger.getLogger(ChangeOptionsAction.class); |
39 | 34 |
50 HttpServletResponse response) throws Exception { | 45 HttpServletResponse response) throws Exception { |
51 log.debug("NextArtifactStepAction.execute"); | 46 log.debug("NextArtifactStepAction.execute"); |
52 try { | 47 try { |
53 SessionModel sm = SessionModelFactory.getInstance() | 48 SessionModel sm = SessionModelFactory.getInstance() |
54 .getSessionModel(request); | 49 .getSessionModel(request); |
50 | |
51 ArtifactDescription ad = sm.getArtifactDescription(); | |
55 | 52 |
56 String target = request.getParameter("target"); | 53 String target = request.getParameter("target"); |
57 OutputMode outputMode = sm.getOutputMode(target); | 54 OutputMode outputMode = sm.getOutputMode(target); |
58 if (outputMode != null) { | 55 if (outputMode != null) { |
59 | 56 |
78 } | 75 } |
79 sm.setDiagrammOptions(diagrammOptions); | 76 sm.setDiagrammOptions(diagrammOptions); |
80 } | 77 } |
81 } | 78 } |
82 | 79 |
83 ArtifactDescription ad = sm.getArtifactDescription(); | |
84 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory | |
85 .getInstance() | |
86 .getArtifactDatabaseClient(getLocale(request)); | |
87 | |
88 ArtifactDescription artifactDescription = adc | |
89 .getCurrentStepDescription(sm.getSelectedArtifactFactory(), | |
90 sm.getCurrentArtifact(), | |
91 true); | |
92 | |
93 Node currentUI = artifactDescription.getCurrentUI(); | |
94 XSLTransformer transformer = new XSLTransformer(); | |
95 | |
96 String url = response.encodeURL( | |
97 mapping.findForward("back").getPath()); | |
98 transformer.addParameter("back-url", url); | |
99 | |
100 String fisUrl = response.encodeURL( | |
101 mapping.findForward("selectfis").getPath()); | |
102 transformer.addParameter("selectfis", fisUrl); | |
103 | |
104 String ui = transformer.transform( | |
105 new XMLUtils().getNodeXPath(currentUI, "art:dynamic"), | |
106 "UTF-8", | |
107 request.getRealPath(XSL_SHEET_DYNAMIC | |
108 )); | |
109 | |
110 if (ui != null && ui.length() > 1) | |
111 request.setAttribute("ui", ui); | |
112 | |
113 String staticUI = transformer.transform( | |
114 new XMLUtils().getNodeXPath(currentUI, "art:static"), | |
115 "UTF-8", | |
116 request.getRealPath(XSL_SHEET_STATIC)); | |
117 request.setAttribute("staticui", staticUI); | |
118 | |
119 Map tmpOuts = ad.getOutputModes(); | 80 Map tmpOuts = ad.getOutputModes(); |
120 if (tmpOuts == null || tmpOuts.isEmpty()) { | 81 if (tmpOuts == null || tmpOuts.isEmpty()) { |
121 request.setAttribute("furthertargets", true); | 82 request.setAttribute("furthertargets", true); |
122 } | 83 } |
123 else { | 84 else { |
133 return super.getExceptionForward(mapping); | 94 return super.getExceptionForward(mapping); |
134 } | 95 } |
135 } | 96 } |
136 | 97 |
137 } | 98 } |
99 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |