annotate gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java @ 30:07e9c137a2f1

Added dynamic Outputparameter Support and Outputparameter-manipulation gnv/trunk@134 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 25 Sep 2009 14:24:08 +0000
parents ec56ef8f3e58
children 0f4362d75e9e
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;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 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
25 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
26 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
27 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
28
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 * @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
31 *
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 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
34 /**
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 * 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
36 */
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 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
38
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 * Constructor
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 */
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 public NextArtifactStepAction() {
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 super();
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 }
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 * @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
48 */
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 @Override
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 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
51 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
52 throws Exception {
24
ec56ef8f3e58 Configurable logging integrated in the Web-Application
Tim Englich <tim.englich@intevation.de>
parents: 22
diff changeset
53 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
54 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
55 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
56 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
57 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
58 if (inputParameter != null){
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 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
60 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
61 while (it.hasNext()){
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 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
63 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
64 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
65 ips.add(ip);
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 }
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 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient();
13
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
69 if (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty()){
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
70 // 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
71 String target = null;
1557bea6cb55 Do some Imporvements for Userfriendly exceptionhandling.
Tim Englich <tim.englich@intevation.de>
parents: 18
diff changeset
72 if (ad.getReachableStates().size() > 1){
1557bea6cb55 Do some Imporvements for Userfriendly exceptionhandling.
Tim Englich <tim.englich@intevation.de>
parents: 18
diff changeset
73 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
74 }else{
1557bea6cb55 Do some Imporvements for Userfriendly exceptionhandling.
Tim Englich <tim.englich@intevation.de>
parents: 18
diff changeset
75 target = ad.getReachableStates().iterator().next();
1557bea6cb55 Do some Imporvements for Userfriendly exceptionhandling.
Tim Englich <tim.englich@intevation.de>
parents: 18
diff changeset
76 }
13
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
77
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
78 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
79
18
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
80 Node currentUI = artifactDescription.getCurrentUI();
13
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
81 XSLTransformer transformer = new XSLTransformer();
18
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
82 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
83
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
84 request.setAttribute("ui", ui);
17
d7e5a929fc34 Some Stylingimprovements done
Tim Englich <tim.englich@intevation.de>
parents: 13
diff changeset
85
18
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
86 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
87 request.setAttribute("staticui", staticUI);
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
88
17
d7e5a929fc34 Some Stylingimprovements done
Tim Englich <tim.englich@intevation.de>
parents: 13
diff changeset
89 request.setAttribute("furthertargets", (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty()));
d7e5a929fc34 Some Stylingimprovements done
Tim Englich <tim.englich@intevation.de>
parents: 13
diff changeset
90
13
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
91 }else{
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
92
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
93 adc.doFeed(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), ips);
22
367a00e4b9ad Some GUI-Improvements done
Tim Englich <tim.englich@intevation.de>
parents: 19
diff changeset
94
367a00e4b9ad Some GUI-Improvements done
Tim Englich <tim.englich@intevation.de>
parents: 19
diff changeset
95 request.setAttribute("diagramm", true);
13
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
96
17
d7e5a929fc34 Some Stylingimprovements done
Tim Englich <tim.englich@intevation.de>
parents: 13
diff changeset
97 ArtifactDescription artifactDescription = adc.getCurrentStepDescription(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact());
d7e5a929fc34 Some Stylingimprovements done
Tim Englich <tim.englich@intevation.de>
parents: 13
diff changeset
98
18
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
99 Node currentUI = artifactDescription.getCurrentUI();
17
d7e5a929fc34 Some Stylingimprovements done
Tim Englich <tim.englich@intevation.de>
parents: 13
diff changeset
100 XSLTransformer transformer = new XSLTransformer();
18
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
101 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
102
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
103 request.setAttribute("ui", ui);
17
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 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
106 request.setAttribute("staticui", staticUI);
87002cbd194c Static UI -integration an some refactoringwork done
Tim Englich <tim.englich@intevation.de>
parents: 17
diff changeset
107
17
d7e5a929fc34 Some Stylingimprovements done
Tim Englich <tim.englich@intevation.de>
parents: 13
diff changeset
108 request.setAttribute("furthertargets",false);
13
2535158e2687 Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents: 12
diff changeset
109 }
12
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
110
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
111 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
112 }
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
113
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
114
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
115 }

http://dive4elements.wald.intevation.org