Mercurial > dive4elements > gnv-client
comparison gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java @ 34:25fdec8b4c69
Added Global Errorhandling to the GNV-Client
gnv/trunk@170 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Fri, 02 Oct 2009 08:38:57 +0000 |
parents | 0f4362d75e9e |
children | ad381cc47217 |
comparison
equal
deleted
inserted
replaced
33:32ffff3f67aa | 34:25fdec8b4c69 |
---|---|
49 */ | 49 */ |
50 @Override | 50 @Override |
51 public ActionForward execute(ActionMapping mapping, ActionForm form, | 51 public ActionForward execute(ActionMapping mapping, ActionForm form, |
52 HttpServletRequest request, HttpServletResponse response) | 52 HttpServletRequest request, HttpServletResponse response) |
53 throws Exception { | 53 throws Exception { |
54 log.debug("NextArtifactStepAction.execute"); | 54 try { |
55 SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); | 55 log.debug("NextArtifactStepAction.execute"); |
56 ArtifactDescription ad = sm.getArtifactDescription(); | 56 SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); |
57 Collection<String> inputParameter = ad.getInputParameter(); | 57 ArtifactDescription ad = sm.getArtifactDescription(); |
58 Collection<InputParameter> ips = null; | 58 Collection<String> inputParameter = ad.getInputParameter(); |
59 if (inputParameter != null){ | 59 Collection<InputParameter> ips = null; |
60 ips = new ArrayList<InputParameter>(inputParameter.size()); | 60 if (inputParameter != null){ |
61 Iterator<String> it = inputParameter.iterator(); | 61 ips = new ArrayList<InputParameter>(inputParameter.size()); |
62 while (it.hasNext()){ | 62 Iterator<String> it = inputParameter.iterator(); |
63 String name = it.next(); | 63 while (it.hasNext()){ |
64 String[] values = request.getParameterValues(name); | 64 String name = it.next(); |
65 InputParameter ip = new DefaultInputParameter(name, values); | 65 String[] values = request.getParameterValues(name); |
66 ips.add(ip); | 66 InputParameter ip = new DefaultInputParameter(name, values); |
67 ips.add(ip); | |
68 } | |
67 } | 69 } |
70 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient(); | |
71 if (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty()){ | |
72 // TODO: Woher kommt der zu erreichende Status; | |
73 String target = null; | |
74 if (ad.getReachableStates().size() > 1){ | |
75 target = request.getParameter("product"); // TODO HACK for Propducts every other Step has currently only one reachable state. | |
76 }else{ | |
77 target = ad.getReachableStates().iterator().next(); | |
78 } | |
79 | |
80 ArtifactDescription artifactDescription = adc.doNextStep(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), target, ips); | |
81 | |
82 Node currentUI = artifactDescription.getCurrentUI(); | |
83 XSLTransformer transformer = new XSLTransformer(); | |
84 String ui = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "dynamic"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui.xsl")); | |
85 | |
86 request.setAttribute("ui", ui); | |
87 | |
88 String staticUI = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "static"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); | |
89 request.setAttribute("staticui", staticUI); | |
90 | |
91 request.setAttribute("furthertargets", (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty())); | |
92 | |
93 }else{ | |
94 | |
95 adc.doFeed(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), ips); | |
96 | |
97 request.setAttribute("diagramm", true); | |
98 | |
99 // statistic abholen und in das sessionmodell schreiben. | |
100 | |
101 Collection<ArtifactStatisticValue> statistics = adc.calculateStatistics(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact()); | |
102 sm.setStatistics(statistics); | |
103 | |
104 ArtifactDescription artifactDescription = adc.getCurrentStepDescription(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact()); | |
105 | |
106 Node currentUI = artifactDescription.getCurrentUI(); | |
107 XSLTransformer transformer = new XSLTransformer(); | |
108 String ui = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "dynamic"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui.xsl")); | |
109 | |
110 request.setAttribute("ui", ui); | |
111 | |
112 String staticUI = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "static"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); | |
113 request.setAttribute("staticui", staticUI); | |
114 | |
115 request.setAttribute("furthertargets",false); | |
116 } | |
117 return super.execute(mapping, form, request, response); | |
118 } catch (Exception e) { | |
119 log.error(e,e); | |
120 request.setAttribute(CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e.getMessage()); | |
121 return super.getExceptionForward(mapping); | |
68 } | 122 } |
69 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient(); | |
70 if (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty()){ | |
71 // TODO: Woher kommt der zu erreichende Status; | |
72 String target = null; | |
73 if (ad.getReachableStates().size() > 1){ | |
74 target = request.getParameter("product"); // TODO HACK for Propducts every other Step has currently only one reachable state. | |
75 }else{ | |
76 target = ad.getReachableStates().iterator().next(); | |
77 } | |
78 | |
79 ArtifactDescription artifactDescription = adc.doNextStep(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), target, ips); | |
80 | |
81 Node currentUI = artifactDescription.getCurrentUI(); | |
82 XSLTransformer transformer = new XSLTransformer(); | |
83 String ui = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "dynamic"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui.xsl")); | |
84 | |
85 request.setAttribute("ui", ui); | |
86 | |
87 String staticUI = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "static"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); | |
88 request.setAttribute("staticui", staticUI); | |
89 | |
90 request.setAttribute("furthertargets", (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty())); | |
91 | |
92 }else{ | |
93 | |
94 adc.doFeed(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), ips); | |
95 | |
96 request.setAttribute("diagramm", true); | |
97 | |
98 // statistic abholen und in das sessionmodell schreiben. | |
99 | |
100 Collection<ArtifactStatisticValue> statistics = adc.calculateStatistics(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact()); | |
101 sm.setStatistics(statistics); | |
102 | |
103 ArtifactDescription artifactDescription = adc.getCurrentStepDescription(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact()); | |
104 | |
105 Node currentUI = artifactDescription.getCurrentUI(); | |
106 XSLTransformer transformer = new XSLTransformer(); | |
107 String ui = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "dynamic"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui.xsl")); | |
108 | |
109 request.setAttribute("ui", ui); | |
110 | |
111 String staticUI = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "static"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); | |
112 request.setAttribute("staticui", staticUI); | |
113 | |
114 request.setAttribute("furthertargets",false); | |
115 } | |
116 | |
117 return super.execute(mapping, form, request, response); | |
118 } | 123 } |
119 | 124 |
120 | 125 |
121 } | 126 } |