changeset 2741:0251393f037c

Refactor usage of now static xpath, other artifacts will follow in later commits. flys-artifacts/trunk@4475 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 23 May 2012 10:17:06 +0000
parents 64dc2997b2dd
children faf73245ec73
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/AreaArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/HYKArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWQKmsArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WQKmsInterpolArtifact.java
diffstat 9 files changed, 32 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed May 23 10:04:11 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed May 23 10:17:06 2012 +0000
@@ -1,3 +1,17 @@
+2012-05-23	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java
+	  (getDatacageIDValue): New, extracted from various duplicates.
+
+	* src/main/java/de/intevation/flys/artifacts/HYKArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/AreaArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/WQKmsInterpolArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/StaticWQKmsArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java:
+	  Use getDatacageIDValue() from superclass or static context.
+
 2012-05-23	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AreaArtifact.java	Wed May 23 10:04:11 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AreaArtifact.java	Wed May 23 10:17:06 2012 +0000
@@ -77,8 +77,7 @@
         super.setup(identifier, factory, context, callMeta, data);
 
         // TODO yet unused.
-        String ids = XMLUtils.xpathString(
-            data, XPATH_IDS, ArtifactNamespaceContext.INSTANCE);
+        String ids = getDatacageIDValue(data);
 
         // TODO this facet will be remodeled during next feed.
         List<Facet> fs = new ArrayList<Facet>();
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java	Wed May 23 10:04:11 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java	Wed May 23 10:17:06 2012 +0000
@@ -81,8 +81,7 @@
 
         super.setup(identifier, factory, context, callMeta, data);
 
-        String ids = XMLUtils.xpathString(
-            data, XPATH_IDS, ArtifactNamespaceContext.INSTANCE);
+        String ids = getDatacageIDValue(data);
 
         if (ids != null && ids.length() > 0) {
             addStringData(DATA_DBID, ids);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java	Wed May 23 10:04:11 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java	Wed May 23 10:17:06 2012 +0000
@@ -74,11 +74,8 @@
     {
         logger.debug("GaugeDischargeArtifact.setup");
         super.setup(identifier, factory, context, callMeta, data);
-        String ids = XMLUtils.xpathString(
-            data, StaticFLYSArtifact.XPATH_IDS,
-            ArtifactNamespaceContext.INSTANCE);
+        String ids = StaticFLYSArtifact.getDatacageIDValue(data);
         logger.debug("id for gaugedischarge: " + ids);
-
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/HYKArtifact.java	Wed May 23 10:04:11 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/HYKArtifact.java	Wed May 23 10:17:06 2012 +0000
@@ -56,8 +56,7 @@
     {
         logger.info("HYKArtifact.setup");
 
-        String ids = XMLUtils.xpathString(
-            data, XPATH_IDS, ArtifactNamespaceContext.INSTANCE);
+        String ids = getDatacageIDValue(data);
 
         logger.info("HYKArtifact.setup: id is " + ids);
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java	Wed May 23 10:04:11 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java	Wed May 23 10:17:06 2012 +0000
@@ -78,6 +78,17 @@
     }
 
 
+    /**
+     * Return the value of id element in Datacage data document.
+     * @param data Document as passed by datacage.
+     * @return the id element value of data document.
+     */
+    public static String getDatacageIDValue(Document data) {
+        return XMLUtils.xpathString(data, XPATH_IDS,
+            ArtifactNamespaceContext.INSTANCE);
+    }
+
+
     protected Element createOutputModes(
         CallContext    cc,
         Document       doc,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWQKmsArtifact.java	Wed May 23 10:04:11 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWQKmsArtifact.java	Wed May 23 10:17:06 2012 +0000
@@ -67,8 +67,7 @@
         // Store the 'ids' (from datacage).
         logger.debug("StaticWQKmsArtiact.setup" + XMLUtils.toString(data));
 
-        String code = XMLUtils.xpathString(
-            data, XPATH_IDS, ArtifactNamespaceContext.INSTANCE);
+        String code = getDatacageIDValue(data);
         addStringData("ids", code);
         if (code != null) {
             String [] parts = code.split("-");
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java	Wed May 23 10:04:11 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java	Wed May 23 10:17:06 2012 +0000
@@ -53,8 +53,7 @@
 
         super.setup(identifier, factory, context, callMeta, data);
 
-        String ids = XMLUtils.xpathString(
-            data, XPATH_IDS, ArtifactNamespaceContext.INSTANCE);
+        String ids = getDatacageIDValue(data);
 
         if (ids != null && ids.length() > 0) {
             addData("ids", new DefaultStateData("ids", null, null, ids));
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WQKmsInterpolArtifact.java	Wed May 23 10:04:11 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WQKmsInterpolArtifact.java	Wed May 23 10:17:06 2012 +0000
@@ -75,8 +75,7 @@
         state = new StaticState(STATIC_STATE_NAME);
 
         List<Facet> fs = new ArrayList<Facet>();
-        String code = XMLUtils.xpathString(
-            data, XPATH_IDS, ArtifactNamespaceContext.INSTANCE);
+        String code = getDatacageIDValue(data);
 
         // TODO Go for JSON, one day.
         //ex.: flood_protection-wstv-114-12

http://dive4elements.wald.intevation.org