Mercurial > dive4elements > gnv-client
comparison 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 |
comparison
equal
deleted
inserted
replaced
11:3cb753564552 | 12:4ebe57b170d3 |
---|---|
1 /** | |
2 * | |
3 */ | |
4 package de.intevation.gnv.action; | |
5 | |
6 import java.util.ArrayList; | |
7 import java.util.Collection; | |
8 import java.util.Iterator; | |
9 | |
10 import javax.servlet.http.HttpServletRequest; | |
11 import javax.servlet.http.HttpServletResponse; | |
12 | |
13 import org.apache.log4j.Logger; | |
14 import org.apache.struts.action.ActionForm; | |
15 import org.apache.struts.action.ActionForward; | |
16 import org.apache.struts.action.ActionMapping; | |
17 | |
18 import de.intevation.gnv.action.sessionmodel.SessionModel; | |
19 import de.intevation.gnv.action.sessionmodel.SessionModelFactory; | |
20 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient; | |
21 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory; | |
22 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription; | |
23 import de.intevation.gnv.artifactdatabase.objects.DefaultInputParameter; | |
24 import de.intevation.gnv.artifactdatabase.objects.InputParameter; | |
25 import de.intevation.gnv.util.XSLTransformer; | |
26 | |
27 /** | |
28 * @author Tim Englich <tim.englich@intevation.de> | |
29 * | |
30 */ | |
31 public class NextArtifactStepAction extends ArtifactDatabaseActionBase { | |
32 /** | |
33 * the logger, used to log exceptions and additonaly information | |
34 */ | |
35 private static Logger log = Logger.getLogger(SelectArtifactFactoryAction.class); | |
36 | |
37 /** | |
38 * Constructor | |
39 */ | |
40 public NextArtifactStepAction() { | |
41 super(); | |
42 } | |
43 | |
44 /** | |
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) | |
46 */ | |
47 @Override | |
48 public ActionForward execute(ActionMapping mapping, ActionForm form, | |
49 HttpServletRequest request, HttpServletResponse response) | |
50 throws Exception { | |
51 SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); | |
52 ArtifactDescription ad = (ArtifactDescription)sm.getCurrentArtifact(); | |
53 Collection<String> inputParameter = ad.getInputParameter(); | |
54 Collection<InputParameter> ips = null; | |
55 if (inputParameter != null){ | |
56 ips = new ArrayList<InputParameter>(inputParameter.size()); | |
57 Iterator<String> it = inputParameter.iterator(); | |
58 while (it.hasNext()){ | |
59 String name = it.next(); | |
60 String[] values = request.getParameterValues(name); | |
61 InputParameter ip = new DefaultInputParameter(name, values); | |
62 ips.add(ip); | |
63 } | |
64 } | |
65 // TODO: Woher kommt der zu erreichende Status; | |
66 String target = ad.getReachableStates().iterator().next(); | |
67 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient(); | |
68 ArtifactDescription artifactDescription = adc.doNextStep(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), target, ips); | |
69 | |
70 XSLTransformer transformer = new XSLTransformer(); | |
71 String ui = transformer.transform(artifactDescription.getCurrentUI(), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui.xsl")); | |
72 | |
73 request.setAttribute("ui", ui); | |
74 | |
75 return super.execute(mapping, form, request, response); | |
76 } | |
77 | |
78 | |
79 } |