annotate gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java @ 12:4ebe57b170d3

Integration of moving through the Artifact-States and rendering the UI. gnv/trunk@91 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Wed, 16 Sep 2009 07:44:26 +0000
parents
children 2535158e2687
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;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 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
19 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
20 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
21 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
22 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
23 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
24 import de.intevation.gnv.artifactdatabase.objects.InputParameter;
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.util.XSLTransformer;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 /**
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 * @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
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 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
32 /**
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 * 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
34 */
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 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
36
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 * Constructor
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 public NextArtifactStepAction() {
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 super();
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
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 * @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
46 */
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 @Override
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 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
49 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
50 throws Exception {
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 ArtifactDescription ad = (ArtifactDescription)sm.getCurrentArtifact();
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 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
54 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
55 if (inputParameter != null){
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 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
57 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
58 while (it.hasNext()){
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 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
60 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
61 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
62 ips.add(ip);
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 }
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 }
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 // TODO: Woher kommt der zu erreichende Status;
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 String target = ad.getReachableStates().iterator().next();
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient();
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 ArtifactDescription artifactDescription = adc.doNextStep(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), target, ips);
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
70 XSLTransformer transformer = new XSLTransformer();
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71 String ui = transformer.transform(artifactDescription.getCurrentUI(), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui.xsl"));
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
72
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 request.setAttribute("ui", ui);
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75 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
76 }
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
77
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
78
4ebe57b170d3 Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
79 }

http://dive4elements.wald.intevation.org