changeset 812:70b728a9f4e8

Meta data service: Create correct request document now. flys-client/trunk@2468 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 08 Aug 2011 14:49:14 +0000
parents 8fa303586f14
children 57ea5af8a967
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java flys-client/src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java flys-client/src/main/java/de/intevation/flys/client/server/meta/Converter.java
diffstat 4 files changed, 39 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon Aug 08 11:02:45 2011 +0000
+++ b/flys-client/ChangeLog	Mon Aug 08 14:49:14 2011 +0000
@@ -1,4 +1,15 @@
-2011-08-08  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+2011-08-08	Sascha L. Teichmann	<sascha.teichmann@intevation.de> 
+
+	* src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java:
+	  Do not cry for missing i18n if running into error.
+
+	* src/main/java/de/intevation/flys/client/server/meta/Converter.java:
+	  Convert more stuff.
+	  
+	* src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java:
+	  Create correct request document now.
+
+2011-08-08	Sascha L. Teichmann	<sascha.teichmann@intevation.de> 
 
 	* src/main/java/de/intevation/flys/client/client/services/MetaDataService.java,
 	  src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java	Mon Aug 08 11:02:45 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java	Mon Aug 08 14:49:14 2011 +0000
@@ -98,7 +98,7 @@
             new AsyncCallback<DataCageTree>() {
                 public void onFailure(Throwable caught) {
                     GWT.log("Could not load meta data.");
-                    SC.warn(messages.getString(caught.getMessage()));
+                    SC.warn(caught.getMessage());
                 }
 
                 public void onSuccess(DataCageTree tree) {
--- a/flys-client/src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java	Mon Aug 08 11:02:45 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java	Mon Aug 08 14:49:14 2011 +0000
@@ -36,7 +36,7 @@
         String userId
     ) throws ServerException
     {
-        System.out.println("MetaDataService.getDistanceInfo");
+        System.out.println("MetaDataService.getMetaData");
 
         Document doc = XMLUtils.newDocument();
 
@@ -45,19 +45,22 @@
             ArtifactNamespaceContext.NAMESPACE_URI,
             ArtifactNamespaceContext.NAMESPACE_PREFIX);
 
+        Element meta = ec.create("meta");
 
         if (artifactId != null) {
             Element artifactEl = ec.create("artifact-id");
             artifactEl.setAttribute("value", artifactId);
-            doc.appendChild(artifactEl);
+            meta.appendChild(artifactEl);
         }
 
         if (userId != null) {
             Element userEl = ec.create("user-id");
             userEl.setAttribute("value", userId);
-            doc.appendChild(userEl);
+            meta.appendChild(userEl);
         }
 
+        doc.appendChild(meta);
+
         HttpClient client = new HttpClientImpl(url, locale);
 
         try {
@@ -65,7 +68,7 @@
             return converter.convert(client.callService(url, "metadata", doc));
         }
         catch (ConnectionException ce) {
-            System.err.println(ce.getLocalizedMessage());
+            ce.printStackTrace();
         }
 
         throw new ServerException(ERROR_NO_META_DATA_FOUND);
--- a/flys-client/src/main/java/de/intevation/flys/client/server/meta/Converter.java	Mon Aug 08 11:02:45 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/meta/Converter.java	Mon Aug 08 14:49:14 2011 +0000
@@ -12,6 +12,8 @@
 import java.util.Map;
 import java.util.HashMap;
 
+import de.intevation.artifacts.common.utils.XMLUtils;
+
 public class Converter
 {
     public interface NodeConverter
@@ -49,11 +51,12 @@
             if (child.getNodeType() == Node.ELEMENT_NODE) {
                 String name = child.getLocalName();
                 NodeConverter converter = converters.get(name);
-                if (converter != null) {
-                    DataCageNode son = converter.convert(
-                        (Element)child, this);
-                    parent.addChild(son);
+                if (converter == null) {
+                    converter = I18N_CONVERTER;
                 }
+                DataCageNode son = converter.convert(
+                    (Element)child, this);
+                parent.addChild(son);
             }
         } // for all children
     }
@@ -63,31 +66,21 @@
         registerConverters();
     }
 
+    public static final NodeConverter NAME_CONVERTER = new NameConverter(); 
+    public static final NodeConverter I18N_CONVERTER = new I18NConverter(); 
+
     protected void registerConverters() {
         System.err.println("register converters called");
-        converters.put("datacage",                    new NameConverter());
-        converters.put("river",                       new NameConverter());
-        converters.put("gauge",                       new NameConverter());
-        converters.put("historical",                  new NameConverter());
-        converters.put("discharge-table-nn",          new I18NConverter());
-        converters.put("discharge-table-gauge",       new I18NConverter());
-        converters.put("fixations",                   new I18NConverter());
-        converters.put("fixation",                    new I18NConverter());
-        converters.put("columns",                     new I18NConverter());
-        converters.put("column",                      new NameConverter());
-        converters.put("flood-protections",           new I18NConverter());
-        converters.put("flood-protection",            new I18NConverter());
-        converters.put("flood-water-marks",           new I18NConverter());
-        converters.put("flood-water-mark",            new I18NConverter());
-        converters.put("water-levels",                new I18NConverter());
-        converters.put("water-level",                 new I18NConverter());
-        converters.put("extra-longitudinal-sections", new I18NConverter());
-        converters.put("extra-longitudinal-section",  new I18NConverter());
-        converters.put("longitudinal-section",        new I18NConverter());
+        converters.put("datacage",   NAME_CONVERTER);
+        converters.put("river",      NAME_CONVERTER);
+        converters.put("gauge",      NAME_CONVERTER);
+        converters.put("historical", NAME_CONVERTER);
+        converters.put("column",     NAME_CONVERTER);
     }
 
     public DataCageTree convert(Document document) {
         System.err.println("convert called");
+        //System.err.println(XMLUtils.toString(document));
 
         ArrayList<DataCageNode> roots = new ArrayList<DataCageNode>();
         NodeList nodes = document.getChildNodes();
@@ -96,9 +89,10 @@
             if (node.getNodeType() == Node.ELEMENT_NODE) {
                 System.err.println("search for name: " + node.getLocalName());
                 NodeConverter converter = converters.get(node.getLocalName());
-                if (converter != null) {
-                    roots.add(converter.convert((Element)node, this));
+                if (converter == null) {
+                    converter = I18N_CONVERTER;
                 }
+                roots.add(converter.convert((Element)node, this));
             }
         }
         return roots.isEmpty()

http://dive4elements.wald.intevation.org