diff gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java @ 57:f01592cd6419

Funktionalität Feed initial bereitgestellt. gnv-artifacts/trunk@39 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 08 Sep 2009 12:22:00 +0000
parents 737d8bf63701
children f31343d80d53
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java	Tue Sep 08 10:39:50 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java	Tue Sep 08 12:22:00 2009 +0000
@@ -3,6 +3,7 @@
  */
 package de.intevation.gnv.artifacts;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -17,9 +18,12 @@
 import de.intevation.artifactdatabase.Config;
 import de.intevation.artifactdatabase.DefaultArtifact;
 import de.intevation.gnv.artifacts.context.GNVArtifactContext;
+import de.intevation.gnv.transition.DefaultInputData;
+import de.intevation.gnv.transition.InputData;
 import de.intevation.gnv.transition.InputValue;
 import de.intevation.gnv.transition.Transition;
 import de.intevation.gnv.transition.TransitionFactory;
+import de.intevation.gnv.transition.exception.TransitionException;
 
 /**
  * @author Tim Englich <tim.englich@intevation.de>
@@ -76,6 +80,24 @@
     }
     
     /**
+     * @see de.intevation.artifactdatabase.DefaultArtifact#feed(org.w3c.dom.Document, java.lang.Object)
+     */
+    @Override
+    public Document feed(Document target, Object context) {
+        Document result = super.newDocument();
+        try {
+            if (this.current != null){
+                this.current.putInputData(this.parseInputData(target));
+                // TODO Ergebnisdokument erzeugen.
+            }
+        } catch (TransitionException e) {
+            log.error(e,e);
+            //TODO: Fehlerdokumenterzeugen.
+        }
+        return result;
+    }
+    
+    /**
      * @see de.intevation.artifactdatabase.DefaultArtifact#setup(java.lang.String, java.lang.Object)
      */
     @Override
@@ -203,5 +225,22 @@
         return node;
     }
     
+    protected Collection<InputData> parseInputData(Document document){
+        log.debug("GNVArtifactBase.parseInputData");
+        Collection<InputData> returnValue = null;
+        
+        NodeList inputElemets = Config.getNodeSetXPath(document, "action/data/input");
+        if(inputElemets != null){
+            returnValue = new ArrayList<InputData>(inputElemets.getLength());
+            for (int i = 0; i < inputElemets.getLength(); i++){
+                Node inputDataNode = inputElemets.item(i);
+                InputData inputData = new DefaultInputData(Config.getStringXPath(inputDataNode,"@name"), Config.getStringXPath(inputDataNode,"@value"));
+                log.debug(inputData.toString());
+                returnValue.add(inputData);
+            }
+        }
+        return returnValue;
+    }
+    
 
 }

http://dive4elements.wald.intevation.org