changeset 976:d830c398c8f4

Improved XPath handling for absent flags. flys-artifacts/trunk@2402 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 25 Jul 2011 14:12:14 +0000
parents a111f0984706
children 598a5e911118
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/meta-data-template.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/Builder.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/DataCage.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/FunctionResolver.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/StackFrames.java
diffstat 6 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Jul 25 12:56:53 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon Jul 25 14:12:14 2011 +0000
@@ -1,3 +1,16 @@
+2011-07-25  Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	* doc/conf/meta-data-template.xml: '$recommended' lead to XPath
+	  errors. Using "dc:contains($parameters, 'recommended')" helps.
+
+	* src/main/java/de/intevation/flys/artifacts/services/meta/Builder.java,
+	  src/main/java/de/intevation/flys/artifacts/services/meta/FunctionResolver.java:
+	  Added some debugging.
+
+	* src/main/java/de/intevation/flys/artifacts/services/meta/DataCage.java:
+	  Added parameters as 'parameters' to parameters. Usefull to check
+	  for containment of variables.
+
 2011-07-25  Sascha L. Teichmann <sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/services/MetaDataService.java:
--- a/flys-artifacts/doc/conf/meta-data-template.xml	Mon Jul 25 12:56:53 2011 +0000
+++ b/flys-artifacts/doc/conf/meta-data-template.xml	Mon Jul 25 14:12:14 2011 +0000
@@ -214,7 +214,7 @@
         <dc:if test="dc:contains($artifact-outs, 'floodmap')">
             <floodmap>
             <dc:choose>
-                <dc:when test="$recommended">
+                <dc:when test="dc:contains($parameters, 'recommended')">
                   <dc:call-macro name="flood-map-recommended"/>
                 </dc:when>
                 <dc:otherwise>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/Builder.java	Mon Jul 25 12:56:53 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/Builder.java	Mon Jul 25 14:12:14 2011 +0000
@@ -282,6 +282,11 @@
         }
 
         protected Boolean evaluateXPath(String expr) {
+
+            if (log.isDebugEnabled()) {
+                log.debug("evaluate: '" + expr + "'");
+            }
+
             try {
                 XPath xpath = XPATH_FACTORY.newXPath();
                 xpath.setXPathVariableResolver(frames);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/DataCage.java	Mon Jul 25 12:56:53 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/DataCage.java	Mon Jul 25 14:12:14 2011 +0000
@@ -87,6 +87,8 @@
 
         parameters.put("artifact-outs", outs);
 
+        parameters.put("parameters", parameters);
+
         recommend(parameters, result);
     }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/FunctionResolver.java	Mon Jul 25 12:56:53 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/FunctionResolver.java	Mon Jul 25 14:12:14 2011 +0000
@@ -11,9 +11,13 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.log4j.Logger;
+
 public class FunctionResolver
 implements   XPathFunctionResolver
 {
+    private static Logger log = Logger.getLogger(FunctionResolver.class);
+
     public static final String FUNCTION_NAMESPACE_URI = "dc";
 
     public static final class Entry {
@@ -62,6 +66,7 @@
                     return Boolean.FALSE;
                 }
                 catch (Exception e) {
+                    log.error(e);
                     throw new XPathFunctionException(e);
                 }
             }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/StackFrames.java	Mon Jul 25 12:56:53 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/StackFrames.java	Mon Jul 25 14:12:14 2011 +0000
@@ -9,9 +9,13 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.log4j.Logger;
+
 public class StackFrames
 implements   XPathVariableResolver
 {
+    private static Logger log = Logger.getLogger(StackFrames.class);
+
     protected List<Map<String, Object>> frames;
 
     public StackFrames() {
@@ -74,6 +78,9 @@
 
     @Override
     public Object resolveVariable(QName variableName) {
+        if (log.isDebugEnabled()) {
+            log.debug("resolve var: " + variableName);
+        }
         return get(variableName.getLocalPart());
     }
 }

http://dive4elements.wald.intevation.org