[Dive4elements-commits] [PATCH 4 of 4] Expose function dc:has-result to Function Resolver

Wald Commits scm-commit at wald.intevation.org
Tue Mar 26 16:29:26 CET 2013


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1364311752 -3600
# Node ID df32d7518f5535ff9bf09d4c42850b211365eff5
# Parent  d0f5bc8064f17d43484f004e913ef9bbf1fec40c
Expose function dc:has-result to Function Resolver.

diff -r d0f5bc8064f1 -r df32d7518f55 flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/Builder.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/Builder.java	Tue Mar 26 16:24:07 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/Builder.java	Tue Mar 26 16:29:12 2013 +0100
@@ -236,6 +236,10 @@
             }
         }
 
+        public boolean hasResult() {
+            return !connectionsStack.isEmpty()
+                && !connectionsStack.peek().getB().isEmpty();
+        }
 
         protected ResultData createFilteredResultData(ResultData rd, String filter) {
             if (filter == null) return rd;
diff -r d0f5bc8064f1 -r df32d7518f55 flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/FunctionResolver.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/FunctionResolver.java	Tue Mar 26 16:24:07 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/FunctionResolver.java	Tue Mar 26 16:29:12 2013 +0100
@@ -74,6 +74,13 @@
                 return toValue(args);
             }
         });
+
+        addFunction("has-result", 0, new XPathFunction() {
+            @Override
+            public Object evaluate(List args) throws XPathFunctionException {
+                return FunctionResolver.this.buildHelper.hasResult();
+            }
+        });
     }
 
     /**


More information about the Dive4elements-commits mailing list