comparison gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java @ 91:bd284d8306db

Added Support for Patameters in OutputModes gnv-artifacts/trunk@135 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 25 Sep 2009 14:37:10 +0000
parents 6bdef6e590d6
children bb45c5097cb6
comparison
equal deleted inserted replaced
90:6bdef6e590d6 91:bd284d8306db
158 public Document feed(Document target, CallContext context) { 158 public Document feed(Document target, CallContext context) {
159 log.debug("GNVArtifactBase.feed"); 159 log.debug("GNVArtifactBase.feed");
160 Document result = XMLUtils.newDocument(); 160 Document result = XMLUtils.newDocument();
161 try { 161 try {
162 if (this.current != null){ 162 if (this.current != null){
163 this.current.putInputData(this.parseInputData(target)); 163 this.current.putInputData(this.parseInputData(target, "/action/data/input"));
164 result = new ArtifactXMLUtilities().createSuccessReport("Feed success", XMLUtils.newDocument()); 164 result = new ArtifactXMLUtilities().createSuccessReport("Feed success", XMLUtils.newDocument());
165 }else{ 165 }else{
166 String msg = "No Transition instantiated"; 166 String msg = "No Transition instantiated";
167 log.warn(msg); 167 log.warn(msg);
168 result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument()); 168 result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument());
306 Element outputModeNode = xmlUtilities.createArtifactElement(document,"output"); 306 Element outputModeNode = xmlUtilities.createArtifactElement(document,"output");
307 outputModeNode.setAttribute("name", outputMode.getName()); 307 outputModeNode.setAttribute("name", outputMode.getName());
308 outputModeNode.setAttribute("description", outputMode.getDescription()); 308 outputModeNode.setAttribute("description", outputMode.getDescription());
309 outputModeNode.setAttribute("mime-type", outputMode.getMimeType()); 309 outputModeNode.setAttribute("mime-type", outputMode.getMimeType());
310 outputsNode.appendChild(outputModeNode); 310 outputsNode.appendChild(outputModeNode);
311
312 Collection<InputValue> inputParameters = outputMode.getInputParameters();
313 if (inputParameters != null){
314 Element inputParametersNode = xmlUtilities.createArtifactElement(document,"parameter");
315 outputModeNode.appendChild(inputParametersNode);
316 Iterator<InputValue> it2 = inputParameters.iterator();
317 while (it2.hasNext()){
318 InputValue inputValue = it2.next();
319 Element inputParameterNode = xmlUtilities.createArtifactElement(document,"parameter");
320 inputParametersNode.appendChild(inputParameterNode);
321 inputParameterNode.setAttribute("name", inputValue.getName());
322 inputParameterNode.setAttribute("type", inputValue.getType());
323 inputParameterNode.setAttribute("value", inputValue.getDefaultValue());
324 }
325 }
311 } 326 }
312 }else{ 327 }else{
313 log.warn("No Outputmodes given."); 328 log.warn("No Outputmodes given.");
314 } 329 }
315 } 330 }
316 parent.appendChild(outputsNode); 331 parent.appendChild(outputsNode);
317 } 332 }
318 333
319 334
320 protected Collection<InputData> parseInputData(Document document){ 335 protected Collection<InputData> parseInputData(Document document, String xPath){
321 log.debug("GNVArtifactBase.parseInputData"); 336 log.debug("GNVArtifactBase.parseInputData");
322 HashMap<String,InputData> returnValue = null; 337 HashMap<String,InputData> returnValue = null;
323 338
324 log.debug(new ArtifactXMLUtilities().writeDocument2String(document)); 339 log.debug(new ArtifactXMLUtilities().writeDocument2String(document));
325 340
326 NodeList inputElemets = (NodeList)XMLUtils.xpath(document, "/action/data/input",XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE);//Config.getNodeSetXPath(document, ""); 341 NodeList inputElemets = (NodeList)XMLUtils.xpath(document, xPath,XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE);//Config.getNodeSetXPath(document, "");
327 if(inputElemets != null){ 342 if(inputElemets != null){
328 returnValue = new HashMap<String,InputData>(inputElemets.getLength()); 343 returnValue = new HashMap<String,InputData>(inputElemets.getLength());
329 for (int i = 0; i < inputElemets.getLength(); i++){ 344 for (int i = 0; i < inputElemets.getLength(); i++){
330 Node inputDataNode = inputElemets.item(i); 345 Node inputDataNode = inputElemets.item(i);
331 String name = Config.getStringXPath(inputDataNode,"@name"); 346 String name = Config.getStringXPath(inputDataNode,"@name");
358 throws IOException { 373 throws IOException {
359 log.debug("TGNVArtifactBase.out"); 374 log.debug("TGNVArtifactBase.out");
360 try { 375 try {
361 376
362 if (current != null && current instanceof OutputTransition){ 377 if (current != null && current instanceof OutputTransition){
363 ((OutputTransition)current).out(this.readOutputType(format), outputStream); 378 ((OutputTransition)current).out(this.readOutputType(format),this.parseInputData(format, "/action/out/params/input"), outputStream);
364 context.afterCall(CallContext.STORE); // TODO: FIXME Schmutzige Lösung: Besser einen weiteren Transitionsschritt zwischenschalten. 379 context.afterCall(CallContext.STORE); // TODO: FIXME Schmutzige Lösung: Besser einen weiteren Transitionsschritt zwischenschalten.
365 } 380 }
366 } catch (TransitionException e) { 381 } catch (TransitionException e) {
367 log.error(e,e); 382 log.error(e,e);
368 throw new IOException(e.getMessage()); 383 throw new IOException(e.getMessage());
369 } 384 }
370 } 385 }
371 386
387
372 protected String readOutputType(Document document){ 388 protected String readOutputType(Document document){
373 String value = Config.getStringXPath(document,"action/out/@name"); 389 String value = Config.getStringXPath(document,"action/out/@name");
374 return value; 390 return value;
375 } 391 }
376 } 392 }

http://dive4elements.wald.intevation.org