You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2014/10/06 11:27:33 UTC

[1/2] git commit: fixes MARMOTTA-546 (SPARQL bound bug)

Repository: marmotta
Updated Branches:
  refs/heads/develop 8e0160f8d -> 1e30102ae


fixes MARMOTTA-546 (SPARQL bound bug)


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/d8e0e30c
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/d8e0e30c
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/d8e0e30c

Branch: refs/heads/develop
Commit: d8e0e30ce8e088a0b9f1eff6f5ad07e5a8f2ea5b
Parents: 3bd8124
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Mon Oct 6 11:27:47 2014 +0200
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Mon Oct 6 11:27:47 2014 +0200

----------------------------------------------------------------------
 .../kiwi/sparql/builder/SQLBuilder.java         | 10 +++++++
 .../evaluation/KiWiEvaluationStrategyImpl.java  |  2 ++
 .../kiwi/sparql/test/KiWiSparqlJoinTest.java    | 23 +++++++++++++++-
 .../marmotta/kiwi/sparql/test/query34.sparql    | 28 ++++++++++++++++++++
 4 files changed, 62 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/d8e0e30c/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLBuilder.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLBuilder.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLBuilder.java
index a160806..f2f5dde 100644
--- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLBuilder.java
+++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLBuilder.java
@@ -759,6 +759,16 @@ public class SQLBuilder {
             } else {
                 return "(" + value + " = '"+pattern.getValue().stringValue()+"' OR " + dialect.getILike(value, "'" + pattern.getValue().stringValue() + "-%' )");
             }
+        } else if(expr instanceof Bound) {
+            ValueExpr arg = ((Bound)expr).getArg();
+
+            if(arg instanceof ValueConstant) {
+                return Boolean.toString(true);
+            } else if(arg instanceof Var) {
+
+                return "(" + evaluateExpression(arg, optype) + " IS NOT NULL)";
+            }
+
         } else if(expr instanceof IsResource) {
             ValueExpr arg = ((UnaryValueOperator)expr).getArg();
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/d8e0e30c/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/evaluation/KiWiEvaluationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/evaluation/KiWiEvaluationStrategyImpl.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/evaluation/KiWiEvaluationStrategyImpl.java
index e625a17..14e69d8 100644
--- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/evaluation/KiWiEvaluationStrategyImpl.java
+++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/evaluation/KiWiEvaluationStrategyImpl.java
@@ -335,6 +335,8 @@ public class KiWiEvaluationStrategyImpl extends EvaluationStrategyImpl{
             return isAtomic(((Str) expr).getArg());
         } else if(expr instanceof Label) {
             return isAtomic(((UnaryValueOperator) expr).getArg());
+        } else if(expr instanceof Bound) {
+            return true;
         } else if(expr instanceof IsResource) {
             return isAtomic(((UnaryValueOperator) expr).getArg());
         } else if(expr instanceof IsURI) {

http://git-wip-us.apache.org/repos/asf/marmotta/blob/d8e0e30c/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlJoinTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlJoinTest.java b/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlJoinTest.java
index db78564..9450126 100644
--- a/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlJoinTest.java
+++ b/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlJoinTest.java
@@ -36,6 +36,7 @@ import org.junit.*;
 import org.junit.rules.TestWatcher;
 import org.junit.runner.Description;
 import org.junit.runner.RunWith;
+import org.openrdf.model.BNode;
 import org.openrdf.model.Statement;
 import org.openrdf.model.URI;
 import org.openrdf.model.impl.URIImpl;
@@ -331,6 +332,13 @@ public class KiWiSparqlJoinTest {
         testQuery("query33.sparql");
     }
 
+    // MARMOTTA-546
+    @Test
+    public void testQuery34() throws Exception {
+        testQuery("query34.sparql");
+    }
+
+
 
     // INSERT/UPDATE
     @Test
@@ -502,6 +510,14 @@ public class KiWiSparqlJoinTest {
         Set<Set<Pair>> set1 = new HashSet<Set<Pair>>(Lists.transform(bindingSets1,new BindingSetPairFunction()));
         Set<Set<Pair>> set2 = new HashSet<Set<Pair>>(Lists.transform(bindingSets2,new BindingSetPairFunction()));
 
+        for(Set<Pair> p : set1) {
+            Assert.assertTrue("binding " + p + " from result set not found in reference set", set2.contains(p));
+        }
+        for(Set<Pair> p : set2) {
+            Assert.assertTrue("binding " + p + " from reference set not found in result set", set1.contains(p));
+        }
+
+
         Assert.assertTrue(CollectionUtils.isEqualCollection(set1, set2));
     }
 
@@ -512,7 +528,7 @@ public class KiWiSparqlJoinTest {
             Set<Pair> result = new HashSet<Pair>();
 
             for(Binding b : input) {
-                Pair p = new Pair(b.getName(), b.getValue() != null ? b.getValue().stringValue() : null);
+                Pair p = new Pair(b.getName(), b.getValue() != null ? (b.getValue() instanceof BNode ? "_" : b.getValue().stringValue()) : null);
                 result.add(p);
             }
 
@@ -555,6 +571,11 @@ public class KiWiSparqlJoinTest {
             result = 31 * result + (value != null ? value.hashCode() : 0);
             return result;
         }
+
+        @Override
+        public String toString() {
+            return key + " = " + value;
+        }
     }
 
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/d8e0e30c/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/query34.sparql
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/query34.sparql b/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/query34.sparql
new file mode 100644
index 0000000..7b73b41
--- /dev/null
+++ b/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/query34.sparql
@@ -0,0 +1,28 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+PREFIX foaf: <http://xmlns.com/foaf/0.1/>
+PREFIX dc: <http://purl.org/dc/elements/1.1/>
+
+
+# Test for MARMOTTA-546
+
+SELECT DISTINCT ?property ?hasValue ?isValueOf WHERE {
+  { <http://localhost:8080/LMF/resource/hans_meier> ?property ?hasValue }
+UNION
+  { ?isValueOf ?property <http://localhost:8080/LMF/resource/hans_meier> }
+} ORDER BY (!BOUND(?hasValue)) ?property ?hasValue ?isValueOf
\ No newline at end of file


[2/2] git commit: Merge remote-tracking branch 'origin/develop' into develop

Posted by ss...@apache.org.
Merge remote-tracking branch 'origin/develop' into develop


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/1e30102a
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/1e30102a
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/1e30102a

Branch: refs/heads/develop
Commit: 1e30102ae431f010643768a779999d022f9a6229
Parents: d8e0e30 8e0160f
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Mon Oct 6 11:28:00 2014 +0200
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Mon Oct 6 11:28:00 2014 +0200

----------------------------------------------------------------------
 .../marmotta-client-js/src/main/js/marmotta.js  | 300 ++++++++++---------
 .../platform/ldp/services/LdpServiceImpl.java   |  37 ++-
 2 files changed, 181 insertions(+), 156 deletions(-)
----------------------------------------------------------------------