comparison gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java @ 171:7fb9441dd8af

Format Code to max 80 Chars per Row and Cleanup gnv-artifacts/trunk@208 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 09 Oct 2009 07:54:48 +0000
parents ef157bd2fa92
children 00c1a931b9c3
comparison
equal deleted inserted replaced
170:7be22e76c270 171:7fb9441dd8af
36 import de.intevation.gnv.transition.exception.TransitionException; 36 import de.intevation.gnv.transition.exception.TransitionException;
37 import de.intevation.gnv.utils.ArtifactXMLUtilities; 37 import de.intevation.gnv.utils.ArtifactXMLUtilities;
38 38
39 /** 39 /**
40 * @author Tim Englich <tim.englich@intevation.de> 40 * @author Tim Englich <tim.englich@intevation.de>
41 * 41 *
42 */ 42 */
43 public abstract class GNVArtifactBase extends DefaultArtifact { 43 public abstract class GNVArtifactBase extends DefaultArtifact {
44 /** 44 /**
45 * the logger, used to log exceptions and additonaly information 45 * the logger, used to log exceptions and additonaly information
46 */ 46 */
47 private static Logger log = Logger.getLogger(GNVArtifactBase.class); 47 private static Logger log = Logger.getLogger(GNVArtifactBase.class);
48 /** 48 /**
49 * The UID of this Class 49 * The UID of this Class
50 */ 50 */
51 private static final long serialVersionUID = -8907096744400741458L; 51 private static final long serialVersionUID = -8907096744400741458L;
52 52
53 /** 53 /**
54 * The Identifier for the Replacement of the Artifactname 54 * The Identifier for the Replacement of the Artifactname
55 */ 55 */
56 public static final String XPATH_IDENTIFIER_REPLACE = "IDENTIFIER"; 56 public static final String XPATH_IDENTIFIER_REPLACE = "IDENTIFIER";
57 57
58 /** 58 /**
59 * The XPATH to the XML-Fragment that should be used for the Configuration 59 * The XPATH to the XML-Fragment that should be used for the Configuration
60 */ 60 */
61 public static final String XPATH_ARTIFACT_CONFIGURATION= "/artifact-database/artifacts/artifact[@name='"+XPATH_IDENTIFIER_REPLACE+"']"; 61 public static final String XPATH_ARTIFACT_CONFIGURATION = "/artifact-database/artifacts/artifact[@name='"
62 62 + XPATH_IDENTIFIER_REPLACE
63 63 + "']";
64
64 /** 65 /**
65 * The current Transition 66 * The current Transition
66 */ 67 */
67 protected Transition current = null; 68 protected Transition current = null;
68 69
69 /** 70 /**
70 * The Transitions that can be used 71 * The Transitions that can be used
71 */ 72 */
72 protected Map<String, Transition> transitions = null; 73 protected Map<String, Transition> transitions = null;
73 74
74 /** 75 /**
75 * The Name of the Artifact 76 * The Name of the Artifact
76 */ 77 */
77 protected String name = null; 78 protected String name = null;
78 79
79 private ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities(); 80 private ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities();
80 81
81 /** 82 /**
82 * Constructor 83 * Constructor
83 */ 84 */
84 public GNVArtifactBase() { 85 public GNVArtifactBase() {
85 super(); 86 super();
86 } 87 }
87 88
88 /** 89 /**
89 * @see de.intevation.artifactdatabase.DefaultArtifact#advance(org.w3c.dom.Document, de.intevation.artifacts.CallContext) 90 * @see de.intevation.artifactdatabase.DefaultArtifact#advance(org.w3c.dom.Document,
91 * de.intevation.artifacts.CallContext)
90 */ 92 */
91 @Override 93 @Override
92 public Document advance(Document target, CallContext context) { 94 public Document advance(Document target, CallContext context) {
93 log.debug("GNVArtifactBase.advance"); 95 log.debug("GNVArtifactBase.advance");
94 String uuid = Config.getStringXPath(target, "action/uuid/@value"); 96 String uuid = Config.getStringXPath(target, "action/uuid/@value");
95 Document result = XMLUtils.newDocument(); 97 Document result = XMLUtils.newDocument();
96 try { 98 try {
97 if (this.current != null){ 99 if (this.current != null) {
98 String transitionName = this.readTransitionName(target); 100 String transitionName = this.readTransitionName(target);
99 log.debug("Transitionsname: "+transitionName); 101 log.debug("Transitionsname: " + transitionName);
100 if (this.current.isTransitionReachable(transitionName)){ 102 if (this.current.isTransitionReachable(transitionName)) {
101 // 1. Prüfung ob Transition valide ist 103 // 1. Prüfung ob Transition valide ist
102 if (this.current.validate()){ 104 if (this.current.validate()) {
103 105
104 try { 106 try {
105 Transition nextStep = this.transitions.get(transitionName); 107 Transition nextStep = this.transitions
108 .get(transitionName);
106 // 2.Ergebnisse Berechnen 109 // 2.Ergebnisse Berechnen
107 this.current.advance(uuid,context.getMeta()); 110 this.current.advance(uuid, context.getMeta());
108 // 3. Ergebnisse übergeben 111 // 3. Ergebnisse übergeben
109 nextStep.setDescibeData(this.current.getDescibeData()); 112 nextStep.setDescibeData(this.current
110 nextStep.putInputData(this.current.getInputData(),uuid); 113 .getDescibeData());
114 nextStep.putInputData(this.current.getInputData(),
115 uuid);
111 // 4. Umschalten auf neue Transistion 116 // 4. Umschalten auf neue Transistion
112 this.current = nextStep; 117 this.current = nextStep;
113 result = new ArtifactXMLUtilities().createSuccessReport("Advance success", XMLUtils.newDocument()); 118 result = new ArtifactXMLUtilities()
119 .createSuccessReport("Advance success",
120 XMLUtils.newDocument());
114 } catch (TransitionException e) { 121 } catch (TransitionException e) {
115 log.error(e,e); 122 log.error(e, e);
116 result = new ArtifactXMLUtilities().createExceptionReport(e.getLocalizedMessage(), XMLUtils.newDocument()); 123 result = new ArtifactXMLUtilities()
124 .createExceptionReport(e
125 .getLocalizedMessage(), XMLUtils
126 .newDocument());
117 } 127 }
118 128
119 }else{ 129 } else {
120 String msg = "Advance nicht möglich, da die Bedingungen für den Übergang " + 130 String msg = "Advance nicht möglich, da die Bedingungen für den Übergang "
121 "in den neuen Zustand noch nicht gegeben ist."; 131 + "in den neuen Zustand noch nicht gegeben ist.";
122 log.error(msg); 132 log.error(msg);
123 result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument()); 133 result = new ArtifactXMLUtilities()
134 .createExceptionReport(msg, XMLUtils
135 .newDocument());
124 } 136 }
125 137
126 }else{ 138 } else {
127 String msg = "Transitionsübergang wird nicht unterstützt."; 139 String msg = "Transitionsübergang wird nicht unterstützt.";
128 log.error(msg); 140 log.error(msg);
129 result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument()); 141 result = new ArtifactXMLUtilities().createExceptionReport(
142 msg, XMLUtils.newDocument());
130 } 143 }
131 }else{ 144 } else {
132 String msg = "Kein Transitionsschritt aktiviert."; 145 String msg = "Kein Transitionsschritt aktiviert.";
133 log.error(msg); 146 log.error(msg);
134 result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument()); 147 result = new ArtifactXMLUtilities().createExceptionReport(msg,
148 XMLUtils.newDocument());
135 } 149 }
136 } catch (Exception e) { 150 } catch (Exception e) {
137 log.error(e,e); 151 log.error(e, e);
138 result = new ArtifactXMLUtilities().createExceptionReport(e.getLocalizedMessage(), XMLUtils.newDocument()); 152 result = new ArtifactXMLUtilities().createExceptionReport(e
153 .getLocalizedMessage(), XMLUtils.newDocument());
139 } 154 }
140 return result; 155 return result;
141 } 156 }
142 157
143 protected String readTransitionName(Document document) { 158 protected String readTransitionName(Document document) {
144 String returnValue = Config.getStringXPath(document, "action/target/@name"); 159 String returnValue = Config.getStringXPath(document,
160 "action/target/@name");
145 return returnValue; 161 return returnValue;
146 } 162 }
147 163
148 protected Node getConfigurationFragment(Document document){ 164 protected Node getConfigurationFragment(Document document) {
149 log.debug("GNVArtifactBase.getConfigurationFragment"); 165 log.debug("GNVArtifactBase.getConfigurationFragment");
150 String xpathQuery = XPATH_ARTIFACT_CONFIGURATION.replaceAll(XPATH_IDENTIFIER_REPLACE, this.name); 166 String xpathQuery = XPATH_ARTIFACT_CONFIGURATION.replaceAll(
167 XPATH_IDENTIFIER_REPLACE, this.name);
151 log.debug(xpathQuery); 168 log.debug(xpathQuery);
152 return Config.getNodeXPath(document,xpathQuery); 169 return Config.getNodeXPath(document, xpathQuery);
153 } 170 }
154 171
155 /** 172 /**
156 * @see de.intevation.artifactdatabase.DefaultArtifact#feed(org.w3c.dom.Document, de.intevation.artifacts.CallContext) 173 * @see de.intevation.artifactdatabase.DefaultArtifact#feed(org.w3c.dom.Document,
174 * de.intevation.artifacts.CallContext)
157 */ 175 */
158 @Override 176 @Override
159 public Document feed(Document target, CallContext context) { 177 public Document feed(Document target, CallContext context) {
160 log.debug("GNVArtifactBase.feed"); 178 log.debug("GNVArtifactBase.feed");
161 Document result = XMLUtils.newDocument(); 179 Document result = XMLUtils.newDocument();
162 try { 180 try {
163 if (this.current != null){ 181 if (this.current != null) {
164 String uuid = Config.getStringXPath(target, "action/uuid/@value"); 182 String uuid = Config.getStringXPath(target,
165 this.current.putInputData(this.parseInputData(target, "/action/data/input"),uuid); 183 "action/uuid/@value");
166 result = new ArtifactXMLUtilities().createSuccessReport("Feed success", XMLUtils.newDocument()); 184 this.current.putInputData(this.parseInputData(target,
167 }else{ 185 "/action/data/input"), uuid);
186 result = new ArtifactXMLUtilities().createSuccessReport(
187 "Feed success", XMLUtils.newDocument());
188 } else {
168 String msg = "No Transition instantiated"; 189 String msg = "No Transition instantiated";
169 log.warn(msg); 190 log.warn(msg);
170 result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument()); 191 result = new ArtifactXMLUtilities().createExceptionReport(msg,
192 XMLUtils.newDocument());
171 } 193 }
172 } catch (TransitionException e) { 194 } catch (TransitionException e) {
173 log.error(e,e); 195 log.error(e, e);
174 result = new ArtifactXMLUtilities().createExceptionReport(e.getLocalizedMessage(), XMLUtils.newDocument()); 196 result = new ArtifactXMLUtilities().createExceptionReport(e
197 .getLocalizedMessage(), XMLUtils.newDocument());
175 } 198 }
176 return result; 199 return result;
177 } 200 }
178 201
179 /** 202 /**
180 * @see de.intevation.artifactdatabase.DefaultArtifact#setup(java.lang.String, java.lang.Object) 203 * @see de.intevation.artifactdatabase.DefaultArtifact#setup(java.lang.String,
204 * java.lang.Object)
181 */ 205 */
182 @Override 206 @Override
183 public void setup(String identifier, ArtifactFactory factory, Object context) { 207 public void setup(String identifier, ArtifactFactory factory, Object context) {
184 log.debug("GNVArtifactBase.setup"); 208 log.debug("GNVArtifactBase.setup");
185 super.setup(identifier, factory, context); 209 super.setup(identifier, factory, context);
186 210
187 Object localContext = context; 211 Object localContext = context;
188 if (context instanceof CallContext){ 212 if (context instanceof CallContext) {
189 localContext = ((CallContext)context).globalContext(); 213 localContext = ((CallContext) context).globalContext();
190 214
191 } 215 }
192 216
193 if (localContext instanceof GNVArtifactContext){ 217 if (localContext instanceof GNVArtifactContext) {
194 GNVArtifactContext gnvContext = (GNVArtifactContext)localContext; 218 GNVArtifactContext gnvContext = (GNVArtifactContext) localContext;
195 Document doc = gnvContext.getConfig(); 219 Document doc = gnvContext.getConfig();
196 Node artifactNode = this.getConfigurationFragment(doc); 220 Node artifactNode = this.getConfigurationFragment(doc);
197 NodeList transitionList = Config.getNodeSetXPath(artifactNode, "transitions/transition"); 221 NodeList transitionList = Config.getNodeSetXPath(artifactNode,
198 this.transitions = new HashMap<String, Transition>(transitionList.getLength()); 222 "transitions/transition");
199 for (int i = 0 ; i < transitionList.getLength(); i++){ 223 this.transitions = new HashMap<String, Transition>(transitionList
200 Transition tmpTransition = TransitionFactory.getInstance().createTransition(transitionList.item(i)); 224 .getLength());
201 if (tmpTransition != null){ 225 for (int i = 0; i < transitionList.getLength(); i++) {
226 Transition tmpTransition = TransitionFactory.getInstance()
227 .createTransition(transitionList.item(i));
228 if (tmpTransition != null) {
202 this.transitions.put(tmpTransition.getID(), tmpTransition); 229 this.transitions.put(tmpTransition.getID(), tmpTransition);
203 if (this.current == null){ 230 if (this.current == null) {
204 this.current = tmpTransition; 231 this.current = tmpTransition;
205 } 232 }
206 } 233 }
207 } 234 }
208 235
209 } 236 }
210 } 237 }
211 238
212 239 protected Document createDescibeOutput(CallMeta callMeta) {
213 protected Document createDescibeOutput(CallMeta callMeta){
214 log.debug("GNVArtifactBase.createDescibeOutput"); 240 log.debug("GNVArtifactBase.createDescibeOutput");
215 Document document = XMLUtils.newDocument(); 241 Document document = XMLUtils.newDocument();
216 Element rootNode = this.createRootNode(document); 242 Element rootNode = this.createRootNode(document);
217 this.createHeader(rootNode, document, "describe"); 243 this.createHeader(rootNode, document, "describe");
218 this.createOutputs(rootNode, document); 244 this.createOutputs(rootNode, document);
219 this.createCurrentState(rootNode, document); 245 this.createCurrentState(rootNode, document);
220 this.createReachableStates(rootNode, document); 246 this.createReachableStates(rootNode, document);
221 this.createModel(rootNode, document); 247 this.createModel(rootNode, document);
222 this.createUserInterface(rootNode, document,callMeta); 248 this.createUserInterface(rootNode, document, callMeta);
223 return document; 249 return document;
224 } 250 }
225 251
226 protected Element createRootNode(Document document){ 252 protected Element createRootNode(Document document) {
227 Element rootNode = xmlUtilities.createArtifactElement(document,"result"); 253 Element rootNode = xmlUtilities.createArtifactElement(document,
254 "result");
228 document.appendChild(rootNode); 255 document.appendChild(rootNode);
229 return rootNode; 256 return rootNode;
230 } 257 }
231 258
232 protected void createHeader(Element parent, Document document, String documentType){ 259 protected void createHeader(Element parent, Document document,
233 Element typeNode = xmlUtilities.createArtifactElement(document,"type"); 260 String documentType) {
261 Element typeNode = xmlUtilities.createArtifactElement(document, "type");
234 typeNode.setAttribute("name", documentType); 262 typeNode.setAttribute("name", documentType);
235 parent.appendChild(typeNode); 263 parent.appendChild(typeNode);
236 264
237 Element uuidNode = xmlUtilities.createArtifactElement(document,"uuid"); 265 Element uuidNode = xmlUtilities.createArtifactElement(document, "uuid");
238 uuidNode.setAttribute("value", super.identifier); 266 uuidNode.setAttribute("value", super.identifier);
239 parent.appendChild(uuidNode); 267 parent.appendChild(uuidNode);
240 268
241 Element hashNode = xmlUtilities.createArtifactElement(document,"hash"); 269 Element hashNode = xmlUtilities.createArtifactElement(document, "hash");
242 hashNode.setAttribute("value", this.hash()); 270 hashNode.setAttribute("value", this.hash());
243 parent.appendChild(hashNode); 271 parent.appendChild(hashNode);
244 } 272 }
245 273
246 protected void createReachableStates(Element parent,Document document){ 274 protected void createReachableStates(Element parent, Document document) {
247 Element stateNode = xmlUtilities.createArtifactElement(document,"reachable-states"); 275 Element stateNode = xmlUtilities.createArtifactElement(document,
248 if (this.current != null){ 276 "reachable-states");
249 Iterator<String> states = this.current.reachableTransitions().iterator(); 277 if (this.current != null) {
250 while(states.hasNext()){ 278 Iterator<String> states = this.current.reachableTransitions()
279 .iterator();
280 while (states.hasNext()) {
251 String value = states.next(); 281 String value = states.next();
252 Element currentNode = xmlUtilities.createArtifactElement(document,"state"); 282 Element currentNode = xmlUtilities.createArtifactElement(
283 document, "state");
253 currentNode.setAttribute("name", value); 284 currentNode.setAttribute("name", value);
254 log.debug("Reachable State: "+value); 285 log.debug("Reachable State: " + value);
255 currentNode.setAttribute("description", transitions.get(value).getDescription()); 286 currentNode.setAttribute("description", transitions.get(value)
287 .getDescription());
256 stateNode.appendChild(currentNode); 288 stateNode.appendChild(currentNode);
257 } 289 }
258 } 290 }
259 parent.appendChild(stateNode); 291 parent.appendChild(stateNode);
260 } 292 }
261 293
262 protected void createCurrentState(Element parent, Document document){ 294 protected void createCurrentState(Element parent, Document document) {
263 Element stateNode = xmlUtilities.createArtifactElement(document,"state"); 295 Element stateNode = xmlUtilities.createArtifactElement(document,
296 "state");
264 stateNode.setAttribute("name", this.current.getID()); 297 stateNode.setAttribute("name", this.current.getID());
265 stateNode.setAttribute("description", this.current.getDescription()); 298 stateNode.setAttribute("description", this.current.getDescription());
266 parent.appendChild(stateNode); 299 parent.appendChild(stateNode);
267 } 300 }
268 301
269 302 protected void createModel(Element parent, Document document) {
270 protected void createModel(Element parent, Document document){ 303 Element modelNode = xmlUtilities.createArtifactElement(document,
271 Element modelNode = xmlUtilities.createArtifactElement(document,"model"); 304 "model");
272 if (this.current != null){ 305 if (this.current != null) {
273 Collection<InputValue> inputValues = this.current.getRequiredInputValues(); 306 Collection<InputValue> inputValues = this.current
274 if (inputValues != null){ 307 .getRequiredInputValues();
308 if (inputValues != null) {
275 Iterator<InputValue> it = inputValues.iterator(); 309 Iterator<InputValue> it = inputValues.iterator();
276 while(it.hasNext()){ 310 while (it.hasNext()) {
277 InputValue inputValue = it.next(); 311 InputValue inputValue = it.next();
278 Element inputNode = xmlUtilities.createArtifactElement(document,"input"); 312 Element inputNode = xmlUtilities.createArtifactElement(
313 document, "input");
279 inputNode.setAttribute("name", inputValue.getName()); 314 inputNode.setAttribute("name", inputValue.getName());
280 inputNode.setAttribute("type", inputValue.getType()); 315 inputNode.setAttribute("type", inputValue.getType());
281 modelNode.appendChild(inputNode); 316 modelNode.appendChild(inputNode);
282 } 317 }
283 } 318 }
284 } 319 }
285 parent.appendChild(modelNode); 320 parent.appendChild(modelNode);
286 } 321 }
287 322
288 protected void createUserInterface(Element parent, Document document, CallMeta callMeta){ 323 protected void createUserInterface(Element parent, Document document,
289 Element uiNode = xmlUtilities.createArtifactElement(document,"ui"); 324 CallMeta callMeta) {
290 325 Element uiNode = xmlUtilities.createArtifactElement(document, "ui");
291 if (this.current != null){ 326
292 this.current.describe(document, uiNode,callMeta); 327 if (this.current != null) {
293 } 328 this.current.describe(document, uiNode, callMeta);
294 329 }
330
295 parent.appendChild(uiNode); 331 parent.appendChild(uiNode);
296 } 332 }
297 333
298 protected void createOutputs(Element parent, Document document){ 334 protected void createOutputs(Element parent, Document document) {
299 log.debug("GNVArtifactBase.createOutputs"); 335 log.debug("GNVArtifactBase.createOutputs");
300 Element outputsNode = xmlUtilities.createArtifactElement(document,"outputs"); 336 Element outputsNode = xmlUtilities.createArtifactElement(document,
301 if (this.current instanceof OutputTransition){ 337 "outputs");
302 Collection<OutputMode> outputModes = ((OutputTransition)this.current).getOutputModes(); 338 if (this.current instanceof OutputTransition) {
303 if (outputModes != null){ 339 Collection<OutputMode> outputModes = ((OutputTransition) this.current)
340 .getOutputModes();
341 if (outputModes != null) {
304 Iterator<OutputMode> it = outputModes.iterator(); 342 Iterator<OutputMode> it = outputModes.iterator();
305 while(it.hasNext()){ 343 while (it.hasNext()) {
306 OutputMode outputMode = it.next(); 344 OutputMode outputMode = it.next();
307 log.debug("Write Outputnode for "+ outputMode.toString()); 345 log.debug("Write Outputnode for " + outputMode.toString());
308 Element outputModeNode = xmlUtilities.createArtifactElement(document,"output"); 346 Element outputModeNode = xmlUtilities
347 .createArtifactElement(document, "output");
309 outputModeNode.setAttribute("name", outputMode.getName()); 348 outputModeNode.setAttribute("name", outputMode.getName());
310 outputModeNode.setAttribute("description", outputMode.getDescription()); 349 outputModeNode.setAttribute("description", outputMode
311 outputModeNode.setAttribute("mime-type", outputMode.getMimeType()); 350 .getDescription());
351 outputModeNode.setAttribute("mime-type", outputMode
352 .getMimeType());
312 outputsNode.appendChild(outputModeNode); 353 outputsNode.appendChild(outputModeNode);
313 354
314 Collection<InputValue> inputParameters = outputMode.getInputParameters(); 355 Collection<InputValue> inputParameters = outputMode
315 if (inputParameters != null){ 356 .getInputParameters();
316 Element inputParametersNode = xmlUtilities.createArtifactElement(document,"parameter"); 357 if (inputParameters != null) {
358 Element inputParametersNode = xmlUtilities
359 .createArtifactElement(document, "parameter");
317 outputModeNode.appendChild(inputParametersNode); 360 outputModeNode.appendChild(inputParametersNode);
318 Iterator<InputValue> it2 = inputParameters.iterator(); 361 Iterator<InputValue> it2 = inputParameters.iterator();
319 while (it2.hasNext()){ 362 while (it2.hasNext()) {
320 InputValue inputValue = it2.next(); 363 InputValue inputValue = it2.next();
321 Element inputParameterNode = xmlUtilities.createArtifactElement(document,"parameter"); 364 Element inputParameterNode = xmlUtilities
365 .createArtifactElement(document,
366 "parameter");
322 inputParametersNode.appendChild(inputParameterNode); 367 inputParametersNode.appendChild(inputParameterNode);
323 inputParameterNode.setAttribute("name", inputValue.getName()); 368 inputParameterNode.setAttribute("name", inputValue
324 inputParameterNode.setAttribute("type", inputValue.getType()); 369 .getName());
325 inputParameterNode.setAttribute("value", inputValue.getDefaultValue()); 370 inputParameterNode.setAttribute("type", inputValue
371 .getType());
372 inputParameterNode.setAttribute("value", inputValue
373 .getDefaultValue());
326 } 374 }
327 } 375 }
328 } 376 }
329 }else{ 377 } else {
330 log.warn("No Outputmodes given."); 378 log.warn("No Outputmodes given.");
331 } 379 }
332 } 380 }
333 parent.appendChild(outputsNode); 381 parent.appendChild(outputsNode);
334 } 382 }
335 383
336 384 protected Collection<InputData> parseInputData(Document document,
337 protected Collection<InputData> parseInputData(Document document, String xPath){ 385 String xPath) {
338 log.debug("GNVArtifactBase.parseInputData"); 386 log.debug("GNVArtifactBase.parseInputData");
339 HashMap<String,InputData> returnValue = null; 387 HashMap<String, InputData> returnValue = null;
340 388
341 log.debug(new ArtifactXMLUtilities().writeDocument2String(document)); 389 log.debug(new ArtifactXMLUtilities().writeDocument2String(document));
342 390
343 NodeList inputElemets = (NodeList)XMLUtils.xpath(document, xPath,XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE);//Config.getNodeSetXPath(document, ""); 391 NodeList inputElemets = (NodeList) XMLUtils.xpath(document, xPath,
344 if(inputElemets != null){ 392 XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE);// Config.getNodeSetXPath(document,
345 returnValue = new HashMap<String,InputData>(inputElemets.getLength()); 393 // "");
346 for (int i = 0; i < inputElemets.getLength(); i++){ 394 if (inputElemets != null) {
395 returnValue = new HashMap<String, InputData>(inputElemets
396 .getLength());
397 for (int i = 0; i < inputElemets.getLength(); i++) {
347 Node inputDataNode = inputElemets.item(i); 398 Node inputDataNode = inputElemets.item(i);
348 String name = Config.getStringXPath(inputDataNode,"@name"); 399 String name = Config.getStringXPath(inputDataNode, "@name");
349 String value = Config.getStringXPath(inputDataNode,"@value"); 400 String value = Config.getStringXPath(inputDataNode, "@value");
350 401
351 if (returnValue.containsKey(name)){ 402 if (returnValue.containsKey(name)) {
352 InputData inputData = returnValue.get(name); 403 InputData inputData = returnValue.get(name);
353 inputData.concartValue(value); 404 inputData.concartValue(value);
354 log.debug(inputData.toString()); 405 log.debug(inputData.toString());
355 returnValue.put(name, inputData); 406 returnValue.put(name, inputData);
356 }else{ 407 } else {
357 InputData inputData = new DefaultInputData(name,value); 408 InputData inputData = new DefaultInputData(name, value);
358 409
359 returnValue.put(name,inputData); 410 returnValue.put(name, inputData);
360 } 411 }
361 } 412 }
362 } 413 }
363 return returnValue.values(); 414 return returnValue.values();
364 } 415 }
365 416
366
367 /** 417 /**
368 * @see de.intevation.artifactdatabase.DefaultArtifact#out(org.w3c.dom.Document, 418 * @see de.intevation.artifactdatabase.DefaultArtifact#out(org.w3c.dom.Document,
369 * java.io.OutputStream, de.intevation.artifacts.CallContext) 419 * java.io.OutputStream, de.intevation.artifacts.CallContext)
370 */ 420 */
371 @Override 421 @Override
386 log.error(e, e); 436 log.error(e, e);
387 throw new IOException(e.getMessage()); 437 throw new IOException(e.getMessage());
388 } 438 }
389 } 439 }
390 440
391 441 protected String readOutputType(Document document) {
392 protected String readOutputType(Document document){ 442 String value = Config.getStringXPath(document, "action/out/@name");
393 String value = Config.getStringXPath(document,"action/out/@name");
394 return value; 443 return value;
395 } 444 }
396 } 445 }

http://dive4elements.wald.intevation.org