commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [19/45] commons-rdf git commit: Test removal of Triple as well
Date Fri, 10 Feb 2017 16:55:21 GMT
Test removal of Triple as well

Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/6b07abf4
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/6b07abf4
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/6b07abf4

Branch: refs/heads/COMMONSRDF-47
Commit: 6b07abf49be486d6985de3c9fe8425adaabc1c38
Parents: d5964a1
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Thu Jan 26 14:24:13 2017 +0000
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Thu Jan 26 14:24:13 2017 +0000

----------------------------------------------------------------------
 .../commons/rdf/jena/impl/JenaGraphImpl.java     | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/6b07abf4/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java
index e3805b6..76e92f7 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java
@@ -24,10 +24,12 @@ import java.util.stream.Stream;
 
 import org.apache.commons.rdf.api.BlankNodeOrIRI;
 import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.Literal;
 import org.apache.commons.rdf.api.RDFTerm;
 import org.apache.commons.rdf.api.Triple;
 import org.apache.commons.rdf.jena.JenaGraph;
 import org.apache.commons.rdf.jena.JenaRDF;
+import org.apache.commons.rdf.jena.JenaTriple;
 import org.apache.jena.atlas.iterator.Iter;
 import org.apache.jena.graph.Node;
 import org.apache.jena.rdf.model.Model;
@@ -93,8 +95,8 @@ class JenaGraphImpl implements JenaGraph {
 
     @Override
     public void remove(final BlankNodeOrIRI subject, final IRI predicate, final RDFTerm object)
{
-        graph.delete(org.apache.jena.graph.Triple.create(toJenaPattern(subject), toJenaPattern(predicate),
-                toJenaPattern(object)));
+        graph.remove(toJenaPattern(subject), toJenaPattern(predicate),
+                toJenaPattern(object));
     }
 
     private Node toJenaPattern(final RDFTerm pattern) {
@@ -106,7 +108,18 @@ class JenaGraphImpl implements JenaGraph {
 
     @Override
     public void remove(final Triple triple) {
-        graph.delete(factory.asJenaTriple(triple));
+        if ((triple.getObject() instanceof Literal) && 
+                ((Literal) triple.getObject()).getLanguageTag().isPresent()) {
+            // COMMONSRDF-51: graph.delete(Triple) would be too restrictive
+            // as it won't delete triples with different lang tag - so 
+            // we'll need to use the pattern matching graph.remove instead()
+            graph.remove(
+                    factory.asJenaNode(triple.getSubject()), 
+                    factory.asJenaNode(triple.getPredicate()),
+                    factory.asJenaNode(triple.getObject()));
+        } else {
+            graph.delete(factory.asJenaTriple(triple));
+        }
     }
 
     @Override


Mime
View raw message